summaryrefslogtreecommitdiffstats
path: root/src/vnet/geneve
diff options
context:
space:
mode:
Diffstat (limited to 'src/vnet/geneve')
-rw-r--r--src/vnet/geneve/decap.c76
-rw-r--r--src/vnet/geneve/geneve.c23
-rw-r--r--src/vnet/geneve/geneve_packet.h13
3 files changed, 45 insertions, 67 deletions
diff --git a/src/vnet/geneve/decap.c b/src/vnet/geneve/decap.c
index a04c1d41e90..10a17cef35d 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))
{
@@ -1240,24 +1240,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,
@@ -1269,26 +1262,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 52664b389a4..1e04c662431 100644
--- a/src/vnet/geneve/geneve.c
+++ b/src/vnet/geneve/geneve.c
@@ -292,14 +292,15 @@ geneve_decap_next_is_valid (geneve_main_t * vxm, u32 is_ip6,
return decap_next_index < r->n_next_nodes;
}
-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)
@@ -352,15 +353,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