summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Loeliger <jdl@netgate.com>2019-01-03 12:56:02 -0600
committerJohn Lo <loj@cisco.com>2019-01-09 04:13:15 +0000
commite3034cdc74f9fe153259a55c03846495d3f9f088 (patch)
treed24cdf96937d623dbcff3749f67bb770f1e86b97
parent95eec06e9d2b552593c35c42455edc494565759a (diff)
VXLAN: Prevent duplicate bypass graph nodes.
Change-Id: I68cc509b594b09751ff5e0e09bbca187a4a88edd Signed-off-by: Jon Loeliger <jdl@netgate.com>
-rw-r--r--src/vnet/vxlan/vxlan.c37
-rw-r--r--src/vnet/vxlan/vxlan.h4
2 files changed, 37 insertions, 4 deletions
diff --git a/src/vnet/vxlan/vxlan.c b/src/vnet/vxlan/vxlan.c
index a26428673c5..ff796ec0673 100644
--- a/src/vnet/vxlan/vxlan.c
+++ b/src/vnet/vxlan/vxlan.c
@@ -919,12 +919,38 @@ VLIB_CLI_COMMAND (show_vxlan_tunnel_command, static) = {
void
vnet_int_vxlan_bypass_mode (u32 sw_if_index, u8 is_ip6, u8 is_enable)
{
+ vxlan_main_t *vxm = &vxlan_main;
+
+ if (pool_is_free_index (vxm->vnet_main->interface_main.sw_interfaces,
+ sw_if_index))
+ return;
+
+ is_enable = ! !is_enable;
+
if (is_ip6)
- vnet_feature_enable_disable ("ip6-unicast", "ip6-vxlan-bypass",
- sw_if_index, is_enable, 0, 0);
+ {
+ if (clib_bitmap_get (vxm->bm_ip6_bypass_enabled_by_sw_if, sw_if_index)
+ != is_enable)
+ {
+ vnet_feature_enable_disable ("ip6-unicast", "ip6-vxlan-bypass",
+ sw_if_index, is_enable, 0, 0);
+ vxm->bm_ip6_bypass_enabled_by_sw_if =
+ clib_bitmap_set (vxm->bm_ip6_bypass_enabled_by_sw_if,
+ sw_if_index, is_enable);
+ }
+ }
else
- vnet_feature_enable_disable ("ip4-unicast", "ip4-vxlan-bypass",
- sw_if_index, is_enable, 0, 0);
+ {
+ if (clib_bitmap_get (vxm->bm_ip4_bypass_enabled_by_sw_if, sw_if_index)
+ != is_enable)
+ {
+ vnet_feature_enable_disable ("ip4-unicast", "ip4-vxlan-bypass",
+ sw_if_index, is_enable, 0, 0);
+ vxm->bm_ip4_bypass_enabled_by_sw_if =
+ clib_bitmap_set (vxm->bm_ip4_bypass_enabled_by_sw_if,
+ sw_if_index, is_enable);
+ }
+ }
}
@@ -1216,6 +1242,9 @@ vxlan_init (vlib_main_t * vm)
vnet_flow_get_range (vxm->vnet_main, "vxlan", 1024 * 1024,
&vxm->flow_id_start);
+ vxm->bm_ip4_bypass_enabled_by_sw_if = 0;
+ vxm->bm_ip6_bypass_enabled_by_sw_if = 0;
+
/* initialize the ip6 hash */
clib_bihash_init_16_8 (&vxm->vxlan4_tunnel_by_key, "vxlan4",
VXLAN_HASH_NUM_BUCKETS, VXLAN_HASH_MEMORY_SIZE);
diff --git a/src/vnet/vxlan/vxlan.h b/src/vnet/vxlan/vxlan.h
index 73052278a48..7ade7c009cd 100644
--- a/src/vnet/vxlan/vxlan.h
+++ b/src/vnet/vxlan/vxlan.h
@@ -172,6 +172,10 @@ typedef struct
/* Mapping from sw_if_index to tunnel index */
u32 *tunnel_index_by_sw_if_index;
+ /* graph node state */
+ uword *bm_ip4_bypass_enabled_by_sw_if;
+ uword *bm_ip6_bypass_enabled_by_sw_if;
+
/* convenience */
vlib_main_t *vlib_main;
vnet_main_t *vnet_main;