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 <jdl@netgate.com>
_(APPLICATION_NOT_ATTACHED, -118, "application not attached") \
_(BD_ALREADY_EXISTS, -119, "Bridge domain already exists") \
_(BD_IN_USE, -120, "Bridge domain has member interfaces") \
_(APPLICATION_NOT_ATTACHED, -118, "application not attached") \
_(BD_ALREADY_EXISTS, -119, "Bridge domain already exists") \
_(BD_IN_USE, -120, "Bridge domain has member interfaces") \
-_(UNSUPPORTED, -121, "Unsupported")
+_(BD_NOT_MODIFIABLE, -121, "Default bridge domain 0 can be neither deleted nor modified") \
+_(UNSUPPORTED, -122, "Unsupported")
vl_api_bridge_domain_set_mac_age_reply_t *rmp;
int rv = 0;
u32 bd_id = ntohl (mp->bd_id);
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;
if (p == 0)
{
rv = VNET_API_ERROR_NO_SUCH_ENTRY;
return;
bd_id = ntohl (mp->bd_id);
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;
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);
for (; bd_index < end; bd_index++)
{
bd_config = l2input_bd_config_from_index (l2im, bd_index);
u32 flags = ntohl (mp->feature_bitmap);
uword *p;
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)
{
p = hash_get (bdm->bd_index_by_bd_id, bd_id);
if (p == 0)
{
+ if (bd_id == 0)
+ return clib_error_return (0,
+ "No operations on the default bridge domain are supported");
+
p = hash_get (bdm->bd_index_by_bd_id, bd_id);
if (p == 0)
p = hash_get (bdm->bd_index_by_bd_id, bd_id);
if (p == 0)
+ if (bd_id == 0)
+ return clib_error_return (0,
+ "No operations on the default bridge domain are supported");
+
p = hash_get (bdm->bd_index_by_bd_id, bd_id);
if (p == 0)
p = hash_get (bdm->bd_index_by_bd_id, bd_id);
if (p == 0)
+ if (bd_id == 0)
+ return clib_error_return (0,
+ "No operations on the default bridge domain are supported");
+
p = hash_get (bdm->bd_index_by_bd_id, bd_id);
if (p == 0)
p = hash_get (bdm->bd_index_by_bd_id, bd_id);
if (p == 0)
+ if (bd_id == 0)
+ return clib_error_return (0,
+ "No operations on the default bridge domain are supported");
+
p = hash_get (bdm->bd_index_by_bd_id, bd_id);
if (p == 0)
p = hash_get (bdm->bd_index_by_bd_id, bd_id);
if (p == 0)
+ if (bd_id == 0)
+ return clib_error_return (0,
+ "No operations on the default bridge domain are supported");
+
p = hash_get (bdm->bd_index_by_bd_id, bd_id);
if (p)
bd_index = *p;
p = hash_get (bdm->bd_index_by_bd_id, bd_id);
if (p)
bd_index = *p;
+ if (bd_id == 0)
+ return clib_error_return (0,
+ "No operations on the default bridge domain are supported");
+
p = hash_get (bdm->bd_index_by_bd_id, bd_id);
if (p == 0)
p = hash_get (bdm->bd_index_by_bd_id, bd_id);
if (p == 0)
+ if (bd_id == 0)
+ return clib_error_return (0,
+ "No operations on the default bridge domain are supported");
+
p = hash_get (bdm->bd_index_by_bd_id, bd_id);
if (p)
p = hash_get (bdm->bd_index_by_bd_id, bd_id);
if (p)
u32 bd_id = ~0;
uword *p;
u32 bd_id = ~0;
uword *p;
end = vec_len (l2input_main.bd_configs);
if (unformat (input, "%d", &bd_id))
end = vec_len (l2input_main.bd_configs);
if (unformat (input, "%d", &bd_id))
if (unformat (input, "arp"))
arp = 1;
if (unformat (input, "arp"))
arp = 1;
+ if (bd_id == 0)
+ return clib_error_return (0,
+ "No operations on the default bridge domain are supported");
+
p = hash_get (bdm->bd_index_by_bd_id, bd_id);
if (p)
bd_index = *p;
p = hash_get (bdm->bd_index_by_bd_id, bd_id);
if (p)
bd_index = *p;
{
if (bd_index == ~0)
return VNET_API_ERROR_NO_SUCH_ENTRY;
{
if (bd_index == ~0)
return VNET_API_ERROR_NO_SUCH_ENTRY;
+ if (bd_index == 0)
+ return VNET_API_ERROR_BD_NOT_MODIFIABLE;
if (vec_len (l2input_main.bd_configs[bd_index].members))
return VNET_API_ERROR_BD_IN_USE;
rv = bd_delete (bdm, bd_index);
if (vec_len (l2input_main.bd_configs[bd_index].members))
return VNET_API_ERROR_BD_IN_USE;
rv = bd_delete (bdm, bd_index);
+ if (bd_id == 0)
+ {
+ error = clib_error_return (0, "bridge domain 0 can not be modified");
+ goto done;
+ }
+
if (mac_age > 255)
{
error = clib_error_return (0, "mac age must be less than 256");
if (mac_age > 255)
{
error = clib_error_return (0, "mac age must be less than 256");
case VNET_API_ERROR_NO_SUCH_ENTRY:
error = clib_error_return (0, "bridge domain id does not exist");
goto done;
case VNET_API_ERROR_NO_SUCH_ENTRY:
error = clib_error_return (0, "bridge domain id does not exist");
goto done;
+ case VNET_API_ERROR_BD_NOT_MODIFIABLE:
+ error = clib_error_return (0, "bridge domain 0 can not be modified");
+ goto done;
default:
error = clib_error_return (0, "bd_add_del returned %d", rv);
goto done;
default:
error = clib_error_return (0, "bd_add_del returned %d", rv);
goto done;
+ 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)
{
p = hash_get (bdm->bd_index_by_bd_id, bd_id);
if (p == 0)
{