OpenBSD Journal

Introducing an OpenBSD LLDP daemon

Contributed by Peter N. M. Hansteen on from the know yer neighbor ethernetly dept.

Our favorite operating system may be on the verge of having a LLDP (Link Layer Discovery Protocol) daemon added to the base system. David Gwynne (dlg@) is circulating a patch on tech@ that introduces the daemon,

List:       openbsd-tech
Subject:    LLDP daemon and display tool
From:       David Gwynne <david () gwynne ! id ! au>
Date:       2025-04-24 3:49:53

this adds a small daemon and command line tool for receiving and
displaying LLDP messages from neighbors connected to Ethernet
interfaces.

the daemon is called olldpd(8) to avoid colliding with the existing
lldpd from ports. the command line tool is lldp(8).

it uses the AF_FRAME sockets that were recently added rather than BPF.
this means it retains fewer privileges while it's running because it
doesn't have to open and configure BPF devices when new interfaces
appear in the system. avoiding BPF means it has basically 0 impact on
the kernel packet path because AF_FRAME is handled as a last resort for
packets rather than up front for every packet on an interface.
it's good enough now that i can leave the daemon running, and it handles
interfaces coming and going, and lldp neighbours coming and going. the
command line utility defaults to a brief output, but can produce verbose
output that handles most of the basic set of lldp information from the
specification.

now that i've done the easy bits (AF_FRAME and the packet reception)
i think it's time to get it into the tree so people can help with
the hard stuff (pretty printing strings in c).

things that i'd like to get working in the future are:

- parse organisationally specific TLVs from IEEE specs
- allow configuration to disable lldp reception on specified interfaces
- query the daemon for stats/counters

things that i do not want to get working in the future:

- support for any other protocols like cdp/edp/etc

long term it should be reasonable to implement tx so openbsd can send
lldp packets to neighbor devices.

this is what the command line tool looks like:

dlg@r5s ~$ lldp    
IFACE    SYSTEM                   PORTID                   CHASSISID
rge0     rb450gx4                 ether3                   dc:2c:6e:87:a0:7c
dlg@r5s ~$ lldp -v
Local interface: rge0, Source address: dc:2c:6e:87:a0:7e
Chassis ID: dc:2c:6e:87:a0:7c
Port ID: ether3
Time-To-Live: 2m1s
System Name: rb450gx4
System Description: MikroTik RouterOS 7.17 (stable) 2025-01-16 08:19:28 RB450Gx4
Management Address: 192.0.2.8, port 3
Management Address: fe80::de2c:6eff:fe87:a07c, port 3
System Capabilities: Bridge: enabled, Router: enabled
Port Description: bridge/ether3
---

dlg@r6415 ~$ lldp
IFACE    SYSTEM                   PORTID                   CHASSISID
bnxt0    eait-42-dc3-a2-2         ethernet1/1/9:1          8c:04:ba:c9:4a:c0
mcx0     eait-42-dc3-a2-2         ethernet1/1/8:1          8c:04:ba:c9:4a:c0
bnxt1    eait-42-dc3-a2-1         ethernet1/1/9:1          8c:04:ba:cf:6b:c0
mcx1     eait-42-dc3-a2-1         ethernet1/1/8:1          8c:04:ba:cf:6b:c0
dlg@r6415 ~$ lldp -i mcx0 
IFACE    SYSTEM                   PORTID                   CHASSISID
mcx0     eait-42-dc3-a2-2         ethernet1/1/8:1          8c:04:ba:c9:4a:c0
dlg@r6415 ~$ lldp -i mcx0 -v
Local interface: mcx0, Source address: 8c:04:ba:c9:4a:c8
Chassis ID: 8c:04:ba:c9:4a:c0
Port ID: ethernet1/1/8:1
Time-To-Live: 2m
Port Description: Po38:r6415
System Name: eait-42-dc3-a2-2
System Description: Dell SmartFabric OS10 Enterprise.
	Copyright (c) 1999-2023 by Dell Inc. All Rights Reserved.
	System Description: OS10 Enterprise.
	OS Version: 10.5.6.0.
	System Type: S5248F-ON
System Capabilities: Repeater: enabled, Bridge: enabled, Router: enabled
Management Address: 8c:04:ba:c9:4a:c0, ifIndex 0
00-80-C2 subtype 1: 0000
00-80-C2 subtype 7: 0300000026
00-12-0F subtype 1: 0100020047
00-12-0F subtype 4: 2400
F8-B1-56 subtype 21: 20
F8-B1-56 subtype 22: 20
F8-B1-56 subtype 23: 20
F8-B1-56 subtype 24: 20
---
-- followed by the code itself.

Discussions are ongoing, and the code is in an early form as indicated. But if you are in a position to test and comment, you are invited to do so!


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.]