X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Fip%2Fip4_forward.c;h=f523ae63ba30faf99b74d43de9d802f85e528b63;hb=775f73c;hp=9911eb71b99bf90b8c602fa2cd6460995c992b2f;hpb=a71844f27a0be91fcda25b19604d16122ccc3e73;p=vpp.git diff --git a/src/vnet/ip/ip4_forward.c b/src/vnet/ip/ip4_forward.c index 9911eb71b99..f523ae63ba3 100644 --- a/src/vnet/ip/ip4_forward.c +++ b/src/vnet/ip/ip4_forward.c @@ -711,6 +711,7 @@ VNET_FEATURE_ARC_INIT (ip4_unicast, static) = { .arc_name = "ip4-unicast", .start_nodes = VNET_FEATURES ("ip4-input", "ip4-input-no-checksum"), + .last_in_arc = "ip4-lookup", .arc_index_ptr = &ip4_main.lookup_main.ucast_feature_arc_index, }; @@ -753,13 +754,13 @@ VNET_FEATURE_INIT (ip4_policer_classify, static) = { .arc_name = "ip4-unicast", .node_name = "ip4-policer-classify", - .runs_before = VNET_FEATURES ("ipsec4-input"), + .runs_before = VNET_FEATURES ("ipsec4-input-feature"), }; VNET_FEATURE_INIT (ip4_ipsec, static) = { .arc_name = "ip4-unicast", - .node_name = "ipsec4-input", + .node_name = "ipsec4-input-feature", .runs_before = VNET_FEATURES ("vpath-input-ip4"), }; @@ -796,6 +797,7 @@ VNET_FEATURE_ARC_INIT (ip4_multicast, static) = { .arc_name = "ip4-multicast", .start_nodes = VNET_FEATURES ("ip4-input", "ip4-input-no-checksum"), + .last_in_arc = "ip4-mfib-forward-lookup", .arc_index_ptr = &ip4_main.lookup_main.mcast_feature_arc_index, }; @@ -825,6 +827,7 @@ VNET_FEATURE_ARC_INIT (ip4_output, static) = { .arc_name = "ip4-output", .start_nodes = VNET_FEATURES ("ip4-rewrite", "ip4-midchain", "ip4-dvr-dpo"), + .last_in_arc = "interface-output", .arc_index_ptr = &ip4_main.lookup_main.output_feature_arc_index, }; @@ -839,13 +842,13 @@ VNET_FEATURE_INIT (ip4_outacl, static) = { .arc_name = "ip4-output", .node_name = "ip4-outacl", - .runs_before = VNET_FEATURES ("ipsec4-output"), + .runs_before = VNET_FEATURES ("ipsec4-output-feature"), }; VNET_FEATURE_INIT (ip4_ipsec_output, static) = { .arc_name = "ip4-output", - .node_name = "ipsec4-output", + .node_name = "ipsec4-output-feature", .runs_before = VNET_FEATURES ("interface-output"), }; @@ -1072,9 +1075,9 @@ ip4_forward_next_trace (vlib_main_t * vm, vec_elt (im->fib_index_by_sw_if_index, vnet_buffer (b0)->sw_if_index[VLIB_RX]); - clib_memcpy (t0->packet_data, - vlib_buffer_get_current (b0), - sizeof (t0->packet_data)); + clib_memcpy_fast (t0->packet_data, + vlib_buffer_get_current (b0), + sizeof (t0->packet_data)); } if (b1->flags & VLIB_BUFFER_IS_TRACED) { @@ -1086,8 +1089,8 @@ ip4_forward_next_trace (vlib_main_t * vm, (u32) ~ 0) ? vnet_buffer (b1)->sw_if_index[VLIB_TX] : vec_elt (im->fib_index_by_sw_if_index, vnet_buffer (b1)->sw_if_index[VLIB_RX]); - clib_memcpy (t1->packet_data, vlib_buffer_get_current (b1), - sizeof (t1->packet_data)); + clib_memcpy_fast (t1->packet_data, vlib_buffer_get_current (b1), + sizeof (t1->packet_data)); } from += 2; n_left -= 2; @@ -1113,8 +1116,8 @@ ip4_forward_next_trace (vlib_main_t * vm, (u32) ~ 0) ? vnet_buffer (b0)->sw_if_index[VLIB_TX] : vec_elt (im->fib_index_by_sw_if_index, vnet_buffer (b0)->sw_if_index[VLIB_RX]); - clib_memcpy (t0->packet_data, vlib_buffer_get_current (b0), - sizeof (t0->packet_data)); + clib_memcpy_fast (t0->packet_data, vlib_buffer_get_current (b0), + sizeof (t0->packet_data)); } from += 1; n_left -= 1; @@ -1212,6 +1215,7 @@ VNET_FEATURE_ARC_INIT (ip4_local) = { .arc_name = "ip4-local", .start_nodes = VNET_FEATURES ("ip4-local"), + .last_in_arc = "ip4-local-end-of-arc", }; /* *INDENT-ON* */ @@ -1330,6 +1334,7 @@ typedef struct ip4_address_t src; u32 lbi; u8 error; + u8 first; } ip4_local_last_check_t; static inline void @@ -1346,7 +1351,8 @@ ip4_local_check_src (vlib_buffer_t * b, ip4_header_t * ip0, vnet_buffer (b)->sw_if_index[VLIB_TX] != ~0 ? vnet_buffer (b)->sw_if_index[VLIB_TX] : vnet_buffer (b)->ip.fib_index; - if (PREDICT_FALSE (last_check->src.as_u32 != ip0->src_address.as_u32)) + if (PREDICT_FALSE (last_check->first || + (last_check->src.as_u32 != ip0->src_address.as_u32))) { mtrie0 = &ip4_fib_get (vnet_buffer (b)->ip.fib_index)->mtrie; leaf0 = ip4_fib_mtrie_lookup_step_one (mtrie0, &ip0->src_address); @@ -1388,6 +1394,7 @@ ip4_local_check_src (vlib_buffer_t * b, ip4_header_t * ip0, vnet_buffer (b)->ip.adj_index[VLIB_TX] = last_check->lbi; vnet_buffer (b)->ip.adj_index[VLIB_RX] = last_check->lbi; *error0 = last_check->error; + last_check->first = 0; } } @@ -1399,9 +1406,10 @@ ip4_local_check_src_x2 (vlib_buffer_t ** b, ip4_header_t ** ip, ip4_fib_mtrie_t *mtrie[2]; const dpo_id_t *dpo[2]; load_balance_t *lb[2]; - u32 not_last_hit = 0; + u32 not_last_hit; u32 lbi[2]; + not_last_hit = last_check->first; not_last_hit |= ip[0]->src_address.as_u32 ^ last_check->src.as_u32; not_last_hit |= ip[1]->src_address.as_u32 ^ last_check->src.as_u32; @@ -1478,6 +1486,7 @@ ip4_local_check_src_x2 (vlib_buffer_t ** b, ip4_header_t ** ip, error[0] = last_check->error; error[1] = last_check->error; + last_check->first = 0; } } @@ -1528,9 +1537,16 @@ ip4_local_inline (vlib_main_t * vm, u8 error[2], pt[2]; ip4_local_last_check_t last_check = { + /* + * 0.0.0.0 can appear as the source address of an IP packet, + * as can any other address, hence the need to use the 'first' + * member to make sure the .lbi is initialised for the first + * packet. + */ .src = {.as_u32 = 0}, .lbi = ~0, - .error = IP4_ERROR_UNKNOWN_PROTOCOL + .error = IP4_ERROR_UNKNOWN_PROTOCOL, + .first = 1, }; from = vlib_frame_vector_args (frame); @@ -1852,9 +1868,9 @@ 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 (h0->ip4_over_ethernet[0].ethernet, - hw_if0->hw_address, - sizeof (h0->ip4_over_ethernet[0].ethernet)); + clib_memcpy_fast (h0->ip4_over_ethernet[0].ethernet, + hw_if0->hw_address, + sizeof (h0->ip4_over_ethernet[0].ethernet)); if (is_glean) { /* The interface's source address is stashed in the Glean Adj */ @@ -2027,8 +2043,8 @@ ip4_probe_neighbor (vlib_main_t * vm, ip4_address_t * dst, u32 sw_if_index, sw_if_index); } - clib_memcpy (h->ip4_over_ethernet[0].ethernet, hi->hw_address, - sizeof (h->ip4_over_ethernet[0].ethernet)); + clib_memcpy_fast (h->ip4_over_ethernet[0].ethernet, hi->hw_address, + sizeof (h->ip4_over_ethernet[0].ethernet)); h->ip4_over_ethernet[0].ip4 = src[0]; h->ip4_over_ethernet[1].ip4 = dst[0]; @@ -2193,7 +2209,7 @@ ip4_rewrite_inline (vlib_main_t * vm, if (n_left_from >= 6) { int i; - for (i = 0; i < 6; i++) + for (i = 2; i < 6; i++) vlib_prefetch_buffer_header (bufs[i], LOAD); } @@ -2332,7 +2348,7 @@ ip4_rewrite_inline (vlib_main_t * vm, adj0->sub_type.midchain.fixup_func (vm, adj0, b[0], adj0->sub_type.midchain.fixup_data); adj1->sub_type.midchain.fixup_func - (vm, adj1, b[1], adj0->sub_type.midchain.fixup_data); + (vm, adj1, b[1], adj1->sub_type.midchain.fixup_data); } if (is_mcast) @@ -2344,7 +2360,7 @@ ip4_rewrite_inline (vlib_main_t * vm, adj0->rewrite_header.dst_mcast_offset, &ip0->dst_address.as_u32, (u8 *) ip0); vnet_ip_mcast_fixup_header (IP4_MCAST_ADDR_MASK, - adj0->rewrite_header.dst_mcast_offset, + adj1->rewrite_header.dst_mcast_offset, &ip1->dst_address.as_u32, (u8 *) ip1); }