lldp: expose raw LLDP message on D-Bus

Also, track sd_lldp_neighbor instance directly.

sd_lldp_neighbor is a perfectly reasonable container for keeping
track of the LLDP neighbor information. Just keep a reference to
it, and don't clone the data. Especially since the LLDP library
keeps a reference to this instance as well.

Also, to compare whether two neighbors are the same, it is sufficient
to only consider the raw data. Everything else depends on these fields
anyway.

This is only possible and useful becuase sd_lldp_neighbor is of course
immutable. It wouldn't make sense otherwise, but it also would be bad
design to mutate the sd_lldp_neighbor instances.

This couples our code slightly more to the systemd code, which we usually
try to avoid. But when we move away in the future from systemd LLDP library,
we anyway need to rework this heavily (and then too, we wouldn't want
to clone the data, when we could just share the reference).
This commit is contained in:
Thomas Haller
2020-06-05 19:54:05 +02:00
parent 597e717659
commit e189d65ab6
3 changed files with 70 additions and 50 deletions

View File

@@ -860,6 +860,7 @@ typedef enum /*< flags >*/ {
#undef NM_AVAILABLE_IN_1_8
#endif
#define NM_LLDP_ATTR_RAW "raw"
#define NM_LLDP_ATTR_DESTINATION "destination"
#define NM_LLDP_ATTR_CHASSIS_ID_TYPE "chassis-id-type"
#define NM_LLDP_ATTR_CHASSIS_ID "chassis-id"