From 1c7d4858369881ac4cc287c4fa16eff2e9890c1c Mon Sep 17 00:00:00 2001 From: Jon Loeliger Date: Tue, 2 May 2017 11:06:23 -0500 Subject: Prevent Bridge Domain operations on BD 0. The default bridge domain, 0, is created automatically with static features. It should be modified by neither the CLI nor the API. So add tests for, and reject any operation on BD 0. The new API error message BD_NOT_MODIFIABLE is returned in such cases. Change-Id: Iaf3dd80c4f43cf41689ca55756a0a3525420cd12 Signed-off-by: Jon Loeliger --- src/vnet/l2/l2_api.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'src/vnet/l2/l2_api.c') diff --git a/src/vnet/l2/l2_api.c b/src/vnet/l2/l2_api.c index 5a3c8dc2682..8cc7c7942eb 100644 --- a/src/vnet/l2/l2_api.c +++ b/src/vnet/l2/l2_api.c @@ -310,7 +310,15 @@ vl_api_bridge_domain_set_mac_age_t_handler (vl_api_bridge_domain_set_mac_age_t vl_api_bridge_domain_set_mac_age_reply_t *rmp; int rv = 0; u32 bd_id = ntohl (mp->bd_id); - uword *p = hash_get (bdm->bd_index_by_bd_id, bd_id); + uword *p; + + if (bd_id == 0) + { + rv = VNET_API_ERROR_BD_NOT_MODIFIABLE; + goto out; + } + + p = hash_get (bdm->bd_index_by_bd_id, bd_id); if (p == 0) { rv = VNET_API_ERROR_NO_SUCH_ENTRY; @@ -401,10 +409,13 @@ vl_api_bridge_domain_dump_t_handler (vl_api_bridge_domain_dump_t * mp) return; bd_id = ntohl (mp->bd_id); + if (bd_id == 0) + return; bd_index = (bd_id == ~0) ? 0 : bd_find_index (bdm, bd_id); ASSERT (bd_index != ~0); end = (bd_id == ~0) ? vec_len (l2im->bd_configs) : bd_index + 1; + for (; bd_index < end; bd_index++) { bd_config = l2input_bd_config_from_index (l2im, bd_index); @@ -437,6 +448,12 @@ vl_api_bridge_flags_t_handler (vl_api_bridge_flags_t * mp) u32 flags = ntohl (mp->feature_bitmap); uword *p; + if (bd_id == 0) + { + rv = VNET_API_ERROR_BD_NOT_MODIFIABLE; + goto out; + } + p = hash_get (bdm->bd_index_by_bd_id, bd_id); if (p == 0) { -- cgit 1.2.3-korg