Page MenuHomePhabricator

Implementation udev predefined interface naming
Closed, ResolvedPublic

Description

Exist many problem with order interfaces for some HW and VM. e.g. if VMWare use more 4 interfaces, then interfaces sequence will be various.
We can use udev rules for these and other platforms.
Detect by dmi/board_name or dmi/sys_vendor and following rules

For VMWare

ATTR{[dmi/id]sys_vendor}!="VMware, Inc.", GOTO="end_vmware_nic"

ACTION=="add", SUBSYSTEM=="net", KERNELS=="0000:0b:00.0", ENV{VYOS_IFNAME}="eth0"
ACTION=="add", SUBSYSTEM=="net", KERNELS=="0000:13:00.0", ENV{VYOS_IFNAME}="eth1"
ACTION=="add", SUBSYSTEM=="net", KERNELS=="0000:1b:00.0", ENV{VYOS_IFNAME}="eth2"
ACTION=="add", SUBSYSTEM=="net", KERNELS=="0000:04:00.0", ENV{VYOS_IFNAME}="eth3"
ACTION=="add", SUBSYSTEM=="net", KERNELS=="0000:0c:00.0", ENV{VYOS_IFNAME}="eth4"
ACTION=="add", SUBSYSTEM=="net", KERNELS=="0000:14:00.0", ENV{VYOS_IFNAME}="eth5"
ACTION=="add", SUBSYSTEM=="net", KERNELS=="0000:1c:00.0", ENV{VYOS_IFNAME}="eth6"

LABEL="end_vmware_nic"

For Edge-Core model SAF51015I-0318-EC

ATTR{[dmi/id]board_name}!="SAF51015I-0318-EC", GOTO="end_ec_nic"

ACTION=="add", SUBSYSTEM=="net", KERNELS=="0000:02:00.0", ENV{VYOS_IFNAME}="eth1"
ACTION=="add", SUBSYSTEM=="net", KERNELS=="0000:03:00.0", ENV{VYOS_IFNAME}="eth2"
ACTION=="add", SUBSYSTEM=="net", KERNELS=="0000:04:00.0", ENV{VYOS_IFNAME}="eth3"
ACTION=="add", SUBSYSTEM=="net", KERNELS=="0000:05:00.0", ENV{VYOS_IFNAME}="eth4"
ACTION=="add", SUBSYSTEM=="net", KERNELS=="0000:06:00.0", ENV{VYOS_IFNAME}="eth5"
ACTION=="add", SUBSYSTEM=="net", KERNELS=="0000:06:00.1", ENV{VYOS_IFNAME}="eth6"
ACTION=="add", SUBSYSTEM=="net", KERNELS=="0000:06:00.2", ENV{VYOS_IFNAME}="eth7"
ACTION=="add", SUBSYSTEM=="net", KERNELS=="0000:06:00.3", ENV{VYOS_IFNAME}="eth8"
ACTION=="add", SUBSYSTEM=="net", KERNELS=="0000:0a:00.0", ENV{VYOS_IFNAME}="eth9"
ACTION=="add", SUBSYSTEM=="net", KERNELS=="0000:0a:00.1", ENV{VYOS_IFNAME}="eth10"
ACTION=="add", SUBSYSTEM=="net", KERNELS=="0000:0b:00.0", ENV{VYOS_IFNAME}="eth11"
ACTION=="add", SUBSYSTEM=="net", KERNELS=="0000:0b:00.1", ENV{VYOS_IFNAME}="eth12"

LABEL="end_ec_nic"

Details

Difficulty level
Unknown (require assessment)
Version
1.2.4-epa1
Why the issue appeared?
Will be filled on close
Is it a breaking change?
Perfectly compatible

Event Timeline

Dmitry changed the task status from Open to In progress.Dec 24 2019, 1:57 PM
Dmitry created this task.

Note: If we have interfaces with description on device panel, like WAN, DMZ, etc, we can use predefined alias in this case.


Simple rules:

vyos@QAT-R1:~$ sudo cat /lib/udev/rules.d/64-vyos-SAF51003I-net.rules 
ATTR{[dmi/id]board_name}!="SAF51003I", GOTO="end_ec_nic"

ACTION=="add", SUBSYSTEM=="net", KERNELS=="0000:02:00.0", ENV{VYOS_IFNAME}="eth1",  ATTR{ifalias}="LAN1"
ACTION=="add", SUBSYSTEM=="net", KERNELS=="0000:02:00.1", ENV{VYOS_IFNAME}="eth2",  ATTR{ifalias}="LAN2"
ACTION=="add", SUBSYSTEM=="net", KERNELS=="0000:02:00.2", ENV{VYOS_IFNAME}="eth3",  ATTR{ifalias}="LAN3"
ACTION=="add", SUBSYSTEM=="net", KERNELS=="0000:02:00.3", ENV{VYOS_IFNAME}="eth4",  ATTR{ifalias}="LAN4"
ACTION=="add", SUBSYSTEM=="net", KERNELS=="0000:05:00.0", ENV{VYOS_IFNAME}="eth5",  ATTR{ifalias}="LAN5"
ACTION=="add", SUBSYSTEM=="net", KERNELS=="0000:05:00.1", ENV{VYOS_IFNAME}="eth6",  ATTR{ifalias}="LAN6"
ACTION=="add", SUBSYSTEM=="net", KERNELS=="0000:05:00.2", ENV{VYOS_IFNAME}="eth7",  ATTR{ifalias}="LAN7"
ACTION=="add", SUBSYSTEM=="net", KERNELS=="0000:05:00.3", ENV{VYOS_IFNAME}="eth8",  ATTR{ifalias}="LAN8"
ACTION=="add", SUBSYSTEM=="net", KERNELS=="0000:08:00.0", ENV{VYOS_IFNAME}="eth9",  ATTR{ifalias}="DMZ"
ACTION=="add", SUBSYSTEM=="net", KERNELS=="0000:08:00.1", ENV{VYOS_IFNAME}="eth10", ATTR{ifalias}="WAN"

LABEL="end_ec_nic"

show interfaces will display helpful interfaces aliases.

vyos@QAT-R1:~$ show interfaces
Codes: S - State, L - Link, u - Up, D - Down, A - Admin Down
Interface        IP Address                        S/L  Description
---------        ----------                        ---  -----------
eth1             -                                 u/D  LAN1 
eth2             -                                 u/D  LAN2 
eth3             -                                 u/D  LAN3 
eth4             -                                 u/D  LAN4 
eth5             -                                 u/D  LAN5 
eth6             -                                 u/D  LAN6 
eth7             -                                 u/D  LAN7 
eth8             -                                 u/D  LAN8 
eth9             -                                 u/D  DMZ 
eth10            -                                 u/u  WAN 
lo               127.0.0.1/8                       u/u  
                 ::1/128

Successfully tested on 1.3. PR for current branch https://github.com/vyos/vyatta-cfg-system/pull/113

@jjakob for equuleus too, wait for merge PR. We have also some ideas how we can improve net naming, and fix issues with renameX interfaces after boot.

pasik added a subscriber: pasik.Dec 27 2019, 9:55 AM
syncer closed this task as Resolved.Jan 1 2020, 1:13 PM
syncer moved this task from Need Triage to Finished on the VyOS 1.3 Equuleus board.
syncer moved this task from Needs Triage to Finished on the VyOS 1.2 Crux (VyOS 1.2.4) board.