Repository navigation
Conversation
troglobit
force-pushed
the
dhcp-relay
branch
2 times, most recently
from
December 1, 2026 17:59
2df7118 to
e2e08ba
Compare
troglobit
marked this pull request as ready for review
December 1, 2026 18:06
DHCP relay agent with option 82, for an IP address per port on a switch. Installed as an available Finit service, to be enabled when a relay is configured. Enabled in all defconfigs that have the DHCP server. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
A node with a when expression that refers to another subtree was never offered for completion, e.g. a list that only applies when the interface its parent names is a bridge. Bump klish-plugin-sysrepo, which now evaluates the expression against the candidate datastore. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
The address of a static host is not used while another client has a lease on it. With a host that matches on the port a client is connected to, option 82, a device that replaces a broken one does not get the address of the port until the lease of the old device expires. With preempt on the dhcp-host the new client takes over the address at once. Issue #705 Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
dnsmasq binds UDP port 67 on the wildcard address without allowing another socket on the port, so a relay agent on the same system cannot bind it on its gateway addresses. With bind-dynamic it can. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
A subnet in the DHCP server without a pool, only static hosts, was not served at all: no client got an address from it. The model allows it, and it is the natural setup when every address is reserved. dnsmasq only serves a subnet it has a dhcp-range for, and the range was written from the pool. Write a static range for a subnet without one. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
A static host in the DHCP server can be matched on MAC address, hostname or client-id, all of which follow the device. With a DHCP relay agent that adds option 82, the server can instead hand out an address per port, whatever is connected to it. Add an option82 case to the host match, with circuit-id and remote-id as string or hex, and a preempt setting, which lets a device that replaces a broken one take over the address before the old lease has expired. Issue #705 Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
Clients cannot get an address from a DHCP server on another subnet, and
a server cannot hand out an address per port, without a relay agent
that tells it where a request came from, option 82.
Add the infix-dhcp-relay model and generate the configuration for
dhcprelayd from it. An interface that is a bridge, or a VLAN interface
on a bridge, relays per bridge port: all ports of a bridge, or the
ports with the VLAN as PVID and its tagged members. The port list of
an interface only holds the exceptions: a port that should not relay,
a trusted port towards another relay agent, or a circuit-id other than
the port name.
For a server on the device itself, at 127.0.0.1, the server identifier
override is always on, or the clients would be told that their server
is 127.0.0.1.
An interface to relay from is refused without a server, and 127.0.0.1
without option 82. So when the DHCP server on the device has a subnet,
the first interface gets 127.0.0.1 as server if none is configured, and
a local server enables option 82:
admin@example:/config/dhcp-relay/> set interface br0
admin@example:/config/dhcp-relay/> show
server 127.0.0.1
option82
interface br0
Fixes #438
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
Five tests, one for each way the relay agent is meant to be used: to a server on another subnet, to a server on the device itself with a replaced client, from an interface that is not a bridge without option 82, in a chain of two switches where the first gets its own address through the second, and on a VLAN filtering bridge with an access port and a trunk port. The first test also listens on a second port of the bridge. No request from a relayed port may show up there, since a switch that floods the broadcast before the CPU sees it leaks it past the relay agent. With relaying disabled on the port, the request must show up. The topologies have fixed node positions, so they fit an A4 page of the test report and render the same with old and new Graphviz. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
Only the first subnet of a DHCP server got the default pool, and a
removed server came back with two options:
admin@example:/config/> no dhcp-server
admin@example:/config/> show dhcp-server
option dns-server {
The candidate hook ran on any change to the server. With no global
options it added them, also when the server had just been removed, and
with global options it returned before it got to the pool.
Run the inference for the subnets a change creates: every new /24
subnet gets a pool, and the options are added with the first one. A
pool or an option the user removes now stays removed.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
The relay agent could only be set up in the advanced editor. The new page lists the interfaces relayed from. For a bridge, or a VLAN interface on a bridge, the fold-out shows the ports the device relays from, where a port can be left out, trusted, or given a circuit-id. Only ports that differ from the defaults are saved in the port list. The DHCP servers, option 82, the remote-id and the policy are in the cards above the list. The page is the counterpart of Status > DHCP, so the tabs in the top bar switch between the two. Issue #438 Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
The DHCP server had a status page but could only be set up in the advanced editor. The page now lists the subnets, above the relay agent, with the pool and lease time of each in a fold-out, and below them the static hosts of the subnet. A host is matched on MAC address, hostname, client-id, or the option 82 a relay agent adds, and can have preempt set, so an address per port is set up without the CLI. Options, the default gateway and DNS server among them, are a list for the server and one for each subnet. Network boot and the options of a host are left to the advanced editor, which the fold-out links to. Issue #705 Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
With a subnet in the DHCP server of the device and no server in the relay agent, the server to relay to is most often 127.0.0.1. Start the add form of the server list with it. Issue #438 Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
A bridge of LAN969x ports with LLDP in ieee-group-forward forwards LLDP to a veth port, but not to its other switch ports. The switch sends reserved link-local multicast to the CPU only, and the driver marked it as already forwarded. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
The relay agent could only be followed in the log. Add its state to the operational datastore: the gateway address of each interface, the requests received, relayed and dropped and the replies relayed for each interface and bridge port, the client a request was last relayed for with the address it got, and for each server the requests sent to it and the replies from it. dhcprelayd replaces its status file when something changed, which is followed with inotify, nothing is polled. Needs the status file of dhcprelayd v3.0. The DHCP Relay test now also verifies the address of the client in the state of its port. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
List the interfaces and ports the relay agent relays from, with their
counters and the last client of each port, and the servers:
admin@example:/> show dhcp-relay
br0 : gateway address 192.168.1.1
INTERFACE PORT REQUESTS RELAYED DROPPED REPLIES CLIENT ADDRESS
br0 2 2 0 2
e8 2 2 0 2 00:a0:85:00:01:05 192.168.1.42
The manual gets a Status section on how to read it, in place of the
table of log messages.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
The DHCP status page only had the server. Add the relay agent below it: for each interface its gateway address, and for each port the requests received, relayed and dropped, the replies relayed, and the client a request was last relayed for with the address it got. The servers are listed with the requests sent to them and the replies received. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
After a save on most configuration pages, the pane to the right kept showing the changes from before the save until the page was reloaded. The pane fetches its diffs again when a write succeeds, and went by the successful flag of htmx. Most handlers answer a save with 204 and an HX-Location header, and htmx returns from such a reply before it sets the flag. Go by the status of the reply. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
A text field that takes a value or a keyword, e.g., an address or the word auto, only works for a user who knows the word. Write down the rule the DHCP option form follows: a word the model takes in place of a value is a checkbox, with the label and help of the schema. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
Setting up DHCP on the page took knowing what a relay agent is and when one is needed, and the page listed the cards of both the server and the relay agent on a device that uses one of them, or neither. Set up now opens a dialog that asks what the device should do: hand out addresses on a network, give the device on each port a fixed address, or pass requests on to a server on another network. Advanced adds the switch in a chain or ring, static hosts only, and option 82. Each goal stages what the matching section of the manual describes, and turns on a server or relay agent that was disabled. A server without a subnet, and a relay agent without servers, interfaces or option 82, is one card with the Set up button. With neither set up, that card is the whole page. Show settings opens the cards, and they stay open over a save until the user leaves the page. A dialog that was closed and opened again showed the fields of the goal selected last under the first goal, since a form reset fires no change event. Fields shown by another field are now updated when a dialog opens, and a selected radio button that gets hidden gives way to the first one left. Issue #438 Issue #705 Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
A camera on port 3 breaks. Someone unscrews it, mounts the spare, and the spare has to come up with the address of the old one, or the video system does not find it. Until now that meant looking up the MAC address of the spare and editing the DHCP server before the swap.
With this PR the address belongs to the port. A relay agent in the switch tags each DHCP request with the port it came in on, option 82, and the DHCP server hands out the address set for that port, also when the lease of the old device has not expired.
Fixes #438
Fixes #705
Setting it up
In the WebUI, a device where DHCP is not set up shows one card under Configuration > DHCP:
Set up asks what the device should do, in the words of the person standing in front of it. Nobody has to know what a relay agent is, or that this case needs both a relay agent and a server:
The wizard stages the result as any other change, so it can be read in the changes pane before it is applied. For the bridge above that is a static host for each port, matched on the circuit-id the relay agent adds, with preempt set so the spare takes over the address at once:
and the relay agent on the same bridge, with every port relayed from and the port name as circuit-id:
After that the page is the full view, where a port can be left out, trusted, or given another circuit-id, and where the server gets its other subnets, pools and options. Status > DHCP shows it working, here with the device on
p1holding the first address:The same is available without a browser:
show dhcp-relayin the CLI, and the relay agent and its state over NETCONF and RESTCONF.Relay agent
New model
infix-dhcp-relay, DHCPv4 only, backed by dhcprelayd 3.0, our fork of the Westermo dhcp-helper.strorhex, the remote-id also as gateway address or hostnamepolicyfor requests that already carry option 82:replace(default),keepordropenabled,trustedfor ports towards other relay agents, andcircuit-idforce-server-identity, RFC 5107, so renewals also pass the relay agentIts state is in the operational datastore: the gateway address of each interface, counters for each interface, port and server, and the client a request was last relayed for on each port, with the address it got. dhcprelayd replaces a status file when something changes and yangerd follows it with inotify, nothing is polled.
A dropped request is logged with the client, the port and the reason.
DHCP server
preempton a static host lets a new client take over the address before the old lease has expired. This is a newpreemptkeyword fordhcp-hostin dnsmasq, carried as a patchOne change in behavior: every new /24 subnet now gets the .100 to .250 pool, not only the first one, and removing the server no longer leaves its default options behind.
Switch drivers
A switch floods a broadcast before the CPU sees it, so a request leaks past the relay agent to the other ports of the bridge. Three kernel patches trap DHCP requests to the CPU on user ports and leave the forwarding to the software bridge, where the relay agent drops them:
A fourth patch is a fix found on the way: a bridge of lan969x ports with
ieee-group-forwardforwarded, e.g., LLDP to a veth port but not to its other switch ports. The driver marked reserved link-local multicast as already forwarded, although the switch sends it to the CPU only. The LLDP IEEE Group Forward test would have caught it, but is skipped on the Tactical rig, whose topology has noieee-mclinks.WebUI
The Configuration > DHCP page is new, and holds both the server and the relay agent, as Status > DHCP does. The two are counterparts, so the tabs in the top bar switch between them.
autohas a checkbox forauto, not a keyword to type. The rule is now in the WebUI READMEHX-Locationas successful, the pane now goes by the status of the replyOther
whenexpression that refers to another subtree were never offered, which hid theportlist. Fixed in klish-plugin-sysrepoChecklist
Tick relevant boxes, this PR is-a or has-a: