diff options
Diffstat (limited to 'src/vnet/ip')
-rw-r--r-- | src/vnet/ip/ip.api | 162 | ||||
-rw-r--r-- | src/vnet/ip/ip4_forward.c | 12 | ||||
-rw-r--r-- | src/vnet/ip/ip6.h | 8 | ||||
-rwxr-xr-x | src/vnet/ip/ip6_neighbor.c | 143 | ||||
-rw-r--r-- | src/vnet/ip/ip6_neighbor.h | 26 | ||||
-rw-r--r-- | src/vnet/ip/ip6_packet.h | 7 | ||||
-rw-r--r-- | src/vnet/ip/ip_api.c | 325 | ||||
-rw-r--r-- | src/vnet/ip/ip_neighbor.c | 39 | ||||
-rw-r--r-- | src/vnet/ip/ip_neighbor.h | 15 | ||||
-rw-r--r-- | src/vnet/ip/ip_types_api.c | 28 | ||||
-rw-r--r-- | src/vnet/ip/ip_types_api.h | 10 | ||||
-rw-r--r-- | src/vnet/ip/lookup.c | 1 | ||||
-rw-r--r-- | src/vnet/ip/rd_cp.c | 8 |
13 files changed, 418 insertions, 366 deletions
diff --git a/src/vnet/ip/ip.api b/src/vnet/ip/ip.api index 025fd577cf5..b67e2e5f0c8 100644 --- a/src/vnet/ip/ip.api +++ b/src/vnet/ip/ip.api @@ -20,7 +20,7 @@ called through a shared memory interface. */ -option version = "1.4.0"; +option version = "2.0.0"; import "vnet/ip/ip_types.api"; import "vnet/fib/fib_types.api"; import "vnet/ethernet/ethernet_types.api"; @@ -103,66 +103,47 @@ manual_endian manual_print define ip6_fib_details vl_api_fib_path_t path[count]; }; -/** \brief Dump IP neighboors - @param client_index - opaque cookie to identify the sender - @param context - sender context, to match reply w/ request - @param sw_if_index - the interface to dump neighboors, ~0 == all - @param is_ipv6 - [1|0] to indicate if address family is ipv[6|4] +/** \brief IP neighbor flags + @param is_static - A static neighbor Entry - there are not flushed + If the interface goes down. + @param is_no_fib_entry - Do not create a corresponding entry in the FIB + table for the neighbor. */ -define ip_neighbor_dump +enum ip_neighbor_flags { - u32 client_index; - u32 context; - u32 sw_if_index; - u8 is_ipv6; + IP_API_NEIGHBOR_FLAG_NONE = 0, + IP_API_NEIGHBOR_FLAG_STATIC = 0x1, + IP_API_NEIGHBOR_FLAG_NO_FIB_ENTRY = 0x2, + IP_API_NEIGHBOR_FLAG_FIX_ME_OLE = 0x3, }; -/** \brief IP neighboors dump response - @param context - sender context which was passed in the request - @param sw_if_index - The interface used to reach the neighbor - @param stats_index - An index in the stats segment that can be used to read - the counters for this neighbour. - @param is_static - [1|0] to indicate if neighbor is statically configured - @param is_ipv6 - [1|0] to indicate if address family is ipv[6|4] +/** \brief IP neighbor + @param sw_if_index - interface used to reach neighbor + @param mac_address - l2 address of the neighbor + @param ip_address - ip4 or ip6 address of the neighbor + @param flags - flags for the nieghbor */ -define ip_neighbor_details { - u32 context; - u32 sw_if_index; - u32 stats_index; - u8 is_static; - u8 is_ipv6; - u8 mac_address[6]; - u8 ip_address[16]; +typedef ip_neighbor { + u32 sw_if_index; + vl_api_ip_neighbor_flags_t flags; + vl_api_mac_address_t mac_address; + vl_api_address_t ip_address; }; /** \brief IP neighbor add / del request @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request - @param sw_if_index - interface used to reach neighbor @param is_add - 1 to add neighbor, 0 to delete - @param is_ipv6 - 1 for IPv6 neighbor, 0 for IPv4 - @param is_ipv6 - 1 for IPv6 neighbor, 0 for IPv4 - @param is_static - A static neighbor Entry - there are not flushed - If the interface goes down. - @param is_no_adj_fib - Do not create a corresponding entry in the FIB - table for the neighbor. - @param mac_address - l2 address of the neighbor - @param dst_address - ip4 or ip6 address of the neighbor + @param neighbor - the neighor to add/remove */ define ip_neighbor_add_del { u32 client_index; u32 context; - u32 sw_if_index; /* 1 = add, 0 = delete */ u8 is_add; - u8 is_ipv6; - u8 is_static; - u8 is_no_adj_fib; - u8 mac_address[6]; - u8 dst_address[16]; + vl_api_ip_neighbor_t neighbor; }; - define ip_neighbor_add_del_reply { u32 context; @@ -170,6 +151,29 @@ define ip_neighbor_add_del_reply u32 stats_index; }; +/** \brief Dump IP neighboors + @param client_index - opaque cookie to identify the sender + @param context - sender context, to match reply w/ request + @param sw_if_index - the interface to dump neighboors, ~0 == all + @param is_ipv6 - [1|0] to indicate if address family is ipv[6|4] +*/ +define ip_neighbor_dump +{ + u32 client_index; + u32 context; + u32 sw_if_index; + u8 is_ipv6; +}; + +/** \brief IP neighboors dump response + @param context - sender context which was passed in the request + @param neighbour - the neighbor +*/ +define ip_neighbor_details { + u32 context; + vl_api_ip_neighbor_t neighbor; +}; + /** \brief Set the ip flow hash config for a fib request @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -239,8 +243,7 @@ autoreply define sw_interface_ip6nd_ra_config @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @param sw_if_index - The interface the RA prefix information is for - @param address[] - The prefix to advertise - @param address_length - the prefix length + @param prefix - The prefix to advertise @param use_default - Revert to default settings @param no_advertise - Do not advertise this prefix @param off_link - The prefix is off link (it is not configured on the interface) @@ -269,8 +272,7 @@ autoreply define sw_interface_ip6nd_ra_prefix u32 client_index; u32 context; u32 sw_if_index; - u8 address[16]; - u8 address_length; + vl_api_prefix_t prefix; u8 use_default; u8 no_advertise; u8 off_link; @@ -294,7 +296,7 @@ autoreply define ip6nd_proxy_add_del u32 context; u32 sw_if_index; u8 is_del; - u8 address[16]; + vl_api_ip6_address_t ip; }; /** \brief IPv6 ND proxy details returned after request @@ -305,7 +307,7 @@ define ip6nd_proxy_details { u32 context; u32 sw_if_index; - u8 address[16]; + vl_api_ip6_address_t ip; }; /** \brief IPv6 ND proxy dump request @@ -683,9 +685,7 @@ autoreply define ip_container_proxy_add_del { u32 client_index; u32 context; - u8 ip[16]; - u8 is_ip4; - u8 plen; + vl_api_prefix_t pfx; u32 sw_if_index; u8 is_add; }; @@ -708,8 +708,7 @@ define ip_container_proxy_details @param context - sender context, to match reply w/ request @param is_ip6 - 1 if source address type is IPv6 @param is_add - 1 if add, 0 if delete - @param mask_length - mask length for address entry - @param address - array of address bytes + @param ip - prefix to match @param number_of_ranges - length of low_port and high_port arrays (must match) @param low_ports[32] - up to 32 low end of port range entries (must have corresponding high_ports entry) @param high_ports[32] - up to 32 high end of port range entries (must have corresponding low_ports entry) @@ -720,10 +719,8 @@ autoreply define ip_source_and_port_range_check_add_del { u32 client_index; u32 context; - u8 is_ipv6; u8 is_add; - u8 mask_length; - u8 address[16]; + vl_api_prefix_t prefix; u8 number_of_ranges; u16 low_ports[32]; u16 high_ports[32]; @@ -794,16 +791,14 @@ autoreply define ip_scan_neighbor_enable_disable @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @param sw_if_index - interface index - @param dst_address - target IP address to send IP addr resolution request - @param is_ipv6 - [1|0] to indicate if address family is IPv[6|4] + @param dst - target IP address to send IP addr resolution request */ autoreply define ip_probe_neighbor { u32 client_index; u32 context; u32 sw_if_index; - u8 dst_address[16]; - u8 is_ipv6; + vl_api_address_t dst; }; /** \brief Register for IP4 ARP resolution event on receing ARP reply or @@ -812,8 +807,8 @@ autoreply define ip_probe_neighbor @param context - sender context, to match reply w/ request @param enable_disable - 1 => register for events, 0 => cancel registration @param pid - sender's pid - @param address - exact IP4 address of interested arp resolution event, or - 0 to get MAC/IP info from ARP requests in BDs + @param ip - exact IP4 address of interested arp resolution event, or + 0 to get MAC/IP info from ARP requests in BDs */ autoreply define want_ip4_arp_events { @@ -821,25 +816,25 @@ autoreply define want_ip4_arp_events u32 context; u8 enable_disable; u32 pid; - u32 address; + vl_api_ip4_address_t ip; }; /** \brief Tell client about an IP4 ARP resolution event or MAC/IP info from ARP requests in L2 BDs @param client_index - opaque cookie to identify the sender - @param address - the exact ip4 address of interest + @param ip - the exact ip4 address of interest @param pid - client pid registered to receive notification @param sw_if_index - interface which received ARP packet - @param new_mac - the new mac address + @param mac - the new mac address @param mac_ip - 0: ARP resolution event, 1: MAC/IP info from L2 BDs */ define ip4_arp_event { u32 client_index; - u32 address; + vl_api_ip4_address_t ip; u32 pid; u32 sw_if_index; - u8 new_mac[6]; + vl_api_mac_address_t mac; u8 mac_ip; }; @@ -854,8 +849,8 @@ service { @param context - sender context, to match reply w/ request @param enable_disable - 1 => register for events, 0 => cancel registration @param pid - sender's pid - @param address - the exact IP6 address of interested ND resolution event, or - 0 to get MAC/IP info from ICMP6 NS in L2 BDs. + @param ip - the exact IP6 address of interested ND resolution event, or + 0 to get MAC/IP info from ICMP6 NS in L2 BDs. */ autoreply define want_ip6_nd_events { @@ -863,7 +858,7 @@ autoreply define want_ip6_nd_events u32 context; u8 enable_disable; u32 pid; - u8 address[16]; + vl_api_ip6_address_t ip; }; /** \brief Tell client about an IP6 ND resolution or @@ -871,7 +866,7 @@ autoreply define want_ip6_nd_events @param client_index - opaque cookie to identify the sender @param pid - client pid registered to receive notification @param sw_if_index - interface which received ARP packet - @param address - the exact ip6 address of interest + @param ip - the exact ip6 address of interest @param new_mac - the new mac address @param mac_ip - 0: ND resolution event, 1: MAC/IP info from L2 BDs */ @@ -880,8 +875,8 @@ define ip6_nd_event u32 client_index; u32 pid; u32 sw_if_index; - u8 address[16]; - u8 new_mac[6]; + vl_api_ip6_address_t ip; + vl_api_mac_address_t mac; u8 mac_ip; }; @@ -905,16 +900,14 @@ autoreply define want_ip6_ra_events }; /** \brief Struct representing RA prefix info - @param dst_address - RA prefix info destination address - @param dst_address_length - RA prefix info destination address length + @param prefix - RA prefix info destination address @param flags - RA prefix info flags @param valid_time - RA prefix info valid time @param preferred_time - RA prefix info preferred time */ typeonly define ip6_ra_prefix_info { - u8 dst_address[16]; - u8 dst_address_length; + vl_api_prefix_t prefix; u8 flags; u32 valid_time; u32 preferred_time; @@ -926,6 +919,7 @@ typeonly define ip6_ra_prefix_info @param current_hop_limit - RA current hop limit @param flags - RA flags @param router_lifetime_in_sec - RA lifetime in seconds + @param router_addr - The router's address @param neighbor_reachable_time_in_msec - RA neighbor reachable time in msec @param time_in_msec_between_retransmitted_neighbor_solicitations - time in msec between retransmitted neighbor solicitations @@ -937,7 +931,7 @@ define ip6_ra_event u32 client_index; u32 pid; u32 sw_if_index; - u8 router_address[16]; + vl_api_ip6_address_t router_addr; u8 current_hop_limit; u8 flags; u16 router_lifetime_in_sec; @@ -953,15 +947,15 @@ service { }; /** \brief Proxy ARP configuration type - @param vrf_id - VRF / Fib table ID - @param low_address[4] - Low address of the Proxy ARP range - @param hi_address[4] - High address of the Proxy ARP range + @param table_id - VRF / Fib table ID + @param low - Low address of the Proxy ARP range + @param hi - High address of the Proxy ARP range */ typeonly define proxy_arp { - u32 vrf_id; - u8 low_address[4]; - u8 hi_address[4]; + u32 table_id; + vl_api_ip4_address_t low; + vl_api_ip4_address_t hi; }; /** \brief Proxy ARP add / del request diff --git a/src/vnet/ip/ip4_forward.c b/src/vnet/ip/ip4_forward.c index 1a1b7e5182b..5fc2552f5ca 100644 --- a/src/vnet/ip/ip4_forward.c +++ b/src/vnet/ip/ip4_forward.c @@ -948,10 +948,6 @@ ip4_lookup_init (vlib_main_t * vm) clib_memset (&h, 0, sizeof (h)); - /* Set target ethernet address to all zeros. */ - clib_memset (h.ip4_over_ethernet[1].ethernet, 0, - sizeof (h.ip4_over_ethernet[1].ethernet)); - #define _16(f,v) h.f = clib_host_to_net_u16 (v); #define _8(f,v) h.f = v; _16 (l2_type, ETHERNET_ARP_HARDWARE_TYPE_ethernet); @@ -1872,9 +1868,8 @@ ip4_arp_inline (vlib_main_t * vm, hw_if0 = vnet_get_sup_hw_interface (vnm, sw_if_index0); /* Src ethernet address in ARP header. */ - clib_memcpy_fast (h0->ip4_over_ethernet[0].ethernet, - hw_if0->hw_address, - sizeof (h0->ip4_over_ethernet[0].ethernet)); + mac_address_from_bytes (&h0->ip4_over_ethernet[0].mac, + hw_if0->hw_address); if (is_glean) { /* The interface's source address is stashed in the Glean Adj */ @@ -2046,8 +2041,7 @@ ip4_probe_neighbor (vlib_main_t * vm, ip4_address_t * dst, u32 sw_if_index, sw_if_index); } - clib_memcpy_fast (h->ip4_over_ethernet[0].ethernet, hi->hw_address, - sizeof (h->ip4_over_ethernet[0].ethernet)); + mac_address_from_bytes (&h->ip4_over_ethernet[0].mac, hi->hw_address); h->ip4_over_ethernet[0].ip4 = src[0]; h->ip4_over_ethernet[1].ip4 = dst[0]; diff --git a/src/vnet/ip/ip6.h b/src/vnet/ip/ip6.h index ab17f662198..f16cda9b8ad 100644 --- a/src/vnet/ip/ip6.h +++ b/src/vnet/ip/ip6.h @@ -42,6 +42,7 @@ #include <vlib/buffer.h> #include <vnet/ethernet/packet.h> +#include <vnet/ethernet/mac_address.h> #include <vnet/ip/ip6_packet.h> #include <vnet/ip/ip6_hop_by_hop_packet.h> #include <vnet/ip/lookup.h> @@ -415,8 +416,13 @@ clib_error_t *set_ip6_link_local_address (vlib_main_t * vm, u32 sw_if_index, ip6_address_t * address); +typedef int (*ip6_nd_change_event_cb_t) (u32 pool_index, + const mac_address_t * new_mac, + u32 sw_if_index, + const ip6_address_t * address); + int vnet_add_del_ip6_nd_change_event (vnet_main_t * vnm, - void *data_callback, + ip6_nd_change_event_cb_t data_callback, u32 pid, void *address_arg, uword node_index, diff --git a/src/vnet/ip/ip6_neighbor.c b/src/vnet/ip/ip6_neighbor.c index b4b6888a934..ded5b868702 100755 --- a/src/vnet/ip/ip6_neighbor.c +++ b/src/vnet/ip/ip6_neighbor.c @@ -26,6 +26,7 @@ #include <vnet/mfib/ip6_mfib.h> #include <vnet/ip/ip6_ll_table.h> #include <vnet/l2/l2_input.h> +#include <vlibmemory/api.h> /** * @file @@ -173,7 +174,7 @@ typedef struct uword type_opaque; uword data; /* Used for nd event notification only */ - void *data_callback; + ip6_nd_change_event_cb_t data_callback; u32 pid; } pending_resolution_t; @@ -266,15 +267,15 @@ ip6_neighbor_get_link_local_address (u32 sw_if_index) * @param sw_if_index The interface on which the ARP entires are acted */ static int -vnet_nd_wc_publish (u32 sw_if_index, u8 * mac, ip6_address_t * ip6) +vnet_nd_wc_publish (u32 sw_if_index, + const mac_address_t * mac, const ip6_address_t * ip6) { wc_nd_report_t r = { .sw_if_index = sw_if_index, .ip6 = *ip6, + .mac = *mac, }; - memcpy (r.mac, mac, sizeof r.mac); - void vl_api_rpc_call_main_thread (void *fp, u8 * data, u32 data_length); vl_api_rpc_call_main_thread (wc_nd_signal_report, (u8 *) & r, sizeof r); return 0; } @@ -347,13 +348,13 @@ format_ip6_neighbor_ip6_entry (u8 * s, va_list * va) return format (s, "%=12s%=45s%=6s%=20s%=40s", "Time", "Address", "Flags", "Link layer", "Interface"); - if (n->flags & IP6_NEIGHBOR_FLAG_DYNAMIC) + if (n->flags & IP_NEIGHBOR_FLAG_DYNAMIC) flags = format (flags, "D"); - if (n->flags & IP6_NEIGHBOR_FLAG_STATIC) + if (n->flags & IP_NEIGHBOR_FLAG_STATIC) flags = format (flags, "S"); - if (n->flags & IP6_NEIGHBOR_FLAG_NO_FIB_ENTRY) + if (n->flags & IP_NEIGHBOR_FLAG_NO_FIB_ENTRY) flags = format (flags, "N"); si = vnet_get_sw_interface (vnm, n->key.sw_if_index); @@ -361,7 +362,7 @@ format_ip6_neighbor_ip6_entry (u8 * s, va_list * va) format_vlib_time, vm, n->time_last_updated, format_ip6_address, &n->key.ip6_address, flags ? (char *) flags : "", - format_ethernet_address, n->link_layer_address, + format_mac_address_t, &n->mac, format_vnet_sw_interface_name, vnm, si); vec_free (flags); @@ -402,9 +403,8 @@ ip6_neighbor_adj_fib_remove (ip6_neighbor_t * n, u32 fib_index) typedef struct { u8 is_add; - u8 is_static; - u8 is_no_fib_entry; - u8 link_layer_address[6]; + ip_neighbor_flags_t flags; + mac_address_t mac; u32 sw_if_index; ip6_address_t addr; } ip6_neighbor_set_unset_rpc_args_t; @@ -416,19 +416,16 @@ static void set_unset_ip6_neighbor_rpc (vlib_main_t * vm, u32 sw_if_index, const ip6_address_t * a, - const u8 * link_layer_address, - int is_add, int is_static, int is_no_fib_entry) + const mac_address_t * mac, int is_add, ip_neighbor_flags_t flags) { ip6_neighbor_set_unset_rpc_args_t args; void vl_api_rpc_call_main_thread (void *fp, u8 * data, u32 data_length); args.sw_if_index = sw_if_index; args.is_add = is_add; - args.is_static = is_static; - args.is_no_fib_entry = is_no_fib_entry; - clib_memcpy (&args.addr, a, sizeof (*a)); - if (NULL != link_layer_address) - clib_memcpy (args.link_layer_address, link_layer_address, 6); + args.flags = flags; + ip6_address_copy (&args.addr, a); + mac_address_copy (&args.mac, mac); vl_api_rpc_call_main_thread (ip6_neighbor_set_unset_rpc_callback, (u8 *) & args, sizeof (args)); @@ -511,7 +508,7 @@ ip6_nd_mk_complete (adj_index_t ai, ip6_neighbor_t * nbr) ethernet_build_rewrite (vnet_get_main (), nbr->key.sw_if_index, adj_get_link_type (ai), - nbr->link_layer_address)); + nbr->mac.bytes)); } static void @@ -604,7 +601,7 @@ ip6_neighbor_sw_interface_up_down (vnet_main_t * vnm, n = pool_elt_at_index (nm->neighbor_pool, to_delete[i]); adj_nbr_walk_nh6 (n->key.sw_if_index, &n->key.ip6_address, ip6_nd_mk_incomplete_walk, NULL); - if (n->flags & IP6_NEIGHBOR_FLAG_STATIC) + if (n->flags & IP_NEIGHBOR_FLAG_STATIC) continue; ip6_neighbor_adj_fib_remove (n, ip6_fib_table_get_index_for_sw_if_index @@ -759,7 +756,7 @@ force_reuse_neighbor_entry (void) nm->neighbor_delete_rotor = index; index = pool_next_index (nm->neighbor_pool, index); } - while (n->flags & IP6_NEIGHBOR_FLAG_STATIC); + while (n->flags & IP_NEIGHBOR_FLAG_STATIC); /* Remove ARP entry from its interface and update fib */ adj_nbr_walk_nh6 (n->key.sw_if_index, @@ -775,9 +772,8 @@ int vnet_set_ip6_ethernet_neighbor (vlib_main_t * vm, u32 sw_if_index, const ip6_address_t * a, - const u8 * link_layer_address, - uword n_bytes_link_layer_address, - int is_static, int is_no_fib_entry) + const mac_address_t * mac, + ip_neighbor_flags_t flags) { ip6_neighbor_main_t *nm = &ip6_neighbor_main; ip6_neighbor_key_t k; @@ -789,9 +785,7 @@ vnet_set_ip6_ethernet_neighbor (vlib_main_t * vm, if (vlib_get_thread_index ()) { - set_unset_ip6_neighbor_rpc (vm, sw_if_index, a, link_layer_address, - 1 /* set new neighbor */ , is_static, - is_no_fib_entry); + set_unset_ip6_neighbor_rpc (vm, sw_if_index, a, mac, 1, flags); return 0; } @@ -804,11 +798,11 @@ vnet_set_ip6_ethernet_neighbor (vlib_main_t * vm, { n = pool_elt_at_index (nm->neighbor_pool, p[0]); /* Refuse to over-write static neighbor entry. */ - if (!is_static && (n->flags & IP6_NEIGHBOR_FLAG_STATIC)) + if (!(flags & IP_NEIGHBOR_FLAG_STATIC) && + (n->flags & IP_NEIGHBOR_FLAG_STATIC)) { /* if MAC address match, still check to send event */ - if (0 == memcmp (n->link_layer_address, - link_layer_address, n_bytes_link_layer_address)) + if (0 == mac_address_cmp (&n->mac, mac)) goto check_customers; return -2; } @@ -832,20 +826,19 @@ vnet_set_ip6_ethernet_neighbor (vlib_main_t * vm, n->key = k; n->fib_entry_index = FIB_NODE_INDEX_INVALID; - clib_memcpy (n->link_layer_address, - link_layer_address, n_bytes_link_layer_address); + mac_address_copy (&n->mac, mac); /* * create the adj-fib. the entry in the FIB table for and to the peer. */ - if (!is_no_fib_entry) + if (!(flags & IP_NEIGHBOR_FLAG_NO_FIB_ENTRY)) { ip6_neighbor_adj_fib_add (n, ip6_fib_table_get_index_for_sw_if_index (n->key.sw_if_index)); } else { - n->flags |= IP6_NEIGHBOR_FLAG_NO_FIB_ENTRY; + n->flags |= IP_NEIGHBOR_FLAG_NO_FIB_ENTRY; } } else @@ -854,28 +847,26 @@ vnet_set_ip6_ethernet_neighbor (vlib_main_t * vm, * prevent a DoS attack from the data-plane that * spams us with no-op updates to the MAC address */ - if (0 == memcmp (n->link_layer_address, - link_layer_address, n_bytes_link_layer_address)) + if (0 == mac_address_cmp (&n->mac, mac)) { n->time_last_updated = vlib_time_now (vm); goto check_customers; } - clib_memcpy (n->link_layer_address, - link_layer_address, n_bytes_link_layer_address); + mac_address_copy (&n->mac, mac); } /* Update time stamp and flags. */ n->time_last_updated = vlib_time_now (vm); - if (is_static) + if (flags & IP_NEIGHBOR_FLAG_STATIC) { - n->flags |= IP6_NEIGHBOR_FLAG_STATIC; - n->flags &= ~IP6_NEIGHBOR_FLAG_DYNAMIC; + n->flags |= IP_NEIGHBOR_FLAG_STATIC; + n->flags &= ~IP_NEIGHBOR_FLAG_DYNAMIC; } else { - n->flags |= IP6_NEIGHBOR_FLAG_DYNAMIC; - n->flags &= ~IP6_NEIGHBOR_FLAG_STATIC; + n->flags |= IP_NEIGHBOR_FLAG_DYNAMIC; + n->flags &= ~IP_NEIGHBOR_FLAG_STATIC; } adj_nbr_walk_nh6 (sw_if_index, @@ -908,16 +899,13 @@ check_customers: while (next_index != (u32) ~ 0) { - int (*fp) (u32, u8 *, u32, ip6_address_t *); int rv = 1; + mc = pool_elt_at_index (nm->mac_changes, next_index); - fp = mc->data_callback; /* Call the user's data callback, return 1 to suppress dup events */ - if (fp) - rv = - (*fp) (mc->data, (u8 *) link_layer_address, sw_if_index, - &ip6a_zero); + if (mc->data_callback) + rv = (mc->data_callback) (mc->data, mac, sw_if_index, &ip6a_zero); /* * Signal the resolver process, as long as the user * says they want to be notified @@ -944,8 +932,8 @@ vnet_unset_ip6_ethernet_neighbor (vlib_main_t * vm, if (vlib_get_thread_index ()) { - set_unset_ip6_neighbor_rpc (vm, sw_if_index, a, NULL, - 0 /* unset */ , 0, 0); + set_unset_ip6_neighbor_rpc (vm, sw_if_index, a, NULL, 0, + IP_NEIGHBOR_FLAG_NONE); return 0; } @@ -980,8 +968,7 @@ static void ip6_neighbor_set_unset_rpc_callback vlib_main_t *vm = vlib_get_main (); if (a->is_add) vnet_set_ip6_ethernet_neighbor (vm, a->sw_if_index, &a->addr, - a->link_layer_address, 6, a->is_static, - a->is_no_fib_entry); + &a->mac, a->flags); else vnet_unset_ip6_ethernet_neighbor (vm, a->sw_if_index, &a->addr); } @@ -1010,7 +997,7 @@ ip6_neighbor_t * ip6_neighbors_entries (u32 sw_if_index) { ip6_neighbor_main_t *nm = &ip6_neighbor_main; - ip6_neighbor_t *n, *ns = 0; + ip6_neighbor_t *n, *ns = NULL; /* *INDENT-OFF* */ pool_foreach (n, nm->neighbor_pool, @@ -1085,13 +1072,12 @@ static clib_error_t * set_ip6_neighbor (vlib_main_t * vm, unformat_input_t * input, vlib_cli_command_t * cmd) { + ip_neighbor_flags_t flags = IP_NEIGHBOR_FLAG_NONE; vnet_main_t *vnm = vnet_get_main (); ip6_address_t addr; - u8 mac_address[6]; + mac_address_t mac; int addr_valid = 0; int is_del = 0; - int is_static = 0; - int is_no_fib_entry = 0; u32 sw_if_index; while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) @@ -1100,15 +1086,15 @@ set_ip6_neighbor (vlib_main_t * vm, if (unformat (input, "%U %U %U", unformat_vnet_sw_interface, vnm, &sw_if_index, unformat_ip6_address, &addr, - unformat_ethernet_address, mac_address)) + unformat_mac_address_t, &mac)) addr_valid = 1; else if (unformat (input, "delete") || unformat (input, "del")) is_del = 1; else if (unformat (input, "static")) - is_static = 1; + flags |= IP_NEIGHBOR_FLAG_STATIC; else if (unformat (input, "no-fib-entry")) - is_no_fib_entry = 1; + flags |= IP_NEIGHBOR_FLAG_NO_FIB_ENTRY; else break; } @@ -1117,9 +1103,7 @@ set_ip6_neighbor (vlib_main_t * vm, return clib_error_return (0, "Missing interface, ip6 or hw address"); if (!is_del) - vnet_set_ip6_ethernet_neighbor (vm, sw_if_index, &addr, - mac_address, sizeof (mac_address), - is_static, is_no_fib_entry); + vnet_set_ip6_ethernet_neighbor (vm, sw_if_index, &addr, &mac, flags); else vnet_unset_ip6_ethernet_neighbor (vm, sw_if_index, &addr); return 0; @@ -1258,9 +1242,9 @@ icmp6_neighbor_solicitation_or_advertisement (vlib_main_t * vm, is_solicitation ? &ip0->src_address : &h0->target_address, + (mac_address_t *) o0->ethernet_address, - sizeof (o0->ethernet_address), - 0, 0); + IP_NEIGHBOR_FLAG_NONE); } if (is_solicitation && error0 == ICMP6_ERROR_NONE) @@ -1591,11 +1575,11 @@ icmp6_router_solicitation (vlib_main_t * vm, if (PREDICT_TRUE (error0 == ICMP6_ERROR_NONE && o0 != 0 && !is_unspecified && !is_link_local)) { - vnet_set_ip6_ethernet_neighbor (vm, sw_if_index0, - &ip0->src_address, - o0->ethernet_address, - sizeof (o0->ethernet_address), - 0, 0); + vnet_set_ip6_ethernet_neighbor + (vm, sw_if_index0, + &ip0->src_address, + (mac_address_t *) o0->ethernet_address, + IP_NEIGHBOR_FLAG_NONE); } /* default is to drop */ @@ -2013,7 +1997,7 @@ icmp6_router_advertisement (vlib_main_t * vm, ra_report_t r; r.sw_if_index = sw_if_index0; - memcpy (r.router_address, &ip0->src_address, 16); + memcpy (&r.router_address, &ip0->src_address, 16); r.current_hop_limit = h0->current_hop_limit; r.flags = h0->flags; r.router_lifetime_in_sec = @@ -2208,9 +2192,9 @@ icmp6_router_advertisement (vlib_main_t * vm, prefix->preferred_time = preferred; prefix->valid_time = valid; prefix->flags = h->flags & 0xc0; - prefix->dst_address_length = - h->dst_address_length; - prefix->dst_address = h->dst_address; + prefix->prefix.fp_len = h->dst_address_length; + prefix->prefix.fp_addr.ip6 = h->dst_address; + prefix->prefix.fp_proto = FIB_PROTOCOL_IP6; /* look for matching prefix - if we our advertising it, it better be consistant */ /* *INDENT-OFF* */ @@ -4686,7 +4670,7 @@ vnet_register_ip6_neighbor_resolution_event (vnet_main_t * vnm, int vnet_add_del_ip6_nd_change_event (vnet_main_t * vnm, - void *data_callback, + ip6_nd_change_event_cb_t data_callback, u32 pid, void *address_arg, uword node_index, @@ -4740,9 +4724,8 @@ vnet_add_del_ip6_nd_change_event (vnet_main_t * vnm, return VNET_API_ERROR_NO_SUCH_ENTRY; /* Clients may need to clean up pool entries, too */ - void (*fp) (u32, u8 *) = data_callback; - if (fp) - (*fp) (mc->data, 0 /* no new mac addrs */ ); + if (data_callback) + (data_callback) (mc->data, NULL /* no new mac addrs */ , 0, NULL); /* Remove the entry from the list and delete the entry */ *p = mc->next_index; @@ -4764,7 +4747,9 @@ vnet_ip6_nd_term (vlib_main_t * vm, { ip6_neighbor_main_t *nm = &ip6_neighbor_main; icmp6_neighbor_solicitation_or_advertisement_header_t *ndh; + mac_address_t mac; + mac_address_from_bytes (&mac, eth->src_address); ndh = ip6_next_header (ip); if (ndh->icmp.type != ICMP6_neighbor_solicitation && ndh->icmp.type != ICMP6_neighbor_advertisement) @@ -4783,7 +4768,7 @@ vnet_ip6_nd_term (vlib_main_t * vm, (nm->wc_ip6_nd_publisher_node != (uword) ~ 0 && !ip6_address_is_link_local_unicast (&ip->src_address))) { - vnet_nd_wc_publish (sw_if_index, eth->src_address, &ip->src_address); + vnet_nd_wc_publish (sw_if_index, &mac, &ip->src_address); } /* Check if MAC entry exsist for solicited target IP */ diff --git a/src/vnet/ip/ip6_neighbor.h b/src/vnet/ip/ip6_neighbor.h index e273a10799f..0707a2a8d21 100644 --- a/src/vnet/ip/ip6_neighbor.h +++ b/src/vnet/ip/ip6_neighbor.h @@ -20,6 +20,8 @@ #define included_ip6_neighbor_h #include <vnet/fib/fib_types.h> +#include <vnet/ethernet/mac_address.h> +#include <vnet/ip/ip_neighbor.h> typedef struct { @@ -28,18 +30,11 @@ typedef struct u32 pad; } ip6_neighbor_key_t; -typedef enum ip6_neighbor_flags_t_ -{ - IP6_NEIGHBOR_FLAG_STATIC = (1 << 0), - IP6_NEIGHBOR_FLAG_DYNAMIC = (1 << 1), - IP6_NEIGHBOR_FLAG_NO_FIB_ENTRY = (1 << 2), -} __attribute__ ((packed)) ip6_neighbor_flags_t; - typedef struct { ip6_neighbor_key_t key; - u8 link_layer_address[8]; - ip6_neighbor_flags_t flags; + mac_address_t mac; + ip_neighbor_flags_t flags; f64 time_last_updated; fib_node_index_t fib_entry_index; } ip6_neighbor_t; @@ -81,10 +76,8 @@ extern void vnet_register_ip6_neighbor_resolution_event (vnet_main_t * vnm, extern int vnet_set_ip6_ethernet_neighbor (vlib_main_t * vm, u32 sw_if_index, const ip6_address_t * a, - const u8 * link_layer_address, - uword n_bytes_link_layer_address, - int is_static, - int is_no_fib_entry); + const mac_address_t * mac, + ip_neighbor_flags_t flags); extern int vnet_unset_ip6_ethernet_neighbor (vlib_main_t * vm, u32 sw_if_index, @@ -99,7 +92,7 @@ typedef struct { u32 sw_if_index; ip6_address_t ip6; - u8 mac[6]; + mac_address_t mac; } wc_nd_report_t; void wc_nd_set_publisher_node (uword node_index, uword event_type); @@ -119,8 +112,7 @@ void icmp6_send_router_solicitation (vlib_main_t * vm, u32 sw_if_index, typedef struct { - ip6_address_t dst_address; - u8 dst_address_length; + fib_prefix_t prefix; u8 flags; u32 valid_time; u32 preferred_time; @@ -129,7 +121,7 @@ typedef struct typedef struct { u32 sw_if_index; - u8 router_address[16]; + ip6_address_t router_address; u8 current_hop_limit; u8 flags; u16 router_lifetime_in_sec; diff --git a/src/vnet/ip/ip6_packet.h b/src/vnet/ip/ip6_packet.h index 015dd01f8aa..5d33cc77925 100644 --- a/src/vnet/ip/ip6_packet.h +++ b/src/vnet/ip/ip6_packet.h @@ -182,6 +182,13 @@ ip46_address_is_multicast (const ip46_address_t * a) } always_inline void +ip6_address_copy (ip6_address_t * dst, const ip6_address_t * src) +{ + dst->as_u64[0] = src->as_u64[0]; + dst->as_u64[1] = src->as_u64[1]; +} + +always_inline void ip6_set_reserved_multicast_address (ip6_address_t * a, ip6_multicast_address_scope_t scope, u16 id) diff --git a/src/vnet/ip/ip_api.c b/src/vnet/ip/ip_api.c index b9fa001553f..749cb889be9 100644 --- a/src/vnet/ip/ip_api.c +++ b/src/vnet/ip/ip_api.c @@ -23,8 +23,10 @@ #include <vnet/interface.h> #include <vnet/api_errno.h> #include <vnet/ethernet/ethernet.h> +#include <vnet/ethernet/ethernet_types_api.h> #include <vnet/ip/ip.h> #include <vnet/ip/ip_neighbor.h> +#include <vnet/ip/ip_types_api.h> #include <vnet/ip/ip6_neighbor.h> #include <vnet/ip/ip_punt_drop.h> #include <vnet/fib/fib_table.h> @@ -120,13 +122,25 @@ _(IP_PUNT_REDIRECT_DUMP, ip_punt_redirect_dump) extern void stats_dslock_with_hint (int hint, int tag); extern void stats_dsunlock (void); +static vl_api_ip_neighbor_flags_t +ip_neighbor_flags_encode (ip_neighbor_flags_t f) +{ + vl_api_ip_neighbor_flags_t v = IP_API_NEIGHBOR_FLAG_NONE; + + if (f & IP_NEIGHBOR_FLAG_STATIC) + v |= IP_API_NEIGHBOR_FLAG_STATIC; + if (f & IP_NEIGHBOR_FLAG_NO_FIB_ENTRY) + v |= IP_API_NEIGHBOR_FLAG_NO_FIB_ENTRY; + + return (clib_host_to_net_u32 (v)); +} + static void send_ip_neighbor_details (u32 sw_if_index, - u8 is_ipv6, - u8 is_static, - u8 * mac_address, - u8 * ip_address, vl_api_registration_t * reg, - u32 context) + const ip46_address_t * ip_address, + const mac_address_t * mac, + ip_neighbor_flags_t flags, + vl_api_registration_t * reg, u32 context) { vl_api_ip_neighbor_details_t *mp; @@ -134,11 +148,11 @@ send_ip_neighbor_details (u32 sw_if_index, clib_memset (mp, 0, sizeof (*mp)); mp->_vl_msg_id = ntohs (VL_API_IP_NEIGHBOR_DETAILS); mp->context = context; - mp->sw_if_index = htonl (sw_if_index); - mp->is_ipv6 = is_ipv6; - mp->is_static = is_static; - memcpy (mp->mac_address, mac_address, 6); - memcpy (mp->ip_address, ip_address, (is_ipv6) ? 16 : 4); + mp->neighbor.sw_if_index = htonl (sw_if_index); + mp->neighbor.flags = ip_neighbor_flags_encode (flags); + + ip_address_encode (ip_address, IP46_TYPE_ANY, &mp->neighbor.ip_address); + mac_address_encode (mac, mp->neighbor.mac_address); vl_api_send_msg (reg, (u8 *) mp); } @@ -162,12 +176,15 @@ vl_api_ip_neighbor_dump_t_handler (vl_api_ip_neighbor_dump_t * mp) /* *INDENT-OFF* */ vec_foreach (n, ns) { - send_ip_neighbor_details - (n->key.sw_if_index, mp->is_ipv6, - ((n->flags & IP6_NEIGHBOR_FLAG_STATIC) ? 1 : 0), - (u8 *) n->link_layer_address, - (u8 *) & (n->key.ip6_address.as_u8), - reg, mp->context); + ip46_address_t nh = { + .ip6 = { + .as_u64[0] = n->key.ip6_address.as_u64[0], + .as_u64[1] = n->key.ip6_address.as_u64[1], + }, + }; + send_ip_neighbor_details (n->key.sw_if_index, &nh, + &n->mac, n->flags, + reg, mp->context); } /* *INDENT-ON* */ vec_free (ns); @@ -180,11 +197,15 @@ vl_api_ip_neighbor_dump_t_handler (vl_api_ip_neighbor_dump_t * mp) /* *INDENT-OFF* */ vec_foreach (n, ns) { - send_ip_neighbor_details (n->sw_if_index, mp->is_ipv6, - ((n->flags & ETHERNET_ARP_IP4_ENTRY_FLAG_STATIC) ? 1 : 0), - (u8*) n->ethernet_address, - (u8*) & (n->ip4_address.as_u8), - reg, mp->context); + ip46_address_t nh = { + .ip4 = { + .as_u32 = n->ip4_address.as_u32, + }, + }; + + send_ip_neighbor_details (n->sw_if_index, &nh, + &n->mac, n->flags, + reg, mp->context); } /* *INDENT-ON* */ vec_free (ns); @@ -654,36 +675,52 @@ vl_api_ip_punt_redirect_t_handler (vl_api_ip_punt_redirect_t * mp, REPLY_MACRO (VL_API_IP_PUNT_REDIRECT_REPLY); } +static ip_neighbor_flags_t +ip_neighbor_flags_decode (vl_api_ip_neighbor_flags_t v) +{ + ip_neighbor_flags_t f = IP_NEIGHBOR_FLAG_NONE; + + v = clib_net_to_host_u32 (v); + + if (v & IP_API_NEIGHBOR_FLAG_STATIC) + f |= IP_NEIGHBOR_FLAG_STATIC; + if (v & IP_API_NEIGHBOR_FLAG_NO_FIB_ENTRY) + f |= IP_NEIGHBOR_FLAG_NO_FIB_ENTRY; + + return (f); +} + static void vl_api_ip_neighbor_add_del_t_handler (vl_api_ip_neighbor_add_del_t * mp, vlib_main_t * vm) { - ip46_address_t ip = ip46_address_initializer; vl_api_ip_neighbor_add_del_reply_t *rmp; ip_neighbor_flags_t flags; u32 stats_index = ~0; + ip46_address_t ip; + mac_address_t mac; + ip46_type_t type; int rv = 0; - VALIDATE_SW_IF_INDEX (mp); + VALIDATE_SW_IF_INDEX ((&mp->neighbor)); stats_dslock_with_hint (1 /* release hint */ , 7 /* tag */ ); - flags = IP_NEIGHBOR_FLAG_NODE; - if (mp->is_static) - flags |= IP_NEIGHBOR_FLAG_STATIC; - if (mp->is_no_adj_fib) - flags |= IP_NEIGHBOR_FLAG_NO_ADJ_FIB; - - if (mp->is_ipv6) - clib_memcpy (&ip.ip6, mp->dst_address, 16); - else - clib_memcpy (&ip.ip4, mp->dst_address, 4); + flags = ip_neighbor_flags_decode (mp->neighbor.flags); + type = ip_address_decode (&mp->neighbor.ip_address, &ip); + mac_address_decode (mp->neighbor.mac_address, &mac); + /* + * there's no validation here of the ND/ARP entry being added. + * The expectation is that the FIB will ensure that nothing bad + * will come of adding bogus entries. + */ if (mp->is_add) - rv = ip_neighbor_add (&ip, mp->is_ipv6, mp->mac_address, - ntohl (mp->sw_if_index), flags, &stats_index); + rv = ip_neighbor_add (&ip, type, &mac, + ntohl (mp->neighbor.sw_if_index), + flags, &stats_index); else - rv = ip_neighbor_del (&ip, mp->is_ipv6, ntohl (mp->sw_if_index)); + rv = ip_neighbor_del (&ip, type, ntohl (mp->neighbor.sw_if_index)); stats_dsunlock (); @@ -1660,11 +1697,13 @@ static void { vlib_main_t *vm = vlib_get_main (); vl_api_sw_interface_ip6nd_ra_prefix_reply_t *rmp; + fib_prefix_t pfx; int rv = 0; u8 is_no, use_default, no_advertise, off_link, no_autoconfig, no_onlink; VALIDATE_SW_IF_INDEX (mp); + ip_prefix_decode (&mp->prefix, &pfx); is_no = mp->is_no == 1; use_default = mp->use_default == 1; no_advertise = mp->no_advertise == 1; @@ -1673,8 +1712,8 @@ static void no_onlink = mp->no_onlink == 1; rv = ip6_neighbor_ra_prefix (vm, ntohl (mp->sw_if_index), - (ip6_address_t *) mp->address, - mp->address_length, use_default, + &pfx.fp_addr.ip6, + pfx.fp_len, use_default, ntohl (mp->val_lifetime), ntohl (mp->pref_lifetime), no_advertise, off_link, no_autoconfig, no_onlink, is_no); @@ -1695,7 +1734,8 @@ send_ip6nd_proxy_details (vl_api_registration_t * reg, mp->_vl_msg_id = ntohs (VL_API_IP6ND_PROXY_DETAILS); mp->context = context; mp->sw_if_index = htonl (sw_if_index); - memcpy (mp->address, addr, 16); + + ip6_address_encode (&addr->ip6, mp->ip); vl_api_send_msg (reg, (u8 *) mp); } @@ -1763,12 +1803,13 @@ static void vl_api_ip6nd_proxy_add_del_t_handler (vl_api_ip6nd_proxy_add_del_t * mp) { vl_api_ip6nd_proxy_add_del_reply_t *rmp; + ip6_address_t ip6; int rv = 0; VALIDATE_SW_IF_INDEX (mp); - rv = ip6_neighbor_proxy_add_del (ntohl (mp->sw_if_index), - (ip6_address_t *) mp->address, mp->is_del); + ip6_address_decode (mp->ip, &ip6); + rv = ip6_neighbor_proxy_add_del (ntohl (mp->sw_if_index), &ip6, mp->is_del); BAD_SW_IF_INDEX_LABEL; REPLY_MACRO (VL_API_IP6ND_PROXY_ADD_DEL_REPLY); @@ -1910,8 +1951,9 @@ static void clib_error_t *error; clib_memset (&args, 0, sizeof (args)); - ip_set (&args.prefix.fp_addr, mp->ip, mp->is_ip4); - args.prefix.fp_len = mp->plen ? mp->plen : (mp->is_ip4 ? 32 : 128); + + ip_prefix_decode (&mp->pfx, &args.prefix); + args.sw_if_index = clib_net_to_host_u32 (mp->sw_if_index); args.is_add = mp->is_add; if ((error = vnet_ip_container_proxy_add_del (&args))) @@ -2014,11 +2056,8 @@ static void vl_api_ip_source_and_port_range_check_add_del_reply_t *rmp; int rv = 0; - u8 is_ipv6 = mp->is_ipv6; u8 is_add = mp->is_add; - u8 mask_length = mp->mask_length; - ip4_address_t ip4_addr; - ip6_address_t ip6_addr; + fib_prefix_t pfx; u16 *low_ports = 0; u16 *high_ports = 0; u32 vrf_id; @@ -2026,6 +2065,8 @@ static void u8 num_ranges; int i; + ip_prefix_decode (&mp->prefix, &pfx); + // Validate port range num_ranges = mp->number_of_ranges; if (num_ranges > 32) @@ -2052,13 +2093,6 @@ static void vec_add1 (high_ports, tmp_high + 1); } - // Validate mask_length - if ((is_ipv6 && mask_length > 128) || (!is_ipv6 && mask_length > 32)) - { - rv = VNET_API_ERROR_ADDRESS_LENGTH_MISMATCH; - goto reply; - } - vrf_id = ntohl (mp->vrf_id); if (vrf_id < 1) @@ -2068,20 +2102,18 @@ static void } - if (is_ipv6) + if (FIB_PROTOCOL_IP6 == pfx.fp_proto) { - clib_memcpy (ip6_addr.as_u8, mp->address, sizeof (ip6_addr.as_u8)); - rv = ip6_source_and_port_range_check_add_del (&ip6_addr, - mask_length, + rv = ip6_source_and_port_range_check_add_del (&pfx.fp_addr.ip6, + pfx.fp_len, vrf_id, low_ports, high_ports, is_add); } else { - clib_memcpy (ip4_addr.data, mp->address, sizeof (ip4_addr)); - rv = ip4_source_and_port_range_check_add_del (&ip4_addr, - mask_length, + rv = ip4_source_and_port_range_check_add_del (&pfx.fp_addr.ip4, + pfx.fp_len, vrf_id, low_ports, high_ports, is_add); @@ -2181,10 +2213,22 @@ static void #define IP4_ARP_EVENT 3 #define IP6_ND_EVENT 4 -static int arp_change_delete_callback (u32 pool_index, u8 * notused); -static int nd_change_delete_callback (u32 pool_index, u8 * notused); static vlib_node_registration_t ip_resolver_process_node; +static int +arp_change_delete_callback (u32 pool_index, + const mac_address_t * mac, + u32 sw_if_index, const ip4_address_t * address) +{ + vpe_api_main_t *am = &vpe_api_main; + + if (pool_is_free_index (am->arp_events, pool_index)) + return 1; + + pool_put_index (am->arp_events, pool_index); + return 0; +} + static void handle_ip4_arp_event (u32 pool_index) { @@ -2206,7 +2250,7 @@ handle_ip4_arp_event (u32 pool_index) { (void) vnet_add_del_ip4_arp_change_event (vnm, arp_change_delete_callback, - event->pid, &event->address, + event->pid, event->ip, ip_resolver_process_node.index, IP4_ARP_EVENT, ~0 /* pool index, notused */ , 0 /* is_add */ ); return; @@ -2228,12 +2272,26 @@ handle_ip4_arp_event (u32 pool_index) if (vlib_time_now (vm) > last_time + 10.0) { clib_warning ("arp event for %U to pid %d: queue stuffed!", - format_ip4_address, &event->address, event->pid); + format_ip4_address, event->ip, event->pid); last_time = vlib_time_now (vm); } } } +static int +nd_change_delete_callback (u32 pool_index, + const mac_address_t * mac, + u32 sw_if_index, const ip6_address_t * addr) +{ + vpe_api_main_t *am = &vpe_api_main; + + if (pool_is_free_index (am->nd_events, pool_index)) + return 1; + + pool_put_index (am->nd_events, pool_index); + return 0; +} + static void handle_ip6_nd_event (u32 pool_index) { @@ -2255,7 +2313,7 @@ handle_ip6_nd_event (u32 pool_index) { (void) vnet_add_del_ip6_nd_change_event (vnm, nd_change_delete_callback, - event->pid, &event->address, + event->pid, event->ip, ip_resolver_process_node.index, IP6_ND_EVENT, ~0 /* pool index, notused */ , 0 /* is_add */ ); return; @@ -2277,7 +2335,7 @@ handle_ip6_nd_event (u32 pool_index) if (vlib_time_now (vm) > last_time + 10.0) { clib_warning ("ip6 nd event for %U to pid %d: queue stuffed!", - format_ip6_address, &event->address, event->pid); + format_ip6_address, event->ip, event->pid); last_time = vlib_time_now (vm); } } @@ -2328,8 +2386,8 @@ VLIB_REGISTER_NODE (ip_resolver_process_node,static) = { /* *INDENT-ON* */ static int -nd_change_data_callback (u32 pool_index, u8 * new_mac, - u32 sw_if_index, ip6_address_t * address) +nd_change_data_callback (u32 pool_index, const mac_address_t * new_mac, + u32 sw_if_index, const ip6_address_t * address) { vpe_api_main_t *am = &vpe_api_main; vl_api_ip6_nd_event_t *event; @@ -2338,41 +2396,17 @@ nd_change_data_callback (u32 pool_index, u8 * new_mac, return 1; event = pool_elt_at_index (am->nd_events, pool_index); - if (eth_mac_equal (event->new_mac, new_mac) && + if (ethernet_mac_address_equal (event->mac, new_mac->bytes) && sw_if_index == ntohl (event->sw_if_index)) { return 1; } - clib_memcpy (event->new_mac, new_mac, sizeof (event->new_mac)); + mac_address_encode (new_mac, event->mac); event->sw_if_index = htonl (sw_if_index); return 0; } -static int -arp_change_delete_callback (u32 pool_index, u8 * notused) -{ - vpe_api_main_t *am = &vpe_api_main; - - if (pool_is_free_index (am->arp_events, pool_index)) - return 1; - - pool_put_index (am->arp_events, pool_index); - return 0; -} - -static int -nd_change_delete_callback (u32 pool_index, u8 * notused) -{ - vpe_api_main_t *am = &vpe_api_main; - - if (pool_is_free_index (am->nd_events, pool_index)) - return 1; - - pool_put_index (am->nd_events, pool_index); - return 0; -} - static vlib_node_registration_t wc_arp_process_node; enum @@ -2403,9 +2437,10 @@ wc_arp_process (vlib_main_t * vm, vlib_node_runtime_t * rt, vlib_frame_t * f) wc_arp_report_t *arp_events = event_data; for (i = 0; i < vec_len (arp_events); i++) { - /* discard dup event */ - if (arp_prev.ip4 == arp_events[i].ip4 && - eth_mac_equal ((u8 *) arp_prev.mac, arp_events[i].mac) && + /* discard dup event - cast away volatile */ + if (arp_prev.ip.as_u32 == arp_events[i].ip.as_u32 && + mac_address_equal ((const mac_address_t *) &arp_prev.mac, + &arp_events[i].mac) && arp_prev.sw_if_index == arp_events[i].sw_if_index && (now - last_arp) < 10.0) { @@ -2428,9 +2463,9 @@ wc_arp_process (vlib_main_t * vm, vlib_node_runtime_t * rt, vlib_frame_t * f) event->client_index = reg->client_index; event->pid = reg->client_pid; event->mac_ip = 1; - event->address = arp_events[i].ip4; + ip4_address_encode(&arp_events[i].ip, event->ip); event->sw_if_index = htonl(arp_events[i].sw_if_index); - memcpy(event->new_mac, arp_events[i].mac, sizeof event->new_mac); + mac_address_encode(&arp_events[i].mac, event->mac); vl_api_send_msg (vl_reg, (u8 *) event); } })); @@ -2442,10 +2477,11 @@ wc_arp_process (vlib_main_t * vm, vlib_node_runtime_t * rt, vlib_frame_t * f) wc_nd_report_t *nd_events = event_data; for (i = 0; i < vec_len (nd_events); i++) { - /* discard dup event */ - if (ip6_address_is_equal - ((ip6_address_t *) & nd_prev.ip6, &nd_events[i].ip6) - && eth_mac_equal ((u8 *) nd_prev.mac, nd_events[i].mac) + /* discard dup event - cast away volatile */ + if (ip6_address_is_equal ((const ip6_address_t *) &nd_prev.ip6, + &nd_events[i].ip6) + && mac_address_equal ((const mac_address_t *) &nd_prev.mac, + &nd_events[i].mac) && nd_prev.sw_if_index == nd_events[i].sw_if_index && (now - last_nd) < 10.0) { @@ -2467,9 +2503,9 @@ wc_arp_process (vlib_main_t * vm, vlib_node_runtime_t * rt, vlib_frame_t * f) event->client_index = reg->client_index; event->pid = reg->client_pid; event->mac_ip = 1; - memcpy(event->address, nd_events[i].ip6.as_u8, sizeof event->address); + ip6_address_encode(&nd_events[i].ip6, event->ip); event->sw_if_index = htonl(nd_events[i].sw_if_index); - memcpy(event->new_mac, nd_events[i].mac, sizeof event->new_mac); + mac_address_encode(&nd_events[i].mac, event->mac); vl_api_send_msg (vl_reg, (u8 *) event); } })); @@ -2507,7 +2543,8 @@ wc_arp_process (vlib_main_t * vm, vlib_node_runtime_t * rt, vlib_frame_t * f) event->sw_if_index = clib_host_to_net_u32 (ra_events[i].sw_if_index); - memcpy (event->router_address, ra_events[i].router_address, 16); + ip6_address_encode (&ra_events[i].router_address, + event->router_addr); event->current_hop_limit = ra_events[i].current_hop_limit; event->flags = ra_events[i].flags; @@ -2531,9 +2568,7 @@ wc_arp_process (vlib_main_t * vm, vlib_node_runtime_t * rt, vlib_frame_t * f) { ra_report_prefix_info_t *info = &ra_events[i].prefixes[j]; - memcpy (prefix->dst_address, info->dst_address.as_u8, - 16); - prefix->dst_address_length = info->dst_address_length; + ip_prefix_encode(&info->prefix, &prefix->prefix); prefix->flags = info->flags; prefix->valid_time = clib_host_to_net_u32 (info->valid_time); @@ -2564,8 +2599,9 @@ VLIB_REGISTER_NODE (wc_arp_process_node,static) = { /* *INDENT-ON* */ static int -arp_change_data_callback (u32 pool_index, u8 * new_mac, - u32 sw_if_index, u32 address) +arp_change_data_callback (u32 pool_index, + const mac_address_t * mac, + u32 sw_if_index, const ip4_address_t * address) { vpe_api_main_t *am = &vpe_api_main; vl_api_ip4_arp_event_t *event; @@ -2574,13 +2610,13 @@ arp_change_data_callback (u32 pool_index, u8 * new_mac, return 1; event = pool_elt_at_index (am->arp_events, pool_index); - if (eth_mac_equal (event->new_mac, new_mac) && + if (ethernet_mac_address_equal (event->mac, mac->bytes) && sw_if_index == ntohl (event->sw_if_index)) { return 1; } - clib_memcpy (event->new_mac, new_mac, sizeof (event->new_mac)); + mac_address_encode (mac, event->mac); event->sw_if_index = htonl (sw_if_index); return 0; } @@ -2591,9 +2627,12 @@ vl_api_want_ip4_arp_events_t_handler (vl_api_want_ip4_arp_events_t * mp) vpe_api_main_t *am = &vpe_api_main; vnet_main_t *vnm = vnet_get_main (); vl_api_want_ip4_arp_events_reply_t *rmp; + ip4_address_t ip; int rv = 0; - if (mp->address == 0) + ip4_address_decode (mp->ip, &ip); + + if (ip.as_u32 == 0) { uword *p = hash_get (am->wc_ip4_arp_events_registration_hash, mp->client_index); @@ -2639,7 +2678,7 @@ vl_api_want_ip4_arp_events_t_handler (vl_api_want_ip4_arp_events_t * mp) pool_get (am->arp_events, event); rv = vnet_add_del_ip4_arp_change_event (vnm, arp_change_data_callback, - mp->pid, &mp->address /* addr, in net byte order */ , + mp->pid, mp->ip /* addr, in net byte order */ , ip_resolver_process_node.index, IP4_ARP_EVENT, event - am->arp_events, 1 /* is_add */ ); @@ -2653,16 +2692,16 @@ vl_api_want_ip4_arp_events_t_handler (vl_api_want_ip4_arp_events_t * mp) /* Python API expects events to have no context */ event->_vl_msg_id = htons (VL_API_IP4_ARP_EVENT); event->client_index = mp->client_index; - event->address = mp->address; + memcpy (event->ip, mp->ip, 4); event->pid = mp->pid; - if (mp->address == 0) + if (ip.as_u32 == 0) event->mac_ip = 1; } else { rv = vnet_add_del_ip4_arp_change_event (vnm, arp_change_delete_callback, - mp->pid, &mp->address /* addr, in net byte order */ , + mp->pid, mp->ip /* addr, in net byte order */ , ip_resolver_process_node.index, IP4_ARP_EVENT, ~0 /* pool index */ , 0 /* is_add */ ); } @@ -2700,7 +2739,7 @@ want_ip4_arp_events_reaper (u32 client_index) event = pool_elt_at_index (am->arp_events, *event_id); vnet_add_del_ip4_arp_change_event (vnm, arp_change_delete_callback, - event->pid, &event->address, + event->pid, event->ip, ip_resolver_process_node.index, IP4_ARP_EVENT, ~0 /* pool index, notused */ , 0 /* is_add */ ); } @@ -2728,9 +2767,12 @@ vl_api_want_ip6_nd_events_t_handler (vl_api_want_ip6_nd_events_t * mp) vpe_api_main_t *am = &vpe_api_main; vnet_main_t *vnm = vnet_get_main (); vl_api_want_ip6_nd_events_reply_t *rmp; + ip6_address_t ip6; int rv = 0; - if (ip6_address_is_zero ((ip6_address_t *) mp->address)) + ip6_address_decode (mp->ip, &ip6); + + if (ip6_address_is_zero (&ip6)) { uword *p = hash_get (am->wc_ip6_nd_events_registration_hash, mp->client_index); @@ -2777,7 +2819,7 @@ vl_api_want_ip6_nd_events_t_handler (vl_api_want_ip6_nd_events_t * mp) rv = vnet_add_del_ip6_nd_change_event (vnm, nd_change_data_callback, - mp->pid, mp->address /* addr, in net byte order */ , + mp->pid, &ip6, ip_resolver_process_node.index, IP6_ND_EVENT, event - am->nd_events, 1 /* is_add */ ); @@ -2790,14 +2832,14 @@ vl_api_want_ip6_nd_events_t_handler (vl_api_want_ip6_nd_events_t * mp) event->_vl_msg_id = ntohs (VL_API_IP6_ND_EVENT); event->client_index = mp->client_index; - clib_memcpy (event->address, mp->address, sizeof event->address); + ip6_address_encode (&ip6, event->ip); event->pid = mp->pid; } else { rv = vnet_add_del_ip6_nd_change_event (vnm, nd_change_delete_callback, - mp->pid, mp->address /* addr, in net byte order */ , + mp->pid, &ip6 /* addr, in net byte order */ , ip_resolver_process_node.index, IP6_ND_EVENT, ~0 /* pool index */ , 0 /* is_add */ ); } @@ -2836,7 +2878,7 @@ want_ip6_nd_events_reaper (u32 client_index) event = pool_elt_at_index (am->nd_events, *event_id); vnet_add_del_ip6_nd_change_event (vnm, nd_change_delete_callback, - event->pid, &event->address, + event->pid, event->ip, ip_resolver_process_node.index, IP6_ND_EVENT, ~0 /* pool index, notused */ , 0 /* is_add */ ); } @@ -2923,26 +2965,24 @@ static void vl_api_proxy_arp_add_del_t_handler (vl_api_proxy_arp_add_del_t * mp) { vl_api_proxy_arp_add_del_reply_t *rmp; + ip4_address_t lo, hi; u32 fib_index; int rv; - ip4_main_t *im = &ip4_main; - uword *p; stats_dslock_with_hint (1 /* release hint */ , 6 /* tag */ ); - p = hash_get (im->fib_index_by_table_id, ntohl (mp->proxy.vrf_id)); + fib_index = fib_table_find (FIB_PROTOCOL_IP4, ntohl (mp->proxy.table_id)); - if (!p) + if (~0 == fib_index) { rv = VNET_API_ERROR_NO_SUCH_FIB; goto out; } - fib_index = p[0]; + ip4_address_decode (mp->proxy.low, &lo); + ip4_address_decode (mp->proxy.hi, &hi); - rv = vnet_proxy_arp_add_del ((ip4_address_t *) mp->proxy.low_address, - (ip4_address_t *) mp->proxy.hi_address, - fib_index, mp->is_add == 0); + rv = vnet_proxy_arp_add_del (&lo, &hi, fib_index, mp->is_add == 0); out: stats_dsunlock (); @@ -2969,10 +3009,10 @@ send_proxy_arp_details (const ip4_address_t * lo_addr, clib_memset (mp, 0, sizeof (*mp)); mp->_vl_msg_id = ntohs (VL_API_PROXY_ARP_DETAILS); mp->context = ctx->context; - mp->proxy.vrf_id = htonl (fib_index); - clib_memcpy (mp->proxy.low_address, lo_addr, - sizeof (mp->proxy.low_address)); - clib_memcpy (mp->proxy.hi_address, hi_addr, sizeof (mp->proxy.hi_address)); + mp->proxy.table_id = htonl (fib_index); + + ip4_address_encode (lo_addr, mp->proxy.low); + ip4_address_encode (hi_addr, mp->proxy.hi); vl_api_send_msg (ctx->reg, (u8 *) mp); @@ -3069,17 +3109,18 @@ vl_api_ip_probe_neighbor_t_handler (vl_api_ip_probe_neighbor_t * mp) vlib_main_t *vm = vlib_get_main (); vl_api_ip_probe_neighbor_reply_t *rmp; clib_error_t *error; + ip46_address_t dst; + ip46_type_t itype; VALIDATE_SW_IF_INDEX (mp); u32 sw_if_index = ntohl (mp->sw_if_index); + itype = ip_address_decode (&mp->dst, &dst); - if (mp->is_ipv6) - error = ip6_probe_neighbor (vm, (ip6_address_t *) mp->dst_address, - sw_if_index, 0); + if (IP46_TYPE_IP6 == itype) + error = ip6_probe_neighbor (vm, &dst.ip6, sw_if_index, 0); else - error = ip4_probe_neighbor (vm, (ip4_address_t *) mp->dst_address, - sw_if_index, 0); + error = ip4_probe_neighbor (vm, &dst.ip4, sw_if_index, 0); if (error) { diff --git a/src/vnet/ip/ip_neighbor.c b/src/vnet/ip/ip_neighbor.c index 7d1998d25b8..ad89d3ff679 100644 --- a/src/vnet/ip/ip_neighbor.c +++ b/src/vnet/ip/ip_neighbor.c @@ -49,8 +49,8 @@ static ip_neighbor_scan_config_t ip_neighbor_scan_conf; int ip_neighbor_add (const ip46_address_t * ip, - u8 is_ip6, - const u8 * mac, + ip46_type_t type, + const mac_address_t * mac, u32 sw_if_index, ip_neighbor_flags_t flags, u32 * stats_index) { @@ -63,13 +63,10 @@ ip_neighbor_add (const ip46_address_t * ip, * The expectation is that the FIB will ensure that nothing bad * will come of adding bogus entries. */ - if (is_ip6) + if (IP46_TYPE_IP6 == type) { rv = vnet_set_ip6_ethernet_neighbor (vlib_get_main (), - sw_if_index, &ip->ip6, mac, 6, - (flags & IP_NEIGHBOR_FLAG_STATIC), - (flags & - IP_NEIGHBOR_FLAG_NO_ADJ_FIB)); + sw_if_index, &ip->ip6, mac, flags); fproto = FIB_PROTOCOL_IP6; linkt = VNET_LINK_IP6; } @@ -77,16 +74,12 @@ ip_neighbor_add (const ip46_address_t * ip, { ethernet_arp_ip4_over_ethernet_address_t a = { .ip4 = ip->ip4, + .mac = *mac, }; - clib_memcpy (&a.ethernet, mac, 6); - - rv = vnet_arp_set_ip4_over_ethernet (vnet_get_main (), - sw_if_index, - &a, - (flags & IP_NEIGHBOR_FLAG_STATIC), - (flags & - IP_NEIGHBOR_FLAG_NO_ADJ_FIB)); + rv = + vnet_arp_set_ip4_over_ethernet (vnet_get_main (), sw_if_index, &a, + flags); fproto = FIB_PROTOCOL_IP4; linkt = VNET_LINK_IP4; } @@ -98,11 +91,11 @@ ip_neighbor_add (const ip46_address_t * ip, } int -ip_neighbor_del (const ip46_address_t * ip, u8 is_ip6, u32 sw_if_index) +ip_neighbor_del (const ip46_address_t * ip, ip46_type_t type, u32 sw_if_index) { int rv; - if (is_ip6) + if (IP46_TYPE_IP6 == type) { rv = vnet_unset_ip6_ethernet_neighbor (vlib_get_main (), sw_if_index, &ip->ip6); @@ -180,14 +173,14 @@ ip_neighbor_scan (vlib_main_t * vm, f64 start_time, u32 start_idx, if (!is_ip6) { n4 = pool_elt_at_index (np4, curr_idx); - if (n4->flags & ETHERNET_ARP_IP4_ENTRY_FLAG_STATIC) + if (n4->flags & IP_NEIGHBOR_FLAG_STATIC) goto next_neighbor; update_time = n4->time_last_updated; } else { n6 = pool_elt_at_index (np6, curr_idx); - if (n6->flags & IP6_NEIGHBOR_FLAG_STATIC) + if (n6->flags & IP_NEIGHBOR_FLAG_STATIC) goto next_neighbor; update_time = n6->time_last_updated; } @@ -199,9 +192,11 @@ ip_neighbor_scan (vlib_main_t * vm, f64 start_time, u32 start_idx, /* delete stale neighbor */ if (!is_ip6) { - ethernet_arp_ip4_over_ethernet_address_t delme; - clib_memcpy (&delme.ethernet, n4->ethernet_address, 6); - delme.ip4.as_u32 = n4->ip4_address.as_u32; + ethernet_arp_ip4_over_ethernet_address_t delme = { + .ip4.as_u32 = n4->ip4_address.as_u32, + .mac = n4->mac, + }; + vnet_arp_unset_ip4_over_ethernet (vnm, n4->sw_if_index, &delme); } else diff --git a/src/vnet/ip/ip_neighbor.h b/src/vnet/ip/ip_neighbor.h index 9eeebdb1555..84247f22f47 100644 --- a/src/vnet/ip/ip_neighbor.h +++ b/src/vnet/ip/ip_neighbor.h @@ -37,19 +37,22 @@ void ip_neighbor_scan_enable_disable (ip_neighbor_scan_arg_t * arg); typedef enum ip_neighbor_flags_t_ { - IP_NEIGHBOR_FLAG_NODE = 0, + IP_NEIGHBOR_FLAG_NONE = 0, IP_NEIGHBOR_FLAG_STATIC = (1 << 0), - IP_NEIGHBOR_FLAG_NO_ADJ_FIB = (1 << 1), -} ip_neighbor_flags_t; + IP_NEIGHBOR_FLAG_DYNAMIC = (1 << 1), + IP_NEIGHBOR_FLAG_NO_FIB_ENTRY = (1 << 2), +} __attribute__ ((packed)) ip_neighbor_flags_t; + +extern u8 *format_ip_neighbor_flags (u8 * s, va_list * args); extern int ip_neighbor_add (const ip46_address_t * ip, - u8 is_ip6, - const u8 * mac, + ip46_type_t type, + const mac_address_t * mac, u32 sw_if_index, ip_neighbor_flags_t flags, u32 * stats_index); extern int ip_neighbor_del (const ip46_address_t * ip, - u8 is_ip6, u32 sw_if_index); + ip46_type_t type, u32 sw_if_index); #endif /* included_ip_neighbor_h */ diff --git a/src/vnet/ip/ip_types_api.c b/src/vnet/ip/ip_types_api.c index 6bc035ebef2..b56101c355f 100644 --- a/src/vnet/ip/ip_types_api.c +++ b/src/vnet/ip/ip_types_api.c @@ -29,6 +29,30 @@ #include <vnet/vnet_all_api_h.h> #undef vl_printfun +void +ip6_address_encode (const ip6_address_t * in, vl_api_ip6_address_t out) +{ + clib_memcpy (out, in, sizeof (*in)); +} + +void +ip6_address_decode (const vl_api_ip6_address_t in, ip6_address_t * out) +{ + clib_memcpy (out, in, sizeof (*out)); +} + +void +ip4_address_encode (const ip4_address_t * in, vl_api_ip4_address_t out) +{ + clib_memcpy (out, in, sizeof (*in)); +} + +void +ip4_address_decode (const vl_api_ip4_address_t in, ip4_address_t * out) +{ + clib_memcpy (out, in, sizeof (*out)); +} + static ip46_type_t ip_address_union_decode (const vl_api_address_union_t * in, vl_api_address_family_t af, ip46_address_t * out) @@ -67,9 +91,9 @@ ip_address_union_encode (const ip46_address_t * in, vl_api_address_union_t * out) { if (ADDRESS_IP6 == clib_net_to_host_u32 (af)) - memcpy (&out->ip6, &in->ip6, sizeof (out->ip6)); + ip6_address_encode (&in->ip6, out->ip6); else - memcpy (&out->ip4, &in->ip4, sizeof (out->ip4)); + ip4_address_encode (&in->ip4, out->ip4); } void diff --git a/src/vnet/ip/ip_types_api.h b/src/vnet/ip/ip_types_api.h index be41bf59ec3..a67134c9a86 100644 --- a/src/vnet/ip/ip_types_api.h +++ b/src/vnet/ip/ip_types_api.h @@ -27,6 +27,8 @@ /** * Forward declarations so we need not #include the API definitions here */ +typedef u8 vl_api_ip6_address_t[16]; +typedef u8 vl_api_ip4_address_t[4]; struct _vl_api_address; struct _vl_api_prefix; struct _vl_api_mprefix; @@ -35,6 +37,14 @@ extern ip46_type_t ip_address_decode (const struct _vl_api_address *in, ip46_address_t * out); extern void ip_address_encode (const ip46_address_t * in, ip46_type_t type, struct _vl_api_address *out); +extern void ip6_address_encode (const ip6_address_t * in, + vl_api_ip6_address_t out); +extern void ip6_address_decode (const vl_api_ip6_address_t in, + ip6_address_t * out); +extern void ip4_address_encode (const ip4_address_t * in, + vl_api_ip4_address_t out); +extern void ip4_address_decode (const vl_api_ip4_address_t in, + ip4_address_t * out); extern void ip_prefix_decode (const struct _vl_api_prefix *in, fib_prefix_t * out); diff --git a/src/vnet/ip/lookup.c b/src/vnet/ip/lookup.c index 2a9b3fed0c9..5c6fec1810b 100644 --- a/src/vnet/ip/lookup.c +++ b/src/vnet/ip/lookup.c @@ -51,6 +51,7 @@ #include <vnet/dpo/ip_null_dpo.h> #include <vnet/dpo/l3_proxy_dpo.h> #include <vnet/ip/ip6_neighbor.h> +#include <vnet/ethernet/arp.h> /** * @file diff --git a/src/vnet/ip/rd_cp.c b/src/vnet/ip/rd_cp.c index 1a6122fc9d3..a0894fa3d7c 100644 --- a/src/vnet/ip/rd_cp.c +++ b/src/vnet/ip/rd_cp.c @@ -297,7 +297,7 @@ ip6_ra_report_handler (void *data) if (default_route->sw_if_index != sw_if_index) ; else if (0 != memcmp (&default_route->router_address, - r->router_address, 16)) + &r->router_address, 16)) ; else { @@ -311,7 +311,7 @@ ip6_ra_report_handler (void *data) if (!route_already_present) { if (router_lifetime_in_sec != 0) - add_default_route (vm, sw_if_index, (void *) r->router_address, + add_default_route (vm, sw_if_index, &r->router_address, current_time + router_lifetime_in_sec); } else @@ -346,8 +346,8 @@ ip6_ra_report_handler (void *data) if (!(prefix->flags & PREFIX_FLAG_A)) continue; - dst_address = &prefix->dst_address; - prefix_length = prefix->dst_address_length; + dst_address = &prefix->prefix.fp_addr.ip6; + prefix_length = prefix->prefix.fp_len; if (ip6_address_is_link_local_unicast (dst_address)) continue; |