Skip to contentSkip to conversation

udev-rules: include *-net-*.rules only if network module is included

PATCH In review Alexander Tsoy 2 participants 2 messages Mar 5, 2014 – Mar 6, 2014 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 udev-rules: include *-net-*.rules only if network module is included

Users have a choice to disable predictable network names by creating a symlink in /etc:
ln -s /dev/null /etc/udev/rules.d/80-net-setup-link.rules

However this doesn't work with non-hostonly initramfs if network drivers are compiled into the kernel - network interfaces gets renamed by udev from initramfs.

So if "network" module is not included in initramfs, let's rename network interfaces during coldplug after switching root.

https://bugs.gentoo.org/show_bug.cgi?id=487184

---
 modules.d/95udev-rules/module-setup.sh | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)
modules.d/95udev-rules/module-setup.sh +10 -8
index 2d36712..199e9a3 100755
@@ -32,8 +32,6 @@ install() {
         60-pcmcia.rules \
         50-udev.rules 95-late.rules \
         50-firmware.rules \
-        75-net-description.rules \
-        80-net-name-slot.rules 80-net-setup-link.rules \
         "$moddir/59-persistent-storage.rules" \
         "$moddir/61-persistent-storage.rules"
 
@@ -43,12 +41,16 @@ install() {
     # eudev rules
     inst_rules 80-drivers-modprobe.rules
 
-    for _i in \
-        ${systemdutildir}/network/*.link \
-        ${hostonly:+/etc/systemd/network/*.link} \
-        ; do
-        [[ -e "$_i" ]] && inst "$_i"
-    done
+    if dracut_module_included "network"; then
+        inst_rules 75-net-description.rules \
+            80-net-name-slot.rules 80-net-setup-link.rules
+        for _i in \
+            ${systemdutildir}/network/*.link \
+            ${hostonly:+/etc/systemd/network/*.link} \
+            ; do
+            [[ -e "$_i" ]] && inst "$_i"
+        done
+    fi
 
     {
         for i in cdrom tape dialout floppy; do
Signature · 1 line
1.8.3.2

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw
Quoted 3 lines · Alexander Tsoy

Users have a choice to disable predictable network names by creating a symlink in /etc:
ln -s /dev/null /etc/udev/rules.d/80-net-setup-link.rules

I would rather let them use the kernel cmdline switch:
net.ifnames=0

That way, it doesn't matter how the udev rules are named.

Quoted 50 lines

However this doesn't work with non-hostonly initramfs if network drivers are compiled into the kernel - network interfaces gets renamed by udev from initramfs.

So if "network" module is not included in initramfs, let's rename network interfaces during coldplug after switching root.

https://bugs.gentoo.org/show_bug.cgi?id=487184

---
 modules.d/95udev-rules/module-setup.sh | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)
modules.d/95udev-rules/module-setup.sh +10 -8
index 2d36712..199e9a3 100755
@@ -32,8 +32,6 @@ install() {
         60-pcmcia.rules \
         50-udev.rules 95-late.rules \
         50-firmware.rules \
-        75-net-description.rules \
-        80-net-name-slot.rules 80-net-setup-link.rules \
         "$moddir/59-persistent-storage.rules" \
         "$moddir/61-persistent-storage.rules"
 
@@ -43,12 +41,16 @@ install() {
     # eudev rules
     inst_rules 80-drivers-modprobe.rules
 
-    for _i in \
-        ${systemdutildir}/network/*.link \
-        ${hostonly:+/etc/systemd/network/*.link} \
-        ; do
-        [[ -e "$_i" ]] && inst "$_i"
-    done
+    if dracut_module_included "network"; then
+        inst_rules 75-net-description.rules \
+            80-net-name-slot.rules 80-net-setup-link.rules
+        for _i in \
+            ${systemdutildir}/network/*.link \
+            ${hostonly:+/etc/systemd/network/*.link} \
+            ; do
+            [[ -e "$_i" ]] && inst "$_i"
+        done
+    fi
 
     {
         for i in cdrom tape dialout floppy; do