bridge and async dhcp in rc.conf

From: David Horn <dhorn2000_at_gmail.com>
Date: Sat, 11 Oct 2025 16:17:35 UTC
I seem to have run into a corner case with bridge support and DHCP that
seems to have a trivial fix.

Using bridge0 with an upstream interface (em0) does not allow me to do
normal rc.conf entries for DHCP to the bridge interface (em0 is not allowed
to get addresses since it is a member of the bridge)  I use dual-stack
IPv4/IPv6 everywhere as well.  I found an example here:
https://wiki.freebsd.org/crest/the-correct-way-to-configure-bridges-in-freebsd-for-ipv6-and-ipv4
that did not work for me.  I checked the handbook documentation here:
https://docs.freebsd.org/en/books/handbook/advanced-networking/#network-bridging
and there are no examples for bridge DHCP on boot using /etc/rc.conf.
Please consider added example once this fix lands.

Example /etc/rc.conf config:

ifconfig_em0="up -tso -vlanhwtso"
cloned_interfaces="bridge0"
create_args_bridge0="addm em0 edge em0"
ifconfig_bridge0="up DHCP"
ifconfig_bridge0_ipv6="inet6 auto_linklocal accept_rtadv -ifdisabled"
rtsold_enable="yes"
rtsold_flags="-i -m bridge0"

The /etc/rc.conf interface variable "DHCP" normally is used to define for
the /etc/rc.d startup scripts and devd rules to automatically provide async
DHCP for interfaces at "LINK_UP" events.  When debugging this, I noticed
that this does not work as expected with bridge interfaces, but does with
ethernet and 802.11 interfaces.   I temporarily used "SYNCDHCP" for this
interface config and worked around the problem until my curiosity got the
best of me to debug further.

Looking at /etc//devd/dhclient.conf, I noticed that only two media-types
are supported for async DHCP on LINK_UP.  I added a third media type to
this configuration file for bridge and it started working for me.

Glad to put in a PR with a proposed patch for this, but the real question
is are there OTHER media types that should be supported with async DHCP
configurations automatically besides bridge via devd rules ?  Does this
also impact LAGG ?

Index: /etc/devd/dhclient.conf
===================================================================
--- /etc/devd/dhclient.conf (stock)
+++ /etc/devd/dhclient.conf (local)
@@ -12,6 +12,13 @@
 };

 notify 0 {
+        match "system"          "IFNET";
+        match "type"            "LINK_UP";
+        media-type              "bridge";
+        action "service dhclient quietstart $subsystem";
+};
+
+notify 0 {
        match "system"          "IFNET";
        match "type"            "LINK_UP";
        media-type              "802.11";

--Thanks!
-_Dave H