From c4eac60d6d6ad88dd499bbf5fbfe3ee7423ae1f7 Mon Sep 17 00:00:00 2001 From: Nikhil Date: Fri, 1 Jul 2016 23:07:19 -0700 Subject: [PATCH] ifupdownaddons: iproute2: fix 'ifquery -c' fail for 'bridge-pvid' on bridge ports Ticket: CM-11624 Reviewed By: roopa, julien Testing Done: using configuration mentioned in the bug This patch fixes 'ifquery -c' failure for 'bridge-pvid' on all bridge ports. The following format of '/sbin/bridge -c vlan show' output was not handled properly by iproute2 port vlan ids swp1 600 700-710 711 PVID Egress Untagged 712-900 iproute2 was parsing the '/sbin/bridge -c vlan show' output with the assumption that pvid line '711 PVID Egress Untagged' appears before all the vland ids. Something like this: port vlan ids swp1 711 PVID Egress Untagged 600 700-710 712-900 Signed-off-by: Nikhil --- addons/bridge.py | 2 +- ifupdownaddons/iproute2.py | 30 +++++++++++------------------- 2 files changed, 12 insertions(+), 20 deletions(-) diff --git a/addons/bridge.py b/addons/bridge.py index c2ec8e0..1a25d3f 100644 --- a/addons/bridge.py +++ b/addons/bridge.py @@ -514,7 +514,7 @@ class bridge(moduleBase): vids2_ints = self._ranges_to_ints(vids2) set_diff = Set(vids1_ints).symmetric_difference(vids2_ints) if pvid: - set_diff = set_diff.remove(pvid) + set_diff = set_diff.remove(int(pvid)) if set_diff: return False else: diff --git a/ifupdownaddons/iproute2.py b/ifupdownaddons/iproute2.py index 13db7d7..67a63c5 100644 --- a/ifupdownaddons/iproute2.py +++ b/ifupdownaddons/iproute2.py @@ -709,26 +709,18 @@ class iproute2(utilsBase): brvlanlines = bridgeout.splitlines() brportname=None for l in brvlanlines[1:]: - if l and l[0] not in [' ', '\t']: - brportname = None - l=l.strip() - if not l: - brportname=None - continue - if 'PVID' in l: - attrs = l.split() - brportname = attrs[0] - brvlaninfo[brportname] = {'pvid' : attrs[1], - 'vlan' : []} - elif brportname: - if 'Egress Untagged' not in l: - brvlaninfo[brportname]['vlan'].append(l) - elif not brportname: + if l and not l.startswith(' ') and not l.startswith('\t'): attrs = l.split() - if attrs[1] == 'None' or 'Egress Untagged' in attrs[1]: - continue - brportname = attrs[0] - brvlaninfo[brportname] = {'vlan' : [attrs[1]]} + brportname = attrs[0].strip() + brvlaninfo[brportname] = {'pvid' : None, 'vlan' : []} + l = ' '.join(attrs[1:]) + if not brportname or not l: + continue + l = l.strip() + if 'PVID' in l: + brvlaninfo[brportname]['pvid'] = l.split()[0] + elif 'Egress Untagged' not in l: + brvlaninfo[brportname]['vlan'].append(l) return brvlaninfo def bridge_port_pvid_add(self, bridgeportname, pvid):