Bug 279181 - order of vlan # and vlandev in rc.conf now matters in rc.conf
Summary: order of vlan # and vlandev in rc.conf now matters in rc.conf
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 14.0-STABLE
Hardware: Any Any
: --- Affects Many People
Assignee: Zhenlei Huang
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-05-20 16:14 UTC by mike
Modified: 2024-06-04 01:43 UTC (History)
2 users (show)

See Also:
zlei: mfc-stable14+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description mike 2024-05-20 16:14:53 UTC
Up until RELENG_13, creating a vlan in /etc/rc.conf did not matter if the syntax was 


ifconfig_vlan2="192.168.1.51/24 vlandev igb1 vlan 2"
or 
ifconfig_vlan2="192.168.1.51/24 vlan 2 vlandev igb1"

either used to work on RELENG_13

now only

ifconfig_vlan2="192.168.1.51/24  vlan 2 vlandev igb1"
works on RELENG_14.

Not sure if the issue was intentional or not but should at least be noted if an deliberate POLA

Short discussion at
https://lists.freebsd.org/archives/freebsd-net/2024-May/004968.html
Comment 1 Zhenlei Huang freebsd_committer freebsd_triage 2024-05-21 01:40:52 UTC
Emm, it is not order in rc, but there is something wrong with ifconfig(8).

Steps to repeat:
```
# ifconfig vlan3 create 192.168.2.51/24 vlandev cxl0 vlan 3
ifconfig: both vlan and vlandev must be specified
```
Comment 2 Zhenlei Huang freebsd_committer freebsd_triage 2024-05-21 07:32:59 UTC
Simpler steps to repeat:

```
# ifconfig vlan create
vlan0
# ifconfig vlan0 vlandev cxl0 vlan 100
ifconfig: both vlan and vlandev must be specified
```

I can confirm that is regression by https://reviews.freebsd.org/D35848 , I'm preparing the patch.
Comment 3 Zhenlei Huang freebsd_committer freebsd_triage 2024-05-21 10:20:28 UTC
Hi mike,

May you please have a try with the patch in https://reviews.freebsd.org/D45283 ?
Comment 4 mike 2024-05-21 12:41:35 UTC
(In reply to Zhenlei Huang from comment #3)

thank you so much for fixing! It does indeed work for me

# patch -p1 < /tmp/if.diff
Hmm...  Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|diff --git a/sbin/ifconfig/ifvlan.c b/sbin/ifconfig/ifvlan.c
|--- a/sbin/ifconfig/ifvlan.c
|+++ b/sbin/ifconfig/ifvlan.c
--------------------------
Patching file sbin/ifconfig/ifvlan.c using Plan A...
Hunk #1 succeeded at 60.
Hunk #2 succeeded at 68.
Hunk #3 succeeded at 158.
Hunk #4 succeeded at 176.
Hunk #5 succeeded at 201.
Hunk #6 succeeded at 243.
Hmm...  Ignoring the trailing garbage.
done
.... (make clean,depend,,install)
root@build14:/usr/src/sbin/ifconfig # ifconfig vlan10 10.1.1.1/24 vlan 10 vlandev vtnet0
root@build14:/usr/src/sbin/ifconfig # ifconfig vlan10 destroy
root@build14:/usr/src/sbin/ifconfig # ifconfig vlan10 create
root@build14:/usr/src/sbin/ifconfig # ifconfig vlan10 10.1.1.1/24 vlandev vtnet0 vlan 10
root@build14:/usr/src/sbin/ifconfig #
Comment 5 Zhenlei Huang freebsd_committer freebsd_triage 2024-05-21 14:35:17 UTC
(In reply to mike from comment #4)
That's good news. Thanks for the testing !
Comment 6 commit-hook freebsd_committer freebsd_triage 2024-05-21 16:37:01 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=76df3c57a0abfd24652bfa33982ba136d9d0575b

commit 76df3c57a0abfd24652bfa33982ba136d9d0575b
Author:     Zhenlei Huang <zlei@FreeBSD.org>
AuthorDate: 2024-05-21 16:35:01 +0000
Commit:     Zhenlei Huang <zlei@FreeBSD.org>
CommitDate: 2024-05-21 16:35:01 +0000

    ifconfig: Redo fix vlan/vlanproto reconfiguration

    When the if_vlan(4) interface has not been fully configured, i.e., a
    bare interface without a physical interface associated with it,
    retrieving the current settings of it and unconditionally overwriting
    `params` will result in losing vlandev settings in `params`. That will
    lead to failing to associate the if_vlan(4) interface with the requested
    physical interface and the false report 'both vlan and vlandev must be
    specified'.

    Fix that by checking if the vlan interface has been fully configured.

    The basic VLAN test is slightly modified to cover this case.

    PR:             279181
    Reviewed by:    kp
    Tested by:      Mike Tancsa <mike@sentex.net>
    Fixes:          b82b8055ad44 ifconfig: fix vlan/vlanproto reconfiguration
    MFC after:      3 days
    Differential Revision:  https://reviews.freebsd.org/D45283

 sbin/ifconfig/ifvlan.c   | 31 ++++++++++++++++++++++++++-----
 tests/sys/net/if_vlan.sh | 10 +++++++---
 2 files changed, 33 insertions(+), 8 deletions(-)
Comment 7 commit-hook freebsd_committer freebsd_triage 2024-05-24 16:05:05 UTC
A commit in branch stable/14 references this bug:

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

commit c9188db6f956b30344bc99a13baf57727d4ac97a
Author:     Zhenlei Huang <zlei@FreeBSD.org>
AuthorDate: 2024-05-21 16:35:01 +0000
Commit:     Zhenlei Huang <zlei@FreeBSD.org>
CommitDate: 2024-05-24 16:03:02 +0000

    ifconfig: Redo fix vlan/vlanproto reconfiguration

    When the if_vlan(4) interface has not been fully configured, i.e., a
    bare interface without a physical interface associated with it,
    retrieving the current settings of it and unconditionally overwriting
    `params` will result in losing vlandev settings in `params`. That will
    lead to failing to associate the if_vlan(4) interface with the requested
    physical interface and the false report 'both vlan and vlandev must be
    specified'.

    Fix that by checking if the vlan interface has been fully configured.

    The basic VLAN test is slightly modified to cover this case.

    PR:             279181
    Reviewed by:    kp
    Tested by:      Mike Tancsa <mike@sentex.net>
    Fixes:          b82b8055ad44 ifconfig: fix vlan/vlanproto reconfiguration
    MFC after:      3 days
    Differential Revision:  https://reviews.freebsd.org/D45283

    (cherry picked from commit 76df3c57a0abfd24652bfa33982ba136d9d0575b)

 sbin/ifconfig/ifvlan.c   | 31 ++++++++++++++++++++++++++-----
 tests/sys/net/if_vlan.sh | 10 +++++++---
 2 files changed, 33 insertions(+), 8 deletions(-)
Comment 8 Zhenlei Huang freebsd_committer freebsd_triage 2024-06-04 01:43:26 UTC
It is too late to catch up with 14.1-RELEASE. The fix has been in stable/14. Closing now.