]> git.ipfire.org Git - thirdparty/ipxe.git/commit
[lldp] Use driver-private data to hold LLDP settings block
authorMichael Brown <mcb30@ipxe.org>
Wed, 13 Sep 2023 19:23:59 +0000 (20:23 +0100)
committerMichael Brown <mcb30@ipxe.org>
Wed, 13 Sep 2023 22:02:47 +0000 (23:02 +0100)
commitcc1e27e525201f5ee7fcc098f47f04ec26814289
tree43d0730fb0c4a896348cacccea01aa410b2c6ccd
parentae4e85bde97c9b216736a5087039f3309a628d24
[lldp] Use driver-private data to hold LLDP settings block

Simplify the LLDP code by using driver-private data to hold the LLDP
settings block, instead of using a separate allocation.  This avoids
the need to maintain a list of LLDP settings blocks (since the LLDP
settings block pointer can always be obtained using netdev_priv()) and
obviates several failure paths.

Any recorded LLDP data is now freed when the network device is
unregistered, since there is no longer a dedicated reference counter
for the LLDP settings block.  To minimise surprise, we also now
explicitly unregister the settings block.  This is not strictly
necessary (since the block will be automatically unregistered when the
parent network device settings block is unregistered), but it
maintains symmetry between lldp_probe() and lldp_remove().

The overall reduction in the size of the LLDP code is around 15%.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/net/lldp.c