X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Fvxlan-gbp%2Fdecap.c;h=927c778b21191e333dd8ccd80b321ebc16b3cf61;hb=59f71132e;hp=7dc8d250f103123f83b5fd69157947fa4ad9c6f4;hpb=8feeaff56fa9a4fbdfc06131f28a1060ffd9645d;p=vpp.git diff --git a/src/vnet/vxlan-gbp/decap.c b/src/vnet/vxlan-gbp/decap.c index 7dc8d250f10..927c778b211 100644 --- a/src/vnet/vxlan-gbp/decap.c +++ b/src/vnet/vxlan-gbp/decap.c @@ -16,7 +16,7 @@ */ #include -#include + #include typedef struct @@ -76,9 +76,11 @@ vxlan4_gbp_find_tunnel (vxlan_gbp_main_t * vxm, last_tunnel_cache4 * cache, vxlan4_gbp_tunnel_key_t key4; int rv; - key4.key[1] = ((u64) fib_index << 32) | vxlan_gbp0->vni_reserved; - key4.key[0] = (((u64) ip4_0->dst_address.as_u32 << 32) | - ip4_0->src_address.as_u32); + key4.key[1] = (((u64) fib_index << 32) | + (vxlan_gbp0->vni_reserved & + clib_host_to_net_u32 (0xffffff00))); + key4.key[0] = + (((u64) ip4_0->dst_address.as_u32 << 32) | ip4_0->src_address.as_u32); if (PREDICT_FALSE (key4.key[0] != cache->key[0] || key4.key[1] != cache->key[1])) @@ -122,7 +124,9 @@ vxlan6_gbp_find_tunnel (vxlan_gbp_main_t * vxm, last_tunnel_cache6 * cache, .key = { [0] = ip6_0->src_address.as_u64[0], [1] = ip6_0->src_address.as_u64[1], - [2] = (((u64) fib_index) << 32) | vxlan_gbp0->vni_reserved, + [2] = ((((u64) fib_index) << 32) | + (vxlan_gbp0->vni_reserved & + clib_host_to_net_u32 (0xffffff00))), } }; int rv; @@ -293,13 +297,13 @@ vxlan_gbp_input (vlib_main_t * vm, vlib_buffer_advance (b0, sizeof *vxlan_gbp0); vlib_buffer_advance (b1, sizeof *vxlan_gbp1); + u8 i_and_g0 = ((flags0 & VXLAN_GBP_FLAGS_GI) == VXLAN_GBP_FLAGS_GI); + u8 i_and_g1 = ((flags1 & VXLAN_GBP_FLAGS_GI) == VXLAN_GBP_FLAGS_GI); + /* Validate VXLAN_GBP tunnel encap-fib index against packet */ - if (PREDICT_FALSE - (t0 == NULL - || flags0 != (VXLAN_GBP_FLAGS_I | VXLAN_GBP_FLAGS_G))) + if (PREDICT_FALSE (t0 == NULL || !i_and_g0)) { - if (t0 != NULL - && flags0 != (VXLAN_GBP_FLAGS_I | VXLAN_GBP_FLAGS_G)) + if (t0 != NULL && !i_and_g0) { error0 = VXLAN_GBP_ERROR_BAD_FLAGS; vlib_increment_combined_counter @@ -309,7 +313,13 @@ vxlan_gbp_input (vlib_main_t * vm, else { error0 = VXLAN_GBP_ERROR_NO_SUCH_TUNNEL; - next0 = VXLAN_GBP_INPUT_NEXT_NO_TUNNEL; + next0 = VXLAN_GBP_INPUT_NEXT_PUNT; + if (is_ip4) + b0->punt_reason = + vxm->punt_no_such_tunnel[FIB_PROTOCOL_IP4]; + else + b0->punt_reason = + vxm->punt_no_such_tunnel[FIB_PROTOCOL_IP6]; } b0->error = node->errors[error0]; } @@ -324,15 +334,14 @@ vxlan_gbp_input (vlib_main_t * vm, pkts_decapsulated++; } - vnet_buffer2 (b0)->gbp.flags = vxlan_gbp_get_gpflags (vxlan_gbp0); + vnet_buffer2 (b0)->gbp.flags = (vxlan_gbp_get_gpflags (vxlan_gbp0) | + VXLAN_GBP_GPFLAGS_R); vnet_buffer2 (b0)->gbp.sclass = vxlan_gbp_get_sclass (vxlan_gbp0); - if (PREDICT_FALSE - (t1 == 0 || flags1 != (VXLAN_GBP_FLAGS_I | VXLAN_GBP_FLAGS_G))) + if (PREDICT_FALSE (t1 == NULL || !i_and_g1)) { - if (t1 != 0 - && flags1 != (VXLAN_GBP_FLAGS_I | VXLAN_GBP_FLAGS_G)) + if (t1 != NULL && !i_and_g1) { error1 = VXLAN_GBP_ERROR_BAD_FLAGS; vlib_increment_combined_counter @@ -342,7 +351,13 @@ vxlan_gbp_input (vlib_main_t * vm, else { error1 = VXLAN_GBP_ERROR_NO_SUCH_TUNNEL; - next1 = VXLAN_GBP_INPUT_NEXT_NO_TUNNEL; + next1 = VXLAN_GBP_INPUT_NEXT_PUNT; + if (is_ip4) + b1->punt_reason = + vxm->punt_no_such_tunnel[FIB_PROTOCOL_IP4]; + else + b1->punt_reason = + vxm->punt_no_such_tunnel[FIB_PROTOCOL_IP6]; } b1->error = node->errors[error1]; } @@ -358,7 +373,9 @@ vxlan_gbp_input (vlib_main_t * vm, (rx_counter, thread_index, t1->sw_if_index, 1, len1); } - vnet_buffer2 (b1)->gbp.flags = vxlan_gbp_get_gpflags (vxlan_gbp1); + vnet_buffer2 (b1)->gbp.flags = (vxlan_gbp_get_gpflags (vxlan_gbp1) | + VXLAN_GBP_GPFLAGS_R); + vnet_buffer2 (b1)->gbp.sclass = vxlan_gbp_get_sclass (vxlan_gbp1); vnet_update_l2_len (b0); @@ -428,13 +445,13 @@ vxlan_gbp_input (vlib_main_t * vm, /* pop (ip, udp, vxlan_gbp) */ vlib_buffer_advance (b0, sizeof (*vxlan_gbp0)); + + u8 i_and_g0 = ((flags0 & VXLAN_GBP_FLAGS_GI) == VXLAN_GBP_FLAGS_GI); + /* Validate VXLAN_GBP tunnel encap-fib index against packet */ - if (PREDICT_FALSE - (t0 == NULL - || flags0 != (VXLAN_GBP_FLAGS_I | VXLAN_GBP_FLAGS_G))) + if (PREDICT_FALSE (t0 == NULL || !i_and_g0)) { - if (t0 != NULL - && flags0 != (VXLAN_GBP_FLAGS_I | VXLAN_GBP_FLAGS_G)) + if (t0 != NULL && !i_and_g0) { error0 = VXLAN_GBP_ERROR_BAD_FLAGS; vlib_increment_combined_counter @@ -444,7 +461,13 @@ vxlan_gbp_input (vlib_main_t * vm, else { error0 = VXLAN_GBP_ERROR_NO_SUCH_TUNNEL; - next0 = VXLAN_GBP_INPUT_NEXT_NO_TUNNEL; + next0 = VXLAN_GBP_INPUT_NEXT_PUNT; + if (is_ip4) + b0->punt_reason = + vxm->punt_no_such_tunnel[FIB_PROTOCOL_IP4]; + else + b0->punt_reason = + vxm->punt_no_such_tunnel[FIB_PROTOCOL_IP6]; } b0->error = node->errors[error0]; } @@ -458,7 +481,9 @@ vxlan_gbp_input (vlib_main_t * vm, vlib_increment_combined_counter (rx_counter, thread_index, t0->sw_if_index, 1, len0); } - vnet_buffer2 (b0)->gbp.flags = vxlan_gbp_get_gpflags (vxlan_gbp0); + vnet_buffer2 (b0)->gbp.flags = (vxlan_gbp_get_gpflags (vxlan_gbp0) | + VXLAN_GBP_GPFLAGS_R); + vnet_buffer2 (b0)->gbp.sclass = vxlan_gbp_get_sclass (vxlan_gbp0); /* Required to make the l2 tag push / pop code work on l2 subifs */