1
0
mirror of https://github.com/CumulusNetworks/ifupdown2.git synced 2024-05-06 15:54:50 +00:00

addons: bridge: warn users if bridge attributes are used under non-bridge stanza

This check is done without too much overhead because we rarely see a stanza
with more than a handful of attributes...

$ ifquery swp1
auto swp1
iface swp1
      bridge-vlan-aware yes
      bridge-stp off

$ ifup swp1 -v
...
info: swp1: running ops ...
warning: swp1: invalid use of bridge attribute (bridge-vlan-aware) on non-bridge stanza
warning: swp1: invalid use of bridge attribute (bridge-stp) on non-bridge stanza
..
$

Reviewed-by: Roopa Prabhu <roopa@cumulusnetworks.com>
Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
This commit is contained in:
Julien Fortin
2018-06-27 23:45:24 +03:00
parent 52ac1cfc92
commit c8e0a11ed1

View File

@ -2163,6 +2163,14 @@ class bridge(moduleBase):
elif ifaceobj.link_kind & ifaceLinkKind.BRIDGE:
self.up_bridge(ifaceobj, ifaceobj_getfunc)
else:
bridge_attributes = self._modinfo.get('attrs', {}).keys()
for ifaceobj_config_attr in ifaceobj.config.keys():
if ifaceobj_config_attr in bridge_attributes:
self.logger.warning('%s: invalid use of bridge attribute (%s) on non-bridge stanza'
% (ifaceobj.name, ifaceobj_config_attr))
def _down(self, ifaceobj, ifaceobj_getfunc=None):
if not self._is_bridge(ifaceobj):
return