Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 11 Oct 2025 12:17:35 -0400
From:      David Horn <dhorn2000@gmail.com>
To:        freebsd-current@freebsd.org
Subject:   bridge and async dhcp in rc.conf
Message-ID:  <CAG7WopnG-sioD-YoGhP3JjdugFUztm2ZpxzcEbiq%2B%2BG9niZZ7g@mail.gmail.com>

index | next in thread | raw e-mail

[-- Attachment #1 --]
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

[-- Attachment #2 --]
<div dir="ltr">I seem to have run into a corner case with bridge support and DHCP that seems to have a trivial fix.<div><br><div>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: <a href="https://wiki.freebsd.org/crest/the-correct-way-to-configure-bridges-in-freebsd-for-ipv6-and-ipv4">https://wiki.freebsd.org/crest/the-correct-way-to-configure-bridges-in-freebsd-for-ipv6-and-ipv4</a>; that did not work for me.  I checked the handbook documentation here: <a href="https://docs.freebsd.org/en/books/handbook/advanced-networking/#network-bridging">https://docs.freebsd.org/en/books/handbook/advanced-networking/#network-bridging</a>; and there are no examples for bridge DHCP on boot using /etc/rc.conf.  Please consider added example once this fix lands.</div><div><br></div><div>Example /etc/rc.conf config:</div><div><br></div><div>ifconfig_em0=&quot;up -tso -vlanhwtso&quot;</div><div>cloned_interfaces=&quot;bridge0&quot;<br>create_args_bridge0=&quot;addm em0 edge em0&quot;<br>ifconfig_bridge0=&quot;up DHCP&quot;<br>ifconfig_bridge0_ipv6=&quot;inet6 auto_linklocal accept_rtadv -ifdisabled&quot;<br>rtsold_enable=&quot;yes&quot;<br>rtsold_flags=&quot;-i -m bridge0&quot;<br></div><div><br></div><div>The /etc/rc.conf interface variable &quot;DHCP&quot; normally is used to define for the /etc/rc.d startup scripts and devd rules to automatically provide async DHCP for interfaces at &quot;LINK_UP&quot; 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 &quot;SYNCDHCP&quot; for this interface config and worked around the problem until my curiosity got the best of me to debug further.</div><div><br></div><div>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.</div><div><br></div><div>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 ?</div><div><br></div><div>Index: /etc/devd/dhclient.conf<br>===================================================================<br>--- /etc/devd/dhclient.conf (stock)<br>+++ /etc/devd/dhclient.conf (local)<br>@@ -12,6 +12,13 @@<br> };<br> <br> notify 0 {<br>+        match &quot;system&quot;          &quot;IFNET&quot;;<br>+        match &quot;type&quot;            &quot;LINK_UP&quot;;<br>+        media-type              &quot;bridge&quot;;<br>+        action &quot;service dhclient quietstart $subsystem&quot;;<br>+};<br>+<br>+notify 0 {<br>        match &quot;system&quot;          &quot;IFNET&quot;;<br>        match &quot;type&quot;            &quot;LINK_UP&quot;;<br>        media-type              &quot;802.11&quot;;<br></div><div><br></div><div>--Thanks!<br></div><div>-_Dave H</div><div><br></div><div><br></div><div><br></div></div></div>
help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAG7WopnG-sioD-YoGhP3JjdugFUztm2ZpxzcEbiq%2B%2BG9niZZ7g>