OpenBSD Journal

LLDP daemon and tool committed to -current

Contributed by rueda on from the the link is ON dept.

Following its recent introduction on tech@ [See earlier article], David Gwynne (dlg@) has committed lldpd(8) to the tree:

CVSROOT:	/cvs
Module name:	src
Changes by:	dlg@cvs.openbsd.org	2025/05/02 00:12:53

Added files:
	usr.sbin/lldpd : Makefile lldpctl.h lldpd.8 lldpd.c log.c log.h 
	                 pdu.c pdu.h 

Log message:
lldpd(8): a daemon that acts as an LLDP agent on Ethernet interfaces.

lldpd uses the recently added AF_FRAME Ethernet sockets to listen
for LLDP packets on all Ethernet interfaces in the system, and
stores them so a lldp(8) client connecting to the control socket
can fetch and display the packets.
AF_FRAME means we can avoid BPF for receiving LLDP packets, which
has a couple of benefits.

firstly, BPF needs to look at all packets entering an interface so
it can filter for the ones you're interested in, which is annoying
for low packet/data rate protocols like LLDP. AF_FRAME is handled
late in ether_input, and only after other protocols (like ip) are
handled, so it's lower overhad compared to BPF listeners.

secondly, attaching a BPF filter to new interfaces relies on having
access to and the privileges to open /dev/bpf, while AF_FRAME
provides a wildcard listener that is able to receive LLDP from all
interfaces on a single socket, like how binding to on 0.0.0.0 with
an AF_INET socket let's you receive packets for all the IPs on your
system from a single socket. lldp can create and configure this
socket when it starts up just use it from then on. this means lldpd
is simpler and needs fewer privileges to operate than if it went
the BPF route.

at the moment lldpd only handles LLDP packet reception on all
interfaces, you can't disable reception on interfaces yet. it also
doesn't transmit LLDP packets (yet).

there is no intention of implementing any protocol other than LLDP
in this daemon either.

ok djm@ deraadt@
general enthusiasm from many

A short time after, the lldp(8) display tool was also committed:

CVSROOT:	/cvs
Module name:	src
Changes by:	dlg@cvs.openbsd.org	2025/05/02 00:15:59

Added files:
	usr.sbin/lldp  : Makefile lldp.8 lldp.c 

Log message:
add lldp(8), a command line tool for interacting with lldpd(8).

lldp can fetch LLDP packets from lldpd and then pulls them apart
and displays them.

by default it shows a brief summary of the lldp neighbor ports and
systems on all interfaces, but you can request verbose info and/or
info only from specific local interfaces.

now that i've done the easy part (implementing AF_FRAME and lldpd)
it would be nice to get some help with the hard stuff (pretty
printing strings in c).

ok djm@ deraadt@
general enthusiasm from many

Further development continues in-tree, and the new programs are now linked to the build.

Testing will be much appreciated, as always.


Credits

Copyright © - Daniel Hartmeier. All rights reserved. Articles and comments are copyright their respective authors, submission implies license to publish on this web site. Contents of the archive prior to as well as images and HTML templates were copied from the fabulous original deadly.org with Jose's and Jim's kind permission. This journal runs as CGI with httpd(8) on OpenBSD, the source code is BSD licensed. undeadly \Un*dead"ly\, a. Not subject to death; immortal. [Obs.]