Skip to content

Commit

Permalink
[show] Fix 'show mac' output, when FDB entry with Vlan 1 is present (#…
Browse files Browse the repository at this point in the history
…1507)

* Skip records of FDB entries, which are linked to default Vlan 1,
  to prevent exception throwing while performing
  command 'show mac' or 'fdbshow'.

#### What I did
Resolves #894
Fixed "show mac" command execution failure in case, when the system has an FDB entry, which is linked to default Vlan 1.
The failure is caused by throwing exception, while trying to get int from None type object.
#### How I did it
The condition has added to src/sonic-utilities/scripts/fdbshow script to handle and skip FDB entries, for which the system can not get Vlan ID.

#### How to verify it
Configure your system to receive both tagged and untagged traffic. For example, you could use the next steps:

Do configuration on DUT
sudo config portchannel add PortChannel0002
sudo config portchannel member add PortChannel0002 Ethernet68
sudo config vlan add 40
sudo config vlan member add 40 PortChannel0002
sudo config interface ip add Vlan40 40.0.0.1/24
Do configuration on Linux host
sudo ip link add bond0 type bond
sudo ip link set dev bond0 type bond mode 4
sudo ip link set enp5s0f1 down
sudo ip link set enp5s0f1 master bond0
sudo ip link set enp5s0f1 up
sudo ip link set bond0 up
sudo ip link add link bond0 name bond0.40 type vlan id 40
sudo ip link set bond0.40 up
sudo ip addr add 40.0.0.3/24 dev bond0.40
Do ping from linux host to DUT IP 40.0.0.1
Do command "show mac" on DUT
"show mac" command should not be finished with the next message: int() argument must be a string, a bytes-like object or a number, not 'NoneType'. Instead, the normal output of the command should be shown.

#### Additional information
Cherry-pick of #1368.

Pay attention, additional change is required. HEAD of https://github.com/Azure/sonic-py-swsssdk submodule of buildimage should be updated and be pointed to the top of 201911 branch, because current head of the submodule causes KeyError exception raising inside function `get_vlan_id_from_bvid` of `port_util.py` module:
```
SAI_VLAN_ATTR_VLAN_ID ('SAI_VLAN_ATTR_VLAN_ID',)
Failed to get Vlan id for bvid oid:0x26000000000013
```
The raising has already fixed on the top of 201911 branch of the submodule.
  • Loading branch information
maksymbelei95 authored Mar 16, 2021
1 parent 650a68b commit 0d5fb48
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions scripts/fdbshow
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ class FdbShow(object):
elif 'bvid' in fdb:
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:
vlan_id = fdb["bvid"]
print "Failed to get Vlan id for bvid {}\n".format(fdb["bvid"])
Expand Down

0 comments on commit 0d5fb48

Please sign in to comment.