Why Are VLAN Interface Names Forced to Start With 'vlan0'

Started by Al Muckart, November 30, 2026, 06:00:46 AM

Previous topic - Next topic
November 30, 2026, 06:00:46 AM Last Edit: November 30, 2026, 06:02:22 AM by Al Muckart
OPNsense won't let me create a VLAN interface whose name doesn't start with 'vlan0'.

This isn't a FreeBSD restriction, and it makes it impossible to properly associate a VLAN subinterface's name with its parent. It also eats five of the 15 characters available for naming.

Is it inherited from pfSense or is there some hidden reason for it?

Thanks.

This is not a FreeBSD restriction, nor is it inherited from pfSense. In fact, I raised similar concerns when the naming scheme was changed back in 2022.

There were essentially three reasons for the current restrictions:

1. Support for stacked VLANs (QinQ): The old naming convention (`igb0_vlan100`) was abandoned in 22.1.4 because stacked VLANs (`igb0_vlan100_vlan200`) could exceed FreeBSD's 15-character interface name limit.

  https://forum.opnsense.org/index.php?topic=27931.0

2. Avoiding naming collisions: The leading zero is intentional to avoid collisions with interface names automatically generated by FreeBSD's interface cloning mechanism. The actual commit that introduced the stricter validation can be found here:

  https://github.com/opnsense/core/commit/2d74c6b641d7dfd0594cb4e8ca84b25667c599bf

3. Legacy code: This is probably the most relevant reason for not allowing arbitrary names. Franco explained in a German forum thread in January 2023 that OPNsense has historically relied on string matching of interface names to determine interface types. Unfortunately, these checks are not consistent throughout the codebase. Allowing arbitrary names could therefore cause subtle problems, while refactoring those checks could introduce regressions.

  https://forum.opnsense.org/index.php?topic=31802.0

Technically, you can still rename VLAN interfaces by editing `config.xml`, provided you update all references accordingly. I would be cautious about completely arbitrary names, though, given Franco's explanation.

IMHO, decoupling VLAN interface names from their parent interfaces and enforcing a particular naming convention are two separate design decisions. While I can understand the rationale for the former, the latter appears to be primarily a consequence of technical debt rather than an inherent technical necessity.

It would be interesting to know whether these limitations in the OPNsense codebase still exist today as technical debt to the same extent as they did in 2022/2023.
Intel N100, 4* I226-V, 2* 82559, 16 GByte, 500 GByte NVME, Leox LXT-010H-D

1100 down / 450 up, Bufferbloat A+

Thank you for that considered and detailed explanation, I really appreciate it.

We'd briefly discussed extending device names to 32 characters (or even 64) with FreeBSD devs which would free this up a bit more, but it's quite tedious to do this while also retaining kernel compatibility with the short fixed name already embedded in existing structures. A nicer alternative would be an alias name which doesn't have this restriction but it adds a lot of plumbing which nobody has committed to.

Even with longer names embedding information into the device names has downsides during reconfiguration where e.g. a parent changes or when stacking for QinQ or adding the IDs to them which. em0.1.2 looks pretty innocent, but if you fiddle with the VLAN which has ID 1 you're forcing a rename of the device which brings life cycle concerns and you also don't know how the kernel reacts on such renames with certain drivers (are they going to reset what you don't actually want).

The much nicer way would be to use a UUID as a device name, but that would also raise some complaints by people. We can't do it anyway, because 16 characters is a bit short either way.


Cheers,
Franco

Quote from: Al Muckart on November 30, 2026, 09:40:24 AMThank you for that considered and detailed explanation, I really appreciate it.
+1 :)

I was a bit confused by all of this too when setting up my first VLAN Interface at the time, but eventually learned to live with it's weirdness, however totally forgot to ask why it is the way it is...

Now I know!
Weird guy who likes everything Linux and *BSD on PC/Laptop/Tablet/Mobile and funny little ARM based boards :)

Quote from: franco on November 30, 2026, 11:26:50 AMWe'd briefly discussed extending device names to 32 characters (or even 64) with FreeBSD devs which would free this up a bit more, but it's quite tedious to do this while also retaining kernel compatibility with the short fixed name already embedded in existing structures. A nicer alternative would be an alias name which doesn't have this restriction but it adds a lot of plumbing which nobody has committed to.

That does sound like a thing that would have a lot of suprise corner cases. FreeBSD is already a lot better than Linux for this. In FreeBSD ifconfig shows the description. The lack of that in Linux has been annoying me for years :)

Quote from: franco on November 30, 2026, 11:26:50 AMEven with longer names embedding information into the device names has downsides during reconfiguration where e.g. a parent changes or when stacking for QinQ or adding the IDs to them which. em0.1.2 looks pretty innocent, but if you fiddle with the VLAN which has ID 1 you're forcing a rename of the device which brings life cycle concerns and you also don't know how the kernel reacts on such renames with certain drivers (are they going to reset what you don't actually want).

That aspect did occur to me after I made the post. I'm very used to vlans being named for their parent interfaces on commercial routing platforms so the idea that when a VLAN moves its interface name changes is normal to me but in the OPNsense context being able to shift a VLAN between parent interfaces without renaming it is nice.

Quote from: franco on November 30, 2026, 11:26:50 AMThe much nicer way would be to use a UUID as a device name, but that would also raise some complaints by people. We can't do it anyway, because 16 characters is a bit short either way.

UUIDs would drive me nuts :)

If I were going to make any change to it at all I'd change them to vl.<tag> by default (the sequencing in the current code gets annoying if you don't specify the name at creation) or vl.<string> if the user supplies a name. It's a common abbreviation and saves a few characters compared to the current state.

Thanks.

vl saves two characters and may clash with an existing driver name

vl isn't taken yet, but that doesn't mean it won't be in the future.

e.g. vr is taken https://man.freebsd.org/cgi/man.cgi?query=vr (not that it matters too much, but just to illustrate that this is very difficult to navigate with future concerns in mind as well)

Also keep in mind that traditionally a lot of driver matching code expects [a-z]+[0+9]+ as a device name which makes giving freedom in naming a slippery slope, too.


Cheers,
Franco