diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/gtpu/test/test_gtpu.py | 5 | ||||
-rw-r--r-- | src/vnet/geneve/decap.c | 76 | ||||
-rw-r--r-- | src/vnet/geneve/geneve.c | 23 | ||||
-rw-r--r-- | src/vnet/geneve/geneve_packet.h | 13 |
4 files changed, 48 insertions, 69 deletions
diff --git a/src/plugins/gtpu/test/test_gtpu.py b/src/plugins/gtpu/test/test_gtpu.py index 667d61c0143..00f641c0088 100644 --- a/src/plugins/gtpu/test/test_gtpu.py +++ b/src/plugins/gtpu/test/test_gtpu.py @@ -187,7 +187,7 @@ class TestGtpu(BridgeDomain, VppTestCase): # Pick first received frame and check if it's correctly encapsulated. out = self.pg0.get_capture(1) pkt = out[0] - self.check_encapsulation(pkt, self.single_tunnel_bd) + self.check_encapsulation(pkt, self.single_tunnel_vni) # payload = self.decapsulate(pkt) # self.assert_eq_pkts(payload, self.frame_reply) @@ -343,13 +343,14 @@ class TestGtpu(BridgeDomain, VppTestCase): # Create GTPU VTEP on VPP pg0, and put gtpu_tunnel0 and pg1 # into BD. cls.single_tunnel_bd = 11 + cls.single_tunnel_vni = 11 r = cls.vapi.gtpu_add_del_tunnel( is_add=True, mcast_sw_if_index=0xFFFFFFFF, decap_next_index=0xFFFFFFFF, src_address=cls.pg0.local_ip4, dst_address=cls.pg0.remote_ip4, - teid=cls.single_tunnel_bd) + teid=cls.single_tunnel_vni) cls.vapi.sw_interface_set_l2_bridge(rx_sw_if_index=r.sw_if_index, bd_id=cls.single_tunnel_bd) cls.vapi.sw_interface_set_l2_bridge( diff --git a/src/vnet/geneve/decap.c b/src/vnet/geneve/decap.c index e30a56c0327..7914ef66005 100644 --- a/src/vnet/geneve/decap.c +++ b/src/vnet/geneve/decap.c @@ -213,7 +213,7 @@ geneve_input (vlib_main_t * vm, if (is_ip4) { key4_0.remote = ip4_0->src_address.as_u32; - key4_0.vni = vnet_get_geneve_vni_bigendian (geneve0); + key4_0.vni = vnet_get_geneve_vni_network_order (geneve0); /* Make sure GENEVE tunnel exist according to packet SIP and VNI */ if (PREDICT_FALSE (key4_0.as_u64 != last_key4.as_u64)) @@ -248,7 +248,7 @@ geneve_input (vlib_main_t * vm, (ip4_address_is_multicast (&ip4_0->dst_address))) { key4_0.remote = ip4_0->dst_address.as_u32; - key4_0.vni = vnet_get_geneve_vni_bigendian (geneve0); + key4_0.vni = vnet_get_geneve_vni_network_order (geneve0); /* Make sure mcast GENEVE tunnel exist by packet DIP and VNI */ p0 = hash_get (vxm->geneve4_tunnel_by_key, key4_0.as_u64); if (PREDICT_TRUE (p0 != NULL)) @@ -266,7 +266,7 @@ geneve_input (vlib_main_t * vm, { key6_0.remote.as_u64[0] = ip6_0->src_address.as_u64[0]; key6_0.remote.as_u64[1] = ip6_0->src_address.as_u64[1]; - key6_0.vni = vnet_get_geneve_vni_bigendian (geneve0); + key6_0.vni = vnet_get_geneve_vni_network_order (geneve0); /* Make sure GENEVE tunnel exist according to packet SIP and VNI */ if (PREDICT_FALSE @@ -303,7 +303,7 @@ geneve_input (vlib_main_t * vm, { key6_0.remote.as_u64[0] = ip6_0->dst_address.as_u64[0]; key6_0.remote.as_u64[1] = ip6_0->dst_address.as_u64[1]; - key6_0.vni = vnet_get_geneve_vni_bigendian (geneve0); + key6_0.vni = vnet_get_geneve_vni_network_order (geneve0); p0 = hash_get_mem (vxm->geneve6_tunnel_by_key, &key6_0); if (PREDICT_TRUE (p0 != NULL)) { @@ -380,7 +380,7 @@ geneve_input (vlib_main_t * vm, if (is_ip4) { key4_1.remote = ip4_1->src_address.as_u32; - key4_1.vni = vnet_get_geneve_vni_bigendian (geneve1); + key4_1.vni = vnet_get_geneve_vni_network_order (geneve1); /* Make sure unicast GENEVE tunnel exist by packet SIP and VNI */ if (PREDICT_FALSE (key4_1.as_u64 != last_key4.as_u64)) @@ -415,7 +415,7 @@ geneve_input (vlib_main_t * vm, (ip4_address_is_multicast (&ip4_1->dst_address))) { key4_1.remote = ip4_1->dst_address.as_u32; - key4_1.vni = vnet_get_geneve_vni_bigendian (geneve1); + key4_1.vni = vnet_get_geneve_vni_network_order (geneve1); /* Make sure mcast GENEVE tunnel exist by packet DIP and VNI */ p1 = hash_get (vxm->geneve4_tunnel_by_key, key4_1.as_u64); if (PREDICT_TRUE (p1 != NULL)) @@ -433,7 +433,7 @@ geneve_input (vlib_main_t * vm, { key6_1.remote.as_u64[0] = ip6_1->src_address.as_u64[0]; key6_1.remote.as_u64[1] = ip6_1->src_address.as_u64[1]; - key6_1.vni = vnet_get_geneve_vni_bigendian (geneve1); + key6_1.vni = vnet_get_geneve_vni_network_order (geneve1); /* Make sure GENEVE tunnel exist according to packet SIP and VNI */ if (PREDICT_FALSE @@ -472,7 +472,7 @@ geneve_input (vlib_main_t * vm, { key6_1.remote.as_u64[0] = ip6_1->dst_address.as_u64[0]; key6_1.remote.as_u64[1] = ip6_1->dst_address.as_u64[1]; - key6_1.vni = vnet_get_geneve_vni_bigendian (geneve1); + key6_1.vni = vnet_get_geneve_vni_network_order (geneve1); p1 = hash_get_mem (vxm->geneve6_tunnel_by_key, &key6_1); if (PREDICT_TRUE (p1 != NULL)) { @@ -618,7 +618,7 @@ geneve_input (vlib_main_t * vm, if (is_ip4) { key4_0.remote = ip4_0->src_address.as_u32; - key4_0.vni = vnet_get_geneve_vni_bigendian (geneve0); + key4_0.vni = vnet_get_geneve_vni_network_order (geneve0); /* Make sure unicast GENEVE tunnel exist by packet SIP and VNI */ if (PREDICT_FALSE (key4_0.as_u64 != last_key4.as_u64)) @@ -653,7 +653,7 @@ geneve_input (vlib_main_t * vm, (ip4_address_is_multicast (&ip4_0->dst_address))) { key4_0.remote = ip4_0->dst_address.as_u32; - key4_0.vni = vnet_get_geneve_vni_bigendian (geneve0); + key4_0.vni = vnet_get_geneve_vni_network_order (geneve0); /* Make sure mcast GENEVE tunnel exist by packet DIP and VNI */ p0 = hash_get (vxm->geneve4_tunnel_by_key, key4_0.as_u64); if (PREDICT_TRUE (p0 != NULL)) @@ -671,7 +671,7 @@ geneve_input (vlib_main_t * vm, { key6_0.remote.as_u64[0] = ip6_0->src_address.as_u64[0]; key6_0.remote.as_u64[1] = ip6_0->src_address.as_u64[1]; - key6_0.vni = vnet_get_geneve_vni_bigendian (geneve0); + key6_0.vni = vnet_get_geneve_vni_network_order (geneve0); /* Make sure GENEVE tunnel exist according to packet SIP and VNI */ if (PREDICT_FALSE @@ -708,7 +708,7 @@ geneve_input (vlib_main_t * vm, { key6_0.remote.as_u64[0] = ip6_0->dst_address.as_u64[0]; key6_0.remote.as_u64[1] = ip6_0->dst_address.as_u64[1]; - key6_0.vni = vnet_get_geneve_vni_bigendian (geneve0); + key6_0.vni = vnet_get_geneve_vni_network_order (geneve0); p0 = hash_get_mem (vxm->geneve6_tunnel_by_key, &key6_0); if (PREDICT_TRUE (p0 != NULL)) { @@ -1262,24 +1262,17 @@ VLIB_NODE_FN (ip4_geneve_bypass_node) (vlib_main_t * vm, /* *INDENT-OFF* */ VLIB_REGISTER_NODE (ip4_geneve_bypass_node) = { - .name = "ip4-geneve-bypass",.vector_size = - sizeof (u32),.n_next_nodes = IP_GENEVE_BYPASS_N_NEXT,.next_nodes = + .name = "ip4-geneve-bypass", + .vector_size = sizeof (u32), + .n_next_nodes = IP_GENEVE_BYPASS_N_NEXT,.next_nodes = { - [IP_GENEVE_BYPASS_NEXT_DROP] = "error-drop", - [IP_GENEVE_BYPASS_NEXT_GENEVE] = "geneve4-input",} -,.format_buffer = format_ip4_header,.format_trace = - format_ip4_forward_next_trace,}; - -#ifndef CLIB_MARCH_VARIANT -/* Dummy init function to get us linked in. */ - clib_error_t *ip4_geneve_bypass_init (vlib_main_t * vm) -{ - return 0; -} - -VLIB_INIT_FUNCTION (ip4_geneve_bypass_init); + [IP_GENEVE_BYPASS_NEXT_DROP] = "error-drop", + [IP_GENEVE_BYPASS_NEXT_GENEVE] = "geneve4-input", + }, + .format_buffer = format_ip4_header, + .format_trace = format_ip4_forward_next_trace, +}; /* *INDENT-ON* */ -#endif /* CLIB_MARCH_VARIANT */ VLIB_NODE_FN (ip6_geneve_bypass_node) (vlib_main_t * vm, vlib_node_runtime_t * node, @@ -1291,26 +1284,19 @@ VLIB_NODE_FN (ip6_geneve_bypass_node) (vlib_main_t * vm, /* *INDENT-OFF* */ VLIB_REGISTER_NODE (ip6_geneve_bypass_node) = { - .name = "ip6-geneve-bypass",.vector_size = - sizeof (u32),.n_next_nodes = IP_GENEVE_BYPASS_N_NEXT,.next_nodes = + .name = "ip6-geneve-bypass", + .vector_size = sizeof (u32), + .n_next_nodes = IP_GENEVE_BYPASS_N_NEXT, + .next_nodes = { - [IP_GENEVE_BYPASS_NEXT_DROP] = "error-drop", - [IP_GENEVE_BYPASS_NEXT_GENEVE] = "geneve6-input",} -,.format_buffer = format_ip6_header,.format_trace = - format_ip6_forward_next_trace,}; + [IP_GENEVE_BYPASS_NEXT_DROP] = "error-drop", + [IP_GENEVE_BYPASS_NEXT_GENEVE] = "geneve6-input", + }, + .format_buffer = format_ip6_header, + .format_trace = format_ip6_forward_next_trace, +}; /* *INDENT-ON* */ -#ifndef CLIB_MARCH_VARIANT -/* Dummy init function to get us linked in. */ -clib_error_t * -ip6_geneve_bypass_init (vlib_main_t * vm) -{ - return 0; -} - -VLIB_INIT_FUNCTION (ip6_geneve_bypass_init); -#endif /* CLIB_MARCH_VARIANT */ - /* * fd.io coding-style-patch-verification: ON * diff --git a/src/vnet/geneve/geneve.c b/src/vnet/geneve/geneve.c index 0c551a0545e..f04917a71a4 100644 --- a/src/vnet/geneve/geneve.c +++ b/src/vnet/geneve/geneve.c @@ -321,14 +321,15 @@ vtep_addr_unref (ip46_address_t * ip) return 0; } -typedef CLIB_PACKED (union - { - struct - { - fib_node_index_t mfib_entry_index; - adj_index_t mcast_adj_index; - }; u64 as_u64; - }) mcast_shared_t; +typedef union +{ + struct + { + fib_node_index_t mfib_entry_index; + adj_index_t mcast_adj_index; + }; + u64 as_u64; +} __clib_packed mcast_shared_t; static inline mcast_shared_t mcast_shared_get (ip46_address_t * ip) @@ -381,15 +382,13 @@ int vnet_geneve_add_del_tunnel if (!is_ip6) { key4.remote = a->remote.ip4.as_u32; - key4.vni = - clib_host_to_net_u32 ((a->vni << GENEVE_VNI_SHIFT) & GENEVE_VNI_MASK); + key4.vni = clib_host_to_net_u32 (a->vni << GENEVE_VNI_SHIFT); p = hash_get (vxm->geneve4_tunnel_by_key, key4.as_u64); } else { key6.remote = a->remote.ip6; - key6.vni = - clib_host_to_net_u32 ((a->vni << GENEVE_VNI_SHIFT) & GENEVE_VNI_MASK); + key6.vni = clib_host_to_net_u32 (a->vni << GENEVE_VNI_SHIFT); p = hash_get_mem (vxm->geneve6_tunnel_by_key, &key6); } diff --git a/src/vnet/geneve/geneve_packet.h b/src/vnet/geneve/geneve_packet.h index ab37f5378df..a0d0687434c 100644 --- a/src/vnet/geneve/geneve_packet.h +++ b/src/vnet/geneve/geneve_packet.h @@ -137,21 +137,14 @@ typedef struct static inline u32 vnet_get_geneve_vni (geneve_header_t * h) { - return (clib_net_to_host_u32 (h->vni_rsvd & GENEVE_VNI_MASK) >> + return ((clib_net_to_host_u32 (h->vni_rsvd) & GENEVE_VNI_MASK) >> GENEVE_VNI_SHIFT); } -/* - * Return the VNI in network-byte order - * - * To be used in the DECAP phase to create the lookup key (IP + VNI) - */ static inline u32 -vnet_get_geneve_vni_bigendian (geneve_header_t * h) +vnet_get_geneve_vni_network_order (geneve_header_t * h) { - u32 vni_host = vnet_get_geneve_vni (h); - return clib_host_to_net_u32 ((vni_host << GENEVE_VNI_SHIFT) & - GENEVE_VNI_MASK); + return (h->vni_rsvd & clib_net_to_host_u32 (GENEVE_VNI_MASK)); } static inline void |