the existing seeting of client_id to a VPP version number was unused and so overridden
Change-Id: If9ebea936336f1fcca8d07e67186c95f8f8f0ccd
Signed-off-by: Neale Ranns <nranns@cisco.com>
o = (dhcp_option_t *) (((uword) o) + (o->length + 2));
}
o = (dhcp_option_t *) (((uword) o) + (o->length + 2));
}
+ /* send option 61, client_id */
+ if (vec_len (c->client_identifier))
+ {
+ o->option = 61;
+ o->length = vec_len (c->client_identifier);
+ clib_memcpy (o->data, c->client_identifier,
+ vec_len (c->client_identifier));
+ o = (dhcp_option_t *) (((uword) o) + (o->length + 2));
+ }
+
/* $$ maybe send the client s/w version if anyone cares */
/*
/* $$ maybe send the client s/w version if anyone cares */
/*
dhcp_client_config (vlib_main_t * vm,
u32 sw_if_index,
u8 * hostname,
dhcp_client_config (vlib_main_t * vm,
u32 sw_if_index,
u8 * hostname,
u32 is_add,
u32 client_index,
void * event_callback,
u32 is_add,
u32 client_index,
void * event_callback,
a->event_callback = event_callback;
vec_validate(a->hostname, strlen((char *)hostname) - 1);
strncpy((char *)a->hostname, (char *)hostname, vec_len(a->hostname));
a->event_callback = event_callback;
vec_validate(a->hostname, strlen((char *)hostname) - 1);
strncpy((char *)a->hostname, (char *)hostname, vec_len(a->hostname));
- a->client_identifier = format (0, "vpe 1.0%c", 0);
+ vec_validate(a->client_identifier, strlen((char *)client_id) - 1);
+ strncpy((char *)a->client_identifier, (char *)client_id, vec_len(a->client_identifier));
+
/*
* Option 55 request list. These data precisely match
* the Ubuntu dhcp client. YMMV.
/*
* Option 55 request list. These data precisely match
* the Ubuntu dhcp client. YMMV.
int dhcp_client_config (vlib_main_t * vm,
u32 sw_if_index,
u8 * hostname,
int dhcp_client_config (vlib_main_t * vm,
u32 sw_if_index,
u8 * hostname,
u32 is_add,
u32 client_index,
void *event_callback,
u32 is_add,
u32 client_index,
void *event_callback,
@param context - sender context, to match reply w/ request
@param sw_if_index - index of the interface for DHCP client
@param hostname - hostname
@param context - sender context, to match reply w/ request
@param sw_if_index - index of the interface for DHCP client
@param hostname - hostname
+ @param client_id - Client ID - option 61
@param is_add - add the config if non-zero, else delete
@param want_dhcp_event - DHCP event sent to the sender
via dhcp_compl_event API message if non-zero
@param is_add - add the config if non-zero, else delete
@param want_dhcp_event - DHCP event sent to the sender
via dhcp_compl_event API message if non-zero
u32 context;
u32 sw_if_index;
u8 hostname[64];
u32 context;
u32 sw_if_index;
u8 hostname[64];
u8 is_add;
u8 want_dhcp_event;
u32 pid;
u8 is_add;
u8 want_dhcp_event;
u32 pid;
VALIDATE_SW_IF_INDEX (mp);
rv = dhcp_client_config (vm, ntohl (mp->sw_if_index),
VALIDATE_SW_IF_INDEX (mp);
rv = dhcp_client_config (vm, ntohl (mp->sw_if_index),
- mp->hostname, mp->is_add, mp->client_index,
+ mp->hostname, mp->client_id,
+ mp->is_add, mp->client_index,
mp->want_dhcp_event ? dhcp_compl_event_callback :
NULL, mp->pid);
mp->want_dhcp_event ? dhcp_compl_event_callback :
NULL, mp->pid);
from vpp_ip_route import find_route
from util import mk_ll_addr
from vpp_ip_route import find_route
from util import mk_ll_addr
-from scapy.layers.l2 import Ether, getmacbyip
+from scapy.layers.l2 import Ether, getmacbyip, ARP
from scapy.layers.inet import IP, UDP, ICMP
from scapy.layers.inet6 import IPv6, in6_getnsmac, in6_mactoifaceid
from scapy.layers.dhcp import DHCP, BOOTP, DHCPTypes
from scapy.layers.inet import IP, UDP, ICMP
from scapy.layers.inet6 import IPv6, in6_getnsmac, in6_mactoifaceid
from scapy.layers.dhcp import DHCP, BOOTP, DHCPTypes
self.assertEqual(udp.dport, DHCP4_SERVER_PORT)
self.assertEqual(udp.sport, DHCP4_CLIENT_PORT)
self.assertEqual(udp.dport, DHCP4_SERVER_PORT)
self.assertEqual(udp.sport, DHCP4_CLIENT_PORT)
- def verify_orig_dhcp_discover(self, pkt, intf, hostname):
+ def verify_orig_dhcp_discover(self, pkt, intf, hostname, client_id=None):
self.verify_orig_dhcp_pkt(pkt, intf)
self.verify_dhcp_msg_type(pkt, "discover")
self.verify_dhcp_has_option(pkt, "hostname", hostname)
self.verify_orig_dhcp_pkt(pkt, intf)
self.verify_dhcp_msg_type(pkt, "discover")
self.verify_dhcp_has_option(pkt, "hostname", hostname)
+ if client_id:
+ self.verify_dhcp_has_option(pkt, "client_id", client_id)
def verify_orig_dhcp_request(self, pkt, intf, hostname, ip):
self.verify_orig_dhcp_pkt(pkt, intf)
def verify_orig_dhcp_request(self, pkt, intf, hostname, ip):
self.verify_orig_dhcp_pkt(pkt, intf)
self.pg_enable_capture(self.pg_interfaces)
self.pg_start()
self.pg_enable_capture(self.pg_interfaces)
self.pg_start()
+ #
+ # We'll get an ARP request for the router address
+ #
+ rx = self.pg2.get_capture(1)
+
+ self.assertEqual(rx[0][ARP].pdst, self.pg2.remote_ip4)
+ self.pg_enable_capture(self.pg_interfaces)
+
#
# At the end of this procedure there should be a connected route
# in the FIB
#
self.assertTrue(find_route(self, self.pg2.local_ip4, 32))
#
# At the end of this procedure there should be a connected route
# in the FIB
#
self.assertTrue(find_route(self, self.pg2.local_ip4, 32))
+ # remove the left over ARP entry
+ self.vapi.ip_neighbor_add_del(self.pg2.sw_if_index,
+ self.pg2.remote_mac,
+ self.pg2.remote_ip4,
+ is_add=0)
#
# remove the DHCP config
#
#
# remove the DHCP config
#
#
self.assertFalse(find_route(self, self.pg2.local_ip4, 32))
#
self.assertFalse(find_route(self, self.pg2.local_ip4, 32))
+ #
+ # Start the procedure again. this time have VPP send the clientiid
+ #
+ self.vapi.dhcp_client(self.pg2.sw_if_index, hostname,
+ client_id=self.pg2.local_mac)
+
+ rx = self.pg2.get_capture(1)
+
+ self.verify_orig_dhcp_discover(rx[0], self.pg2, hostname,
+ self.pg2.local_mac)
+
+ #
+ # remove the DHCP config
+ #
+ self.vapi.dhcp_client(self.pg2.sw_if_index, hostname, is_add=0)
if __name__ == '__main__':
unittest.main(testRunner=VppTestRunner)
if __name__ == '__main__':
unittest.main(testRunner=VppTestRunner)
def dhcp_client(self,
sw_if_index,
hostname,
def dhcp_client(self,
sw_if_index,
hostname,
is_add=1,
want_dhcp_events=0):
return self.api(
is_add=1,
want_dhcp_events=0):
return self.api(
{
'sw_if_index': sw_if_index,
'hostname': hostname,
{
'sw_if_index': sw_if_index,
'hostname': hostname,
+ 'client_id': client_id,
'is_add': is_add,
'want_dhcp_event': want_dhcp_events,
'pid': os.getpid(),
'is_add': is_add,
'want_dhcp_event': want_dhcp_events,
'pid': os.getpid(),