Skip to content

Commit eafa643

Browse files
authored
Show FDB type in fdbshow/show mac (sonic-net#231)
1 parent 86a3c94 commit eafa643

1 file changed

Lines changed: 14 additions & 12 deletions

File tree

scripts/fdbshow

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@
99
1010
Example of the output:
1111
admin@str~$ fdbshow
12-
No. Vlan MacAddress Port
13-
----- ------ ----------------- ----------
14-
1 1000 7C:FE:90:80:9F:05 Ethernet20
15-
2 1000 7C:FE:90:80:9F:10 Ethernet40
16-
3 1000 7C:FE:90:80:9F:01 Ethernet4
17-
4 1000 7C:FE:90:80:9F:02 Ethernet8
12+
No. Vlan MacAddress Port Type
13+
----- ------ ----------------- ---------- -------
14+
1 1000 7C:FE:90:80:9F:05 Ethernet20 Dynamic
15+
2 1000 7C:FE:90:80:9F:10 Ethernet40 Dynamic
16+
3 1000 7C:FE:90:80:9F:01 Ethernet4 Dynamic
17+
4 1000 7C:FE:90:80:9F:02 Ethernet8 Dynamic
1818
Total number of entries 4
1919
admin@str:~$ fdbshow -p Ethernet4
20-
No. Vlan MacAddress Port
21-
----- ------ ----------------- ---------
22-
1 1000 7C:FE:90:80:9F:01 Ethernet4
20+
No. Vlan MacAddress Port Type
21+
----- ------ ----------------- --------- -------
22+
1 1000 7C:FE:90:80:9F:01 Ethernet4 Dynamic
2323
Total number of entries 1
2424
admin@str:~$ fdbshow -v 1001
2525
1001 is not in list
@@ -35,7 +35,7 @@ from tabulate import tabulate
3535

3636
class FdbShow(object):
3737

38-
HEADER = ['No.', 'Vlan', 'MacAddress', 'Port']
38+
HEADER = ['No.', 'Vlan', 'MacAddress', 'Port', 'Type']
3939
FDB_COUNT = 0
4040

4141
def __init__(self):
@@ -71,6 +71,8 @@ class FdbShow(object):
7171

7272
ent = self.db.get_all('ASIC_DB', s, blocking=True)
7373
br_port_id = ent[b"SAI_FDB_ENTRY_ATTR_BRIDGE_PORT_ID"][oid_pfx:]
74+
ent_type = ent[b"SAI_FDB_ENTRY_ATTR_TYPE"]
75+
fdb_type = ['Dynamic','Static'][ent_type == "SAI_FDB_ENTRY_TYPE_STATIC"]
7476
if br_port_id not in self.if_br_oid_map:
7577
continue
7678
port_id = self.if_br_oid_map[br_port_id]
@@ -79,7 +81,7 @@ class FdbShow(object):
7981
vlan_id = fdb["vlan"]
8082
elif 'bvid' in fdb:
8183
vlan_id = port_util.get_vlan_id_from_bvid(self.db, fdb["bvid"])
82-
self.bridge_mac_list.append((int(vlan_id),) + (fdb["mac"],) + (if_name,))
84+
self.bridge_mac_list.append((int(vlan_id),) + (fdb["mac"],) + (if_name,) + (fdb_type,))
8385

8486
self.bridge_mac_list.sort(key = lambda x: x[0])
8587
return
@@ -118,7 +120,7 @@ class FdbShow(object):
118120

119121
for fdb in self.bridge_mac_list:
120122
self.FDB_COUNT += 1
121-
output.append([self.FDB_COUNT, fdb[0], fdb[1], fdb[2]])
123+
output.append([self.FDB_COUNT, fdb[0], fdb[1], fdb[2], fdb[3]])
122124

123125
print tabulate(output, self.HEADER)
124126
print "Total number of entries {0} ".format(self.FDB_COUNT)

0 commit comments

Comments
 (0)