X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Fip%2Fip6_neighbor.c;h=87bda439ae5b3532455dc574975cbd03e17d12c7;hb=17ff3c1fa5687255a118c53223fa2cd49132d929;hp=1b37e549e83b98a2abd5b85ffd0e6a07ee0f05b8;hpb=4fed5b1b34b346f25feef34c590b4dd428343756;p=vpp.git diff --git a/src/vnet/ip/ip6_neighbor.c b/src/vnet/ip/ip6_neighbor.c index 1b37e549e83..87bda439ae5 100644 --- a/src/vnet/ip/ip6_neighbor.c +++ b/src/vnet/ip/ip6_neighbor.c @@ -236,6 +236,29 @@ static ip6_address_t ip6a_zero; /* ip6 address 0 */ static void wc_nd_signal_report (wc_nd_report_t * r); static void ra_signal_report (ra_report_t * r); +ip6_address_t +ip6_neighbor_get_link_local_address (u32 sw_if_index) +{ + static ip6_address_t empty_address = { {0} }; + ip6_neighbor_main_t *nm = &ip6_neighbor_main; + ip6_radv_t *radv_info; + u32 ri; + + ri = nm->if_radv_pool_index_by_sw_if_index[sw_if_index]; + if (ri == ~0) + { + clib_warning ("IPv6 is not enabled for sw_if_index %d", sw_if_index); + return empty_address; + } + radv_info = pool_elt_at_index (nm->if_radv_pool, ri); + if (radv_info == NULL) + { + clib_warning ("Internal error"); + return empty_address; + } + return radv_info->link_local_address; +} + /** * @brief publish wildcard arp event * @param sw_if_index The interface on which the ARP entires are acted @@ -443,6 +466,8 @@ ip6_nbr_probe (ip_adjacency_t * adj) h = vlib_packet_template_get_packet (vm, &im->discover_neighbor_packet_template, &bi); + if (!h) + return; hi = vnet_get_sup_hw_interface (vnm, adj->rewrite_header.sw_if_index); @@ -2610,10 +2635,6 @@ ip6_neighbor_sw_interface_add_del (vnet_main_t * vnm, { if (is_add) { - vnet_hw_interface_t *hw_if0; - - hw_if0 = vnet_get_sup_hw_interface (vnm, sw_if_index); - pool_get (nm->if_radv_pool, a); ri = a - nm->if_radv_pool; @@ -2647,7 +2668,8 @@ ip6_neighbor_sw_interface_add_del (vnet_main_t * vnm, a->send_radv = 1; /* fill in radv_info for this interface that will be needed later */ - a->adv_link_mtu = hw_if0->max_l3_packet_bytes[VLIB_RX]; + a->adv_link_mtu = + vnet_sw_interface_get_mtu (vnm, sw_if_index, VNET_MTU_IP6); clib_memcpy (a->link_layer_address, eth_if0->address, 6); @@ -3265,6 +3287,8 @@ ip6_discover_neighbor_inline (vlib_main_t * vm, h0 = vlib_packet_template_get_packet (vm, &im->discover_neighbor_packet_template, &bi0); + if (!h0) + continue; /* * Build ethernet header. @@ -4166,6 +4190,7 @@ enable_ip6_interface (vlib_main_t * vm, u32 sw_if_index) sw_if0 = vnet_get_sw_interface (vnm, sw_if_index); if (sw_if0->type == VNET_SW_INTERFACE_TYPE_SUB || + sw_if0->type == VNET_SW_INTERFACE_TYPE_PIPE || sw_if0->type == VNET_SW_INTERFACE_TYPE_P2P) { /* make up an interface id */ @@ -4757,11 +4782,17 @@ vnet_add_del_ip6_nd_change_event (vnet_main_t * vnm, return VNET_API_ERROR_ENTRY_ALREADY_EXISTS; pool_get (nm->mac_changes, mc); + /* *INDENT-OFF* */ *mc = (pending_resolution_t) { - .next_index = ~0,.node_index = node_index,.type_opaque = - type_opaque,.data = data,.data_callback = data_callback,.pid = - pid,}; + .next_index = ~0, + .node_index = node_index, + .type_opaque = type_opaque, + .data = data, + .data_callback = data_callback, + .pid = pid, + }; + /* *INDENT-ON* */ /* Insert new resolution at the end of the list */ u32 new_idx = mc - nm->mac_changes; @@ -4980,22 +5011,23 @@ ethernet_ndp_change_mac (u32 sw_if_index) } void -send_ip6_na (vlib_main_t * vm, const vnet_hw_interface_t * hi) +send_ip6_na (vlib_main_t * vm, u32 sw_if_index) { ip6_main_t *i6m = &ip6_main; - u32 sw_if_index = hi->sw_if_index; ip6_address_t *ip6_addr = ip6_interface_first_address (i6m, sw_if_index); - send_ip6_na_w_addr (vm, ip6_addr, hi); + send_ip6_na_w_addr (vm, ip6_addr, sw_if_index); } void send_ip6_na_w_addr (vlib_main_t * vm, - const ip6_address_t * ip6_addr, - const vnet_hw_interface_t * hi) + const ip6_address_t * ip6_addr, u32 sw_if_index) { ip6_main_t *i6m = &ip6_main; - u32 sw_if_index = hi->sw_if_index; + vnet_main_t *vnm = vnet_get_main (); + u8 *rewrite, rewrite_len; + vnet_hw_interface_t *hi = vnet_get_sup_hw_interface (vnm, sw_if_index); + u8 dst_address[6]; if (ip6_addr) { @@ -5010,6 +5042,9 @@ send_ip6_na_w_addr (vlib_main_t * vm, vlib_packet_template_get_packet (vm, &i6m->discover_neighbor_packet_template, &bi); + if (!h) + return; + ip6_set_reserved_multicast_address (&h->ip.dst_address, IP6_MULTICAST_SCOPE_link_local, IP6_MULTICAST_GROUP_ID_all_hosts); @@ -5026,12 +5061,15 @@ send_ip6_na_w_addr (vlib_main_t * vm, /* Setup MAC header with IP6 Etype and mcast DMAC */ vlib_buffer_t *b = vlib_get_buffer (vm, bi); - vlib_buffer_advance (b, -sizeof (ethernet_header_t)); - ethernet_header_t *e = vlib_buffer_get_current (b); - e->type = clib_host_to_net_u16 (ETHERNET_TYPE_IP6); - clib_memcpy (e->src_address, hi->hw_address, sizeof (e->src_address)); - ip6_multicast_ethernet_address (e->dst_address, + ip6_multicast_ethernet_address (dst_address, IP6_MULTICAST_GROUP_ID_all_hosts); + rewrite = + ethernet_build_rewrite (vnm, sw_if_index, VNET_LINK_IP6, dst_address); + rewrite_len = vec_len (rewrite); + vlib_buffer_advance (b, -rewrite_len); + ethernet_header_t *e = vlib_buffer_get_current (b); + clib_memcpy (e->dst_address, rewrite, rewrite_len); + vec_free (rewrite); /* Send unsolicited ND advertisement packet out the specified interface */ vnet_buffer (b)->sw_if_index[VLIB_RX] =