Skip to content

Commit

Permalink
Fix issue of lldp_syncd crashes and cause docker lldp restarts
Browse files Browse the repository at this point in the history
lldp-syncd throws exception from get_sys_capability_list
The get_sys_capability_list() shall consider both the system name and system capabilities of remote device is null case.
  • Loading branch information
Th1592-aster committed Dec 20, 2024
1 parent b0ea01f commit 9131b46
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/lldp_syncd/daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def get_sys_capability_list(self, if_attributes, if_name, chassis_id):
# {'enabled': ..., 'type': 'capability'}
if isinstance(capability_list, dict):
capability_list = [capability_list]
except KeyError:
except :
logger.info("Failed to get system capabilities on {} ({})".format(if_name, chassis_id))
return []
return capability_list
Expand Down
20 changes: 20 additions & 0 deletions tests/subproc_outputs/interface_only.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,26 @@
]
}
},
{
"Ethernet47": {
"via": "LLDP",
"rid": "80",
"age": "0 day, 00:00:05",
"chassis": {
"id": {
"type": "mac",
"value": "e4:f4:c6:da:8d:d0"
}
},
"port": {
"id": {
"type": "ifname",
"value": "g5"
},
"ttl": "120"
}
}
},
{
"Ethernet100": {
"rid": "1",
Expand Down
5 changes: 4 additions & 1 deletion tests/test_lldpSyncDaemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,10 @@ def test_remote_sys_capability_list(self):
for interface in interface_list:
(if_name, if_attributes), = interface.items()
capability_list = self.daemon.get_sys_capability_list(if_attributes, if_name, "fake_chassis_id")
self.assertNotEqual(capability_list, [])
if if_name == 'Ethernet47':
self.assertEqual(capability_list, [])
else:
self.assertNotEqual(capability_list, [])

def test_changed_deleted_interface(self):
parsed_update = self.daemon.parse_update(self._json)
Expand Down

0 comments on commit 9131b46

Please sign in to comment.