Bug 261136 - ifconfig vlan option parsing is overly fussy
Summary: ifconfig vlan option parsing is overly fussy
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 13.0-STABLE
Hardware: Any Any
: --- Affects Some People
Assignee: Alexander V. Chernikov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-01-12 04:10 UTC by Daniel O'Connor
Modified: 2022-05-30 11:46 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel O'Connor 2022-01-12 04:10:30 UTC
The VLAN chapter of the handbook (https://docs.freebsd.org/en/books/handbook/advanced-networking/#network-vlan) lists several examples which do not work in FreeBSD 13.

eg
[test13 14:34] ~ >sudo ifconfig video.5 create vlan 5 vlandev video name cameras inet 192.168.20.20/24
ifconfig: ambiguous vlan specification
[test13 14:34] ~ >sudo ifconfig em0.5 create vlan 5 vlandev em0 inet 192.168.20.20/24
ifconfig: ambiguous vlan specification

I attempted to be clever with this:

[test13 14:31] ~ >sudo ifconfig vlan create name em0.5 vlandev em0 vlan 5 192.168.200.0/24
em0.5

However ifconfig shows that it did not assign the vlandev or vlan:
[test13 14:31] ~ >ifconfig
em0: flags=8863<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
	options=481009b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,VLAN_HWFILTER,NOMAP>
	ether 00:0c:29:6c:45:cd
	inet6 fe80::20c:29ff:fe6c:45cd%em0 prefixlen 64 scopeid 0x1
	inet6 2001:44b8:1d2:8900:20c:29ff:fe6c:45cd prefixlen 64 autoconf
	inet 203.31.81.137 netmask 0xffffff00 broadcast 203.31.81.255
	media: Ethernet autoselect (1000baseT <full-duplex>)
	status: active
	nd6 options=23<PERFORMNUD,ACCEPT_RTADV,AUTO_LINKLOCAL>
em0.5: flags=8003<UP,BROADCAST,MULTICAST> metric 0 mtu 1500
	ether 00:00:00:00:00:00
	inet 192.168.200.0 netmask 0xffffff00 broadcast 192.168.200.255
	inet6 fe80::20c:29ff:fe6c:45cd%em0.5 prefixlen 64 tentative scopeid 0x3
	groups: vlan
	vlan: 0 vlanproto: 0x0000 vlanpcp: 0 parent interface: <none>
	nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>

The only working way I have found is as follows:
ifconfig vlan0 create
ifconfig vlan0 name em0.5
ifconfig em0.5 vlan 5 vlandev em0

Looks like this was broken by c7cffd65c5d858425e90b847d2e8e583e3b13bf7
Comment 1 Alexander V. Chernikov freebsd_committer freebsd_triage 2022-01-12 08:04:36 UTC
Thank you for the report!

The shorter way is just running "ifconfig em0.5 create inet 192.168.20.20/24", so ifconfig deduces parent interface and vlan tag from the interface name.

However, the provided example should indeed just work.
I'll take a look at it at the weekend.
Comment 2 commit-hook freebsd_committer freebsd_triage 2022-01-17 09:36:19 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=779fd05344662aeec79c29470258bf657318eab3

commit 779fd05344662aeec79c29470258bf657318eab3
Author:     Alexander V. Chernikov <melifaro@FreeBSD.org>
AuthorDate: 2022-01-17 09:30:26 +0000
Commit:     Alexander V. Chernikov <melifaro@FreeBSD.org>
CommitDate: 2022-01-17 09:35:15 +0000

    ifconfig: improve vlan options parsing

    PR:     261136
    Reported by:    Daniel O'Connor
    MFC after:      2 weeks

 sbin/ifconfig/ifvlan.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)
Comment 3 commit-hook freebsd_committer freebsd_triage 2022-03-28 09:17:14 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=157bf2c9964a54124e05bb7c354d8e5ad784802a

commit 157bf2c9964a54124e05bb7c354d8e5ad784802a
Author:     Alexander V. Chernikov <melifaro@FreeBSD.org>
AuthorDate: 2022-01-17 09:30:26 +0000
Commit:     Alexander V. Chernikov <melifaro@FreeBSD.org>
CommitDate: 2022-03-28 08:50:12 +0000

    ifconfig: improve vlan options parsing

    PR:     261136
    Reported by:    Daniel O'Connor
    MFC after:      2 weeks

    (cherry picked from commit 779fd05344662aeec79c29470258bf657318eab3)

 sbin/ifconfig/ifvlan.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)
Comment 4 commit-hook freebsd_committer freebsd_triage 2022-03-28 15:26:21 UTC
A commit in branch releng/13.1 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=2eb4ac1e6fc946ca8d175863b16602885fae61b7

commit 2eb4ac1e6fc946ca8d175863b16602885fae61b7
Author:     Alexander V. Chernikov <melifaro@FreeBSD.org>
AuthorDate: 2022-01-17 09:30:26 +0000
Commit:     Alexander V. Chernikov <melifaro@FreeBSD.org>
CommitDate: 2022-03-28 15:25:23 +0000

    ifconfig: improve vlan options parsing

    PR:     261136
    Reported by:    Daniel O'Connor
    Approved by:    re(gjb)
    MFC after:      2 weeks

    (cherry picked from commit 779fd05344662aeec79c29470258bf657318eab3)
    (cherry picked from commit 157bf2c9964a54124e05bb7c354d8e5ad784802a)

 sbin/ifconfig/ifvlan.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)
Comment 5 Alexander V. Chernikov freebsd_committer freebsd_triage 2022-05-30 11:44:35 UTC
Should be fixed in 13.1 and 13-STABLE.
I'm going to close it in a couple of days if there are no objections.
Comment 6 Daniel O'Connor 2022-05-30 11:46:31 UTC
I'll close it - sorry, wasn't sure what the protocol was.