mirror of
https://github.com/CumulusNetworks/ifupdown2.git
synced 2024-05-06 15:54:50 +00:00
ifupdown2: bridge: try to interpret bridge port add rtnetlink return strings from
iproute and print meaningful error
Ticket: CM-6278
Reviewed By: CCR-3851
Testing Done: Tested error cases for bridge with multiple vlans when
net.bridge.bridge-allow-multiple-vlans is zero
new error message with the patch:
$ifquery br-vlan0502
auto br-vlan0502
iface br-vlan0502
bridge-ports swp2.502 swp3.12
bridge-stp on
mstpctl-portadminedge swp2.502=yes
mstpctl-portbpdufilter swp2.502=yes
address 3.50.2.1/24
$ifup br-vlan0502
<snip>
error: br-vlan0502: net.bridge.bridge-allow-multiple-vlans not set, multiple
vlans not allowed
error: br-vlan0502: failed to execute cmd 'ip -force -batch - [link set
dev swp3.12 master br-vlan0502
addr flush dev swp3.12
]'(RTNETLINK answers: Invalid argument
Command failed -:1)
(cherry picked from commit 3d06230cba47e8d8244439ea4d07dbdf05011067)
This commit is contained in:
committed by
Sam Tannous
parent
307e06bb2c
commit
ff28a49e7d
@@ -299,6 +299,30 @@ class bridge(moduleBase):
|
||||
self.logger.info(str(e))
|
||||
pass
|
||||
|
||||
def _pretty_print_add_ports_error(self, errstr, bridgename, bridgeports):
|
||||
""" pretty print bridge port add errors.
|
||||
since the commands are batched and the kernel only returns error
|
||||
codes, this function tries to interpret some error codes
|
||||
and prints clearer errors """
|
||||
|
||||
if re.search('RTNETLINK answers: Invalid argument', errstr):
|
||||
# Cumulus Linux specific error checks
|
||||
try:
|
||||
if self.sysctl_get('net.bridge.bridge-allow-multiple-vlans') == '0':
|
||||
vlanid = None
|
||||
for bport in bridgeports:
|
||||
ifattrs = bport.split('.')
|
||||
if vlanid:
|
||||
if (len(ifattrs) == 1 or ifattrs[1] != vlanid):
|
||||
self.logger.error('%s: ' %bridgename +
|
||||
'net.bridge.bridge-allow-multiple-vlans not set, multiple vlans not allowed')
|
||||
break
|
||||
if len(ifattrs) == 2:
|
||||
vlanid = ifattrs[1]
|
||||
except:
|
||||
pass
|
||||
self.logger.error(bridgename + ': ' + errstr)
|
||||
|
||||
def _add_ports(self, ifaceobj):
|
||||
bridgeports = self._get_bridge_port_list(ifaceobj)
|
||||
runningbridgeports = []
|
||||
@@ -322,7 +346,8 @@ class bridge(moduleBase):
|
||||
return
|
||||
err = 0
|
||||
ports = 0
|
||||
for bridgeport in Set(bridgeports).difference(Set(runningbridgeports)):
|
||||
newbridgeports = Set(bridgeports).difference(Set(runningbridgeports))
|
||||
for bridgeport in newbridgeports:
|
||||
try:
|
||||
if not self.DRYRUN and not self.ipcmd.link_exists(bridgeport):
|
||||
self.log_warn('%s: bridge port %s does not exist'
|
||||
@@ -348,7 +373,8 @@ class bridge(moduleBase):
|
||||
try:
|
||||
self.ipcmd.batch_commit()
|
||||
except Exception, e:
|
||||
self.logger.error(str(e))
|
||||
self._pretty_print_add_ports_error(str(e), ifaceobj.name,
|
||||
bridgeports)
|
||||
pass
|
||||
|
||||
# enable ipv6 for ports that were removed
|
||||
|
||||
Reference in New Issue
Block a user