[PATCH 7/7] Avoid generating udev rules for master interfaces

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


From: Cong Wang <xiyou.wangcong@xxxxxxxxx>

Vlan/bridge/bonding device has the same mac address with its underlying
physical device, if we generate udev rules for vlan NIC too,
its physical device name will be override.

This looks a little ugly, but I can't find any better way to handle this.

Cc: Dave Young <dyoung@xxxxxxxxxx>
Cc: Harald Hoyer <harald@xxxxxxxxxx>
Cc: Vivek Goyal <vgoyal@xxxxxxxxxx>
Signed-off-by: Cong Wang <xiyou.wangcong@xxxxxxxxx>
---
 modules.d/40network/ifname-genrules.sh |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/modules.d/40network/ifname-genrules.sh b/modules.d/40network/ifname-genrules.sh
index e188c88..89621a2 100755
--- a/modules.d/40network/ifname-genrules.sh
+++ b/modules.d/40network/ifname-genrules.sh
@@ -8,9 +8,15 @@ if ! getarg ifname= >/dev/null ; then
 fi
 
 {
+    [ -e /tmp/vlan.info ] && source /tmp/vlan.info
+    [ -e /tmp/bridge.info ] && source /tmp/bridge.info
+    [ -e /tmp/bond.info ] && source /tmp/bond.info
     for p in $(getargs ifname=); do
         parse_ifname_opts $p
-        printf 'SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="%s", ATTR{type}=="1", NAME="%s"\n' "$ifname_mac" "$ifname_if"
+        #Hack: vlan, bridge, bonding devices may have the same mac address with its physical device
+        if [ "$ifname_if" != "$vlanname" ] && [ "$ifname_if" != "$bridgename" ] && [ "$ifname_if" != "$bondname" ]; then
+            printf 'SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="%s", ATTR{type}=="1", NAME="%s"\n' "$ifname_mac" "$ifname_if"
+        fi
     done
 
     # Rename non named interfaces out of the way for named ones.
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe initramfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Home]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]    [Yosemite Photos]    [Free Online Dating]     [Linux Kernel]     [Linux SCSI]     [XFree86]

Add to Google Powered by Linux