X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Fip-neighbor%2Fip4_neighbor.c;h=c268b96e00d5acf71005e765422451a236c68a9b;hb=e2fe09742;hp=2a9e2675a78fc2f554c24d2e43889c8d58aeb1f8;hpb=cbe25aab3be72154f2c706c39eeba6a77f34450f;p=vpp.git diff --git a/src/vnet/ip-neighbor/ip4_neighbor.c b/src/vnet/ip-neighbor/ip4_neighbor.c index 2a9e2675a78..c268b96e00d 100644 --- a/src/vnet/ip-neighbor/ip4_neighbor.c +++ b/src/vnet/ip-neighbor/ip4_neighbor.c @@ -39,20 +39,24 @@ #include #include +#include +#include + +/** ARP throttling */ +static throttle_t arp_throttle; void -ip4_neighbor_probe_dst (const ip_adjacency_t * adj, const ip4_address_t * dst) +ip4_neighbor_probe_dst (u32 sw_if_index, const ip4_address_t * dst) { - ip_interface_address_t *ia; - ip4_address_t *src; + ip4_address_t src; + adj_index_t ai; - src = ip4_interface_address_matching_destination - (&ip4_main, - &adj->sub_type.nbr.next_hop.ip4, adj->rewrite_header.sw_if_index, &ia); - if (!src) - return; + /* any glean will do, it's just for the rewrite */ + ai = adj_glean_get (FIB_PROTOCOL_IP4, sw_if_index, NULL); - ip4_neighbor_probe (vlib_get_main (), vnet_get_main (), adj, src, dst); + if (ADJ_INDEX_INVALID != ai && fib_sas4_get (sw_if_index, dst, &src)) + ip4_neighbor_probe (vlib_get_main (), + vnet_get_main (), adj_get (ai), &src, dst); } void @@ -63,11 +67,12 @@ ip4_neighbor_advertise (vlib_main_t * vm, vnet_hw_interface_t *hi = vnet_get_sup_hw_interface (vnm, sw_if_index); ip4_main_t *i4m = &ip4_main; u8 *rewrite, rewrite_len; + ip4_address_t tmp; if (NULL == addr) { - ip4_main_t *i4m = &ip4_main; - addr = ip4_interface_first_address (i4m, sw_if_index, 0); + fib_sas4_get (sw_if_index, NULL, &tmp); + addr = &tmp; } if (addr) @@ -118,8 +123,6 @@ ip4_arp_inline (vlib_main_t * vm, vlib_frame_t * frame, int is_glean) { vnet_main_t *vnm = vnet_get_main (); - ip4_main_t *im = &ip4_main; - ip_lookup_main_t *lm = &im->lookup_main; u32 *from, *to_next_drop; uword n_left_from, n_left_to_next_drop, next_index; u32 thread_index = vm->thread_index; @@ -128,7 +131,7 @@ ip4_arp_inline (vlib_main_t * vm, if (node->flags & VLIB_NODE_FLAG_TRACE) ip4_forward_next_trace (vm, node, frame, VLIB_TX); - seed = throttle_seed (&im->arp_throttle, thread_index, vlib_time_now (vm)); + seed = throttle_seed (&arp_throttle, thread_index, vlib_time_now (vm)); from = vlib_frame_vector_args (frame); n_left_from = frame->n_vectors; @@ -167,14 +170,14 @@ ip4_arp_inline (vlib_main_t * vm, /* resolve the packet's destination */ ip4_header_t *ip0 = vlib_buffer_get_current (p0); resolve0 = ip0->dst_address; - src0 = adj0->sub_type.glean.receive_addr.ip4; + src0 = adj0->sub_type.glean.rx_pfx.fp_addr.ip4; } else { /* resolve the incomplete adj */ resolve0 = adj0->sub_type.nbr.next_hop.ip4; /* Src IP address in ARP header. */ - if (ip4_src_address_for_packet (lm, sw_if_index0, &src0)) + if (!fib_sas4_get (sw_if_index0, &resolve0, &src0)) { /* No source address available */ p0->error = node->errors[IP4_ARP_ERROR_NO_SOURCE_ADDRESS]; @@ -186,7 +189,7 @@ ip4_arp_inline (vlib_main_t * vm, r0 = (u64) resolve0.data_u32 << 32; r0 |= sw_if_index0; - if (throttle_check (&im->arp_throttle, thread_index, r0, seed)) + if (throttle_check (&arp_throttle, thread_index, r0, seed)) { p0->error = node->errors[IP4_ARP_ERROR_THROTTLED]; continue; @@ -310,6 +313,20 @@ arp_notrace_init (vlib_main_t * vm) VLIB_INIT_FUNCTION (arp_notrace_init); +static clib_error_t * +ip4_neighbor_main_loop_enter (vlib_main_t * vm) +{ + vlib_thread_main_t *tm = &vlib_thread_main; + u32 n_vlib_mains = tm->n_vlib_mains; + + throttle_init (&arp_throttle, n_vlib_mains, 1e-3); + + return (NULL); +} + +VLIB_MAIN_LOOP_ENTER_FUNCTION (ip4_neighbor_main_loop_enter); + + /* * fd.io coding-style-patch-verification: ON *