diff options
author | DmitriyEshenko <dmitriy.eshenko@vyos.io> | 2021-11-08 17:20:03 +0000 |
---|---|---|
committer | DmitriyEshenko <dmitriy.eshenko@vyos.io> | 2021-11-09 19:09:40 +0000 |
commit | ee02ca93ec7be75edd0ec4c0e07fe5d51a45edc6 (patch) | |
tree | 550eded1f03e3479231d9df89253f9debb392c43 | |
parent | 73be449b1cd09f3ca86400753630fb4804fbeca7 (diff) | |
download | vyos-1x-ee02ca93ec7be75edd0ec4c0e07fe5d51a45edc6.tar.gz vyos-1x-ee02ca93ec7be75edd0ec4c0e07fe5d51a45edc6.zip |
interface-names: T3871: Add temporary interface names to properly renaming
-rw-r--r-- | src/etc/udev/rules.d/62-temporary-interface-rename.rules | 1 | ||||
-rw-r--r-- | src/etc/udev/rules.d/65-vyos-net.rules | 5 | ||||
-rwxr-xr-x | src/helpers/vyos_net_name | 17 |
3 files changed, 12 insertions, 11 deletions
diff --git a/src/etc/udev/rules.d/62-temporary-interface-rename.rules b/src/etc/udev/rules.d/62-temporary-interface-rename.rules new file mode 100644 index 000000000..4a579dcab --- /dev/null +++ b/src/etc/udev/rules.d/62-temporary-interface-rename.rules @@ -0,0 +1 @@ +SUBSYSTEM=="net", ACTION=="add", KERNEL=="eth*", DRIVERS=="?*", NAME="e$env{IFINDEX}" diff --git a/src/etc/udev/rules.d/65-vyos-net.rules b/src/etc/udev/rules.d/65-vyos-net.rules index c8d5750dd..32ae352de 100644 --- a/src/etc/udev/rules.d/65-vyos-net.rules +++ b/src/etc/udev/rules.d/65-vyos-net.rules @@ -4,11 +4,8 @@ ACTION!="add", GOTO="vyos_net_end" SUBSYSTEM!="net", GOTO="vyos_net_end" -# ignore the interface if a name has already been set -NAME=="?*", GOTO="vyos_net_end" - # Do name change for ethernet and wireless devices only -KERNEL!="eth*|wlan*", GOTO="vyos_net_end" +KERNEL!="eth*|wlan*|e*", GOTO="vyos_net_end" # ignore "secondary" monitor interfaces of mac80211 drivers KERNEL=="wlan*", ATTRS{type}=="803", GOTO="vyos_net_end" diff --git a/src/helpers/vyos_net_name b/src/helpers/vyos_net_name index 0652e98b1..5d9535cf0 100755 --- a/src/helpers/vyos_net_name +++ b/src/helpers/vyos_net_name @@ -77,10 +77,12 @@ def get_biosdevname(ifname: str) -> str: XXX: This throws an error, and likely has for a long time, unnoticed since vyatta_net_name redirected stderr to /dev/null. """ - if 'eth' not in ifname: - return ifname + intf = f"eth{re.sub(r'[^0-9]', '', ifname)}" if 'e' == ifname[0] else ifname + + if 'eth' not in intf: + return intf if os.path.isdir('/proc/xen'): - return ifname + return intf time.sleep(1) @@ -90,7 +92,7 @@ def get_biosdevname(ifname: str) -> str: logging.error(f'biosdevname error: {e}') biosname = '' - return ifname if biosname == '' else biosname + return intf if biosname == '' else biosname def leave_rescan_hint(intf_name: str, hwid: str): """Write interface information reported by udev @@ -186,9 +188,9 @@ def on_boot_event(intf_name: str, hwid: str, predefined: str = '') -> str: interfaces = get_configfile_interfaces() logging.debug(f"config file interfaces are {interfaces}") - if hwid in list(interfaces) and intf_name == interfaces[hwid]: - logging.info(f"use mapping from config file: '{hwid}' -> '{intf_name}'") - return intf_name + if hwid in list(interfaces): + logging.info(f"use mapping from config file: '{hwid}' -> '{interfaces[hwid]}'") + return interfaces[hwid] add_assigned_interfaces(interfaces) logging.debug(f"adding assigned interfaces: {interfaces}") @@ -223,6 +225,7 @@ lock.acquire() if not boot_configuration_complete(): res = on_boot_event(argv[1], argv[2], predefined=predef_name) logging.debug(f"on boot, returned name is {res}") + print(res) else: logging.debug("boot configuration complete") lock.release() |