Skip to content

fix show mac slow #1524

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions scripts/fdbshow
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ class FdbShow(object):
"""
self.db.connect(self.db.ASIC_DB)
self.bridge_mac_list = []
vlan_bvid_map = {}

if not self.if_br_oid_map:
return
Expand Down Expand Up @@ -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"]))
if fdb["bvid"] in vlan_bvid_map:
vlan_id = vlan_bvid_map[fdb["bvid"]]
else:
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
else:
vlan_bvid_map[fdb["bvid"]] = vlan_id
except Exception:
vlan_id = fdb["bvid"]
print("Failed to get Vlan id for bvid {}\n".format(fdb["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])
Expand Down