diff --git a/scripts/fdbshow b/scripts/fdbshow index 2ae95cab79f2..97e51a784fa9 100755 --- a/scripts/fdbshow +++ b/scripts/fdbshow @@ -87,6 +87,7 @@ class FdbShow(object): if not fdb_str: return + bvid_tlb = {} oid_pfx = len("oid:0x") for s in fdb_str: fdb_entry = s @@ -111,15 +112,20 @@ class FdbShow(object): if 'bvid' not in fdb: # no possibility to find the Vlan id. skip the FDB entry continue - try: - vlan_id = port_util.get_vlan_id_from_bvid(self.db, fdb["bvid"]) - if vlan_id is None: - # the situation could be faced if the system has an FDB entries, - # which are linked to default Vlan(caused by untagged trafic) - continue - except Exception: - vlan_id = fdb["bvid"] - print("Failed to get Vlan id for bvid {}\n".format(fdb["bvid"])) + bvid = fdb["bvid"] + if bvid in bvid_tlb: + vlan_id = bvid_tlb[bvid] + else: + try: + vlan_id = port_util.get_vlan_id_from_bvid(self.db, bvid) + bvid_tlb[bvid] = vlan_id + if vlan_id is None: + # the situation could be faced if the system has an FDB entries, + # which are linked to default Vlan(caused by untagged trafic) + continue + except Exception: + vlan_id = bvid + print("Failed to get Vlan id for bvid {}\n".format(bvid)) self.bridge_mac_list.append((int(vlan_id),) + (fdb["mac"],) + (if_name,) + (fdb_type,)) self.bridge_mac_list.sort(key = lambda x: x[0])