aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/vnet/l2/l2.api2
-rw-r--r--src/vnet/l2/l2_api.c8
-rw-r--r--src/vnet/l2/l2_bd.c53
-rw-r--r--src/vnet/l2/l2_bd.h5
4 files changed, 66 insertions, 2 deletions
diff --git a/src/vnet/l2/l2.api b/src/vnet/l2/l2.api
index 9f97ebbe2ca..baf830fae3b 100644
--- a/src/vnet/l2/l2.api
+++ b/src/vnet/l2/l2.api
@@ -249,6 +249,7 @@ autoreply define bridge_domain_add_del
u8 learn;
u8 arp_term;
u8 mac_age;
+ u8 bd_tag[64];
u8 is_add;
};
@@ -296,6 +297,7 @@ manual_print manual_endian define bridge_domain_details
u8 learn;
u8 arp_term;
u8 mac_age;
+ u8 bd_tag[64];
u32 bvi_sw_if_index;
u32 n_sw_ifs;
vl_api_bridge_domain_sw_if_t sw_if_details[n_sw_ifs];
diff --git a/src/vnet/l2/l2_api.c b/src/vnet/l2/l2_api.c
index 989081fb4e2..20d6ab32fad 100644
--- a/src/vnet/l2/l2_api.c
+++ b/src/vnet/l2/l2_api.c
@@ -420,6 +420,7 @@ vl_api_bridge_domain_add_del_t_handler (vl_api_bridge_domain_add_del_t * mp)
.arp_term = mp->arp_term,
.mac_age = mp->mac_age,
.bd_id = ntohl (mp->bd_id),
+ .bd_tag = mp->bd_tag
};
int rv = bd_add_del (&a);
@@ -451,6 +452,13 @@ send_bridge_domain_details (l2input_main_t * l2im,
mp->arp_term = bd_feature_arp_term (bd_config);
mp->bvi_sw_if_index = ntohl (bd_config->bvi_sw_if_index);
mp->mac_age = bd_config->mac_age;
+ if (bd_config->bd_tag)
+ {
+ strncpy ((char *) mp->bd_tag, (char *) bd_config->bd_tag,
+ ARRAY_LEN (mp->bd_tag) - 1);
+ mp->bd_tag[ARRAY_LEN (mp->bd_tag) - 1] = 0;
+ }
+
mp->context = context;
sw_ifs = (vl_api_bridge_domain_sw_if_t *) mp->sw_if_details;
diff --git a/src/vnet/l2/l2_bd.c b/src/vnet/l2/l2_bd.c
index 6e0db058e31..3670a4f0db4 100644
--- a/src/vnet/l2/l2_bd.c
+++ b/src/vnet/l2/l2_bd.c
@@ -108,6 +108,9 @@ bd_delete (bd_main_t * bdm, u32 bd_index)
bd->bd_id = ~0;
bd->feature_bitmap = 0;
+ /* free BD tag */
+ vec_free (bd->bd_tag);
+
/* free memory used by BD */
vec_free (bd->members);
hash_free (bd->mac_by_ip4);
@@ -288,6 +291,29 @@ bd_set_mac_age (vlib_main_t * vm, u32 bd_index, u8 age)
L2_MAC_AGE_PROCESS_EVENT_STOP, 0);
}
+
+void
+bd_set_bd_tag (vlib_main_t * vm, u32 bd_index, u8 * bd_tag)
+{
+ u8 *old;
+ l2_bridge_domain_t *bd_config;
+ vec_validate (l2input_main.bd_configs, bd_index);
+ bd_config = vec_elt_at_index (l2input_main.bd_configs, bd_index);
+
+ old = bd_config->bd_tag;
+
+ if (bd_tag[0])
+ {
+ bd_config->bd_tag = format (0, "%s%c", bd_tag, 0);
+ }
+ else
+ {
+ bd_config->bd_tag = NULL;
+ }
+
+ vec_free (old);
+}
+
/**
Set bridge-domain learn enable/disable.
The CLI format is:
@@ -906,6 +932,7 @@ bd_show (vlib_main_t * vm, unformat_input_t * input, vlib_cli_command_t * cmd)
u32 detail = 0;
u32 intf = 0;
u32 arp = 0;
+ u32 bd_tag = 0;
u32 bd_id = ~0;
uword *p;
@@ -922,6 +949,8 @@ bd_show (vlib_main_t * vm, unformat_input_t * input, vlib_cli_command_t * cmd)
intf = 1;
if (unformat (input, "arp"))
arp = 1;
+ if (unformat (input, "bd-tag"))
+ bd_tag = 1;
if (bd_id == 0)
return clib_error_return (0,
@@ -1039,6 +1068,12 @@ bd_show (vlib_main_t * vm, unformat_input_t * input, vlib_cli_command_t * cmd)
}));
/* *INDENT-ON* */
}
+
+ if ((detail || bd_tag) && (bd_config->bd_tag))
+ {
+ vlib_cli_output (vm, "\n BD-Tag: %s", bd_config->bd_tag);
+
+ }
}
}
vec_free (as);
@@ -1080,7 +1115,7 @@ done:
/* *INDENT-OFF* */
VLIB_CLI_COMMAND (bd_show_cli, static) = {
.path = "show bridge-domain",
- .short_help = "show bridge-domain [bridge-domain-id [detail|int|arp]]",
+ .short_help = "show bridge-domain [bridge-domain-id [detail|int|arp|bd-tag]]",
.function = bd_show,
};
/* *INDENT-ON* */
@@ -1134,6 +1169,10 @@ bd_add_del (l2_bridge_domain_add_del_args_t * a)
bd_set_flags (vm, bd_index, disable_flags, 0 /* disable */ );
bd_set_mac_age (vm, bd_index, a->mac_age);
+
+ if (a->bd_tag)
+ bd_set_bd_tag (vm, bd_index, a->bd_tag);
+
}
else
{
@@ -1166,6 +1205,7 @@ bd_add_del_command_fn (vlib_main_t * vm, unformat_input_t * input,
u32 bd_id = ~0;
u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
u32 mac_age = 0;
+ u8 *bd_tag = NULL;
l2_bridge_domain_add_del_args_t _a, *a = &_a;
int rv;
@@ -1189,6 +1229,8 @@ bd_add_del_command_fn (vlib_main_t * vm, unformat_input_t * input,
;
else if (unformat (line_input, "mac-age %d", &mac_age))
;
+ else if (unformat (line_input, "bd-tag %s", &bd_tag))
+ ;
else if (unformat (line_input, "del"))
{
is_add = 0;
@@ -1215,6 +1257,11 @@ bd_add_del_command_fn (vlib_main_t * vm, unformat_input_t * input,
error = clib_error_return (0, "mac age must be less than 256");
goto done;
}
+ if ((bd_tag) && (strlen ((char *) bd_tag) > 63))
+ {
+ error = clib_error_return (0, "bd-tag cannot be longer than 63");
+ goto done;
+ }
memset (a, 0, sizeof (*a));
a->is_add = is_add;
@@ -1225,6 +1272,7 @@ bd_add_del_command_fn (vlib_main_t * vm, unformat_input_t * input,
a->learn = (u8) learn;
a->arp_term = (u8) arp_term;
a->mac_age = (u8) mac_age;
+ a->bd_tag = bd_tag;
rv = bd_add_del (a);
@@ -1252,6 +1300,7 @@ bd_add_del_command_fn (vlib_main_t * vm, unformat_input_t * input,
}
done:
+ vec_free (bd_tag);
unformat_free (line_input);
return error;
@@ -1291,7 +1340,7 @@ VLIB_CLI_COMMAND (bd_create_cli, static) = {
.path = "create bridge-domain",
.short_help = "create bridge-domain <bridge-domain-id>"
" [learn <0|1>] [forward <0|1>] [uu-flood <0|1>] [flood <0|1>] [arp-term <0|1>]"
- " [mac-age <nn>] [del]",
+ " [mac-age <nn>] [bd-tag <tag>] [del]",
.function = bd_add_del_command_fn,
};
/* *INDENT-ON* */
diff --git a/src/vnet/l2/l2_bd.h b/src/vnet/l2/l2_bd.h
index 0e070651859..e60f1ab3f09 100644
--- a/src/vnet/l2/l2_bd.h
+++ b/src/vnet/l2/l2_bd.h
@@ -88,6 +88,9 @@ typedef struct
/* sequence number for bridge domain based flush of MACs */
u8 seq_num;
+ /* Bridge domain tag (C string NULL terminated) */
+ u8 *bd_tag;
+
} l2_bridge_domain_t;
/* Limit Bridge Domain ID to 24 bits to match 24-bit VNI range */
@@ -102,6 +105,7 @@ typedef struct
u8 learn;
u8 arp_term;
u8 mac_age;
+ u8 *bd_tag;
u8 is_add;
} l2_bridge_domain_add_del_args_t;
@@ -130,6 +134,7 @@ u32 bd_remove_member (l2_bridge_domain_t * bd_config, u32 sw_if_index);
u32 bd_set_flags (vlib_main_t * vm, u32 bd_index, u32 flags, u32 enable);
void bd_set_mac_age (vlib_main_t * vm, u32 bd_index, u8 age);
+void bd_set_bd_tag (vlib_main_t * vm, u32 bd_index, u8 * bd_tag);
int bd_add_del (l2_bridge_domain_add_del_args_t * args);
/**