Page MenuHomeFreeBSD

Teach bridge interfaces to work with async DHCP (add IFM_ETHER support)
Needs ReviewPublic

Authored by dhorn2000_gmail.com on Oct 12 2025, 5:09 PM.
Tags
Referenced Files
Unknown Object (File)
Thu, Apr 9, 1:47 AM
Unknown Object (File)
Wed, Apr 8, 11:59 PM
Unknown Object (File)
Sat, Mar 28, 4:36 PM
Unknown Object (File)
Mar 14 2026, 9:16 AM
Unknown Object (File)
Mar 2 2026, 4:08 AM
Unknown Object (File)
Mar 2 2026, 4:07 AM
Unknown Object (File)
Mar 2 2026, 4:07 AM
Unknown Object (File)
Feb 28 2026, 12:26 AM

Details

Reviewers
ivy
imp
manu
Group Reviewers
network
bridge
Summary

When devd initializes the /etc/devd/dhclient.conf configuration for async DHCP, it requires either a media-type match to Ethernet or 802.11 in the current version. Unfortunately, bridge interfaces do not seem to have any media type defined that devd can detect, so does not execute the service dhclient quietstart $subsystem call.

bridge: teach bridge(4) to report IFM_ETHER media type

Bridge interfaces are Ethernet-like layer-2 devices but previously had
no ifmedia support, which meant SIOCGIFMEDIA and SIOCSIFMEDIA ioctls
returned EINVAL.  As a consequence, devd(8) could not classify bridge
interfaces as Ethernet via the media-type match in dhclient.conf, so
DHCP was never triggered automatically when a bridge interface came up.

Add struct ifmedia sc_media to bridge_softc and initialise it with
IFM_ETHER | IFM_AUTO on clone creation, matching the pattern used by
if_vxlan(4).  Handle SIOCSIFMEDIA and SIOCGIFMEDIA in bridge_ioctl()
by delegating to ifmedia_ioctl().  Media changes are silently ignored
(bridge has no physical media to configure), but SIOCGIFMEDIA now
correctly reports the interface as an active full-duplex Ethernet link.

Clean up sc_media with ifmedia_removeall() during clone destruction.
Test Plan
  • Testing with multiple bridge interfaces, with and without DHCP and SYNCDHCP flags in /etc/rc.conf.
  • Testing with one and more bridge members
  • Manually with service netif restart and normal reboot flows.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

could you please recreate the diff with -U9999 to include the missing context, or (preferably) use git arc which does this automatically? otherwise, it is much harder to see what changed.

Updated diff with more context -U9999.

sbin/devd/dhclient.conf
24

i'm not sure this is the right fix. bridges don't need to be named bridgeN; it would be perfectly reasonable to have a bridge called vlan100.

is there not a media-type we can use to match bridge? in the kernel, these are IFT_BRIDGE (as opposed to IFT_ETHER) but i don't know how this is exposed in devd.

@imp any suggestions?

sbin/devd/dhclient.conf
24

Good point on the interface name.

Then can we either make:

  1. if_bridge code enumerate as IFM_ETHER (leaving devd code as-is), or
  2. add a new feature to devd to detect IFT_BRIDGE from <net/if_types.h> ?

I took a quick look, but those structures and ioctls are outside my current knowledge.

I'm agnostic to slightly leaning towards on the 'bridge up' model. I don't know enough to have a really good opinion beyond that, though.

I think we should assign IFM_ETHER in if_bridge.c instead, we already assign it to other layer 2 interfaces like if_vxlan module.
This requires updating to the bridge_softc struct to store ifmedia and adding the SIOCSIFMEDIA/SIOCGIFMEDIA handling to its ioctl.
I'm not sure whether it should depend on the member_ifaddrs sysctl or not.

adding this code to the clone_create

ifmedia_init(&sc->sc_media, 0, NULL, NULL);
ifmedia_add(&sc->sc_media, IFM_ETHER | IFM_AUTO, 0, NULL);                                                                                                               
ifmedia_set(&sc->sc_media, IFM_ETHER | IFM_AUTO);

And this for clone_destroy

ifmedia_removeall(&sc->sc_media);

what do you think? @ivy

sbin/devd/dhclient.conf
24

I have not tested, but I think the sbin/devd/devd.cc might be a good start point,

media::media(config &, const char *var, const char *type)
        : _var(var), _type(-1)
{
        static struct ifmedia_description media_types[] = {
                { IFM_ETHER,            "Ethernet" },
                { IFM_IEEE80211,        "802.11" },
                { IFM_ATM,              "ATM" },
                { -1,                   "unknown" },
                { 0, NULL },
        };
        for (int i = 0; media_types[i].ifmt_string != NULL; ++i)
                if (strcasecmp(type, media_types[i].ifmt_string) == 0) {
                        _type = media_types[i].ifmt_word;
                        break;
                }
}

This seems to have stalled; ok if I take it off the 15.0 issues list?

This seems to have stalled; ok if I take it off the 15.0 issues list?

yes, this won't be ready for 15.0.

dhorn2000_gmail.com edited the summary of this revision. (Show Details)

Initial stab at implementing IFM_ETHER for bridge(4)

dhorn2000_gmail.com retitled this revision from Teach bridge interfaces to work with async DHCP (devd config) to Teach bridge interfaces to work with async DHCP (add IFM_ETHER support).Sat, Apr 18, 3:02 PM

I think having it nailed up the way it is for now is a good first step. Ideally we'd have the bridge "state" for something like dhcp be based on the link state of a subset of children interfaces - and if none exist, it does what you're doing.

@ivy @bms what do you think?