All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matthias Schwarzott <zzam@gentoo.org>
To: linux-hotplug@vger.kernel.org
Subject: Re: Excluding some device types from persistent-net (xen, s390)
Date: Sat, 14 Apr 2007 12:35:10 +0000	[thread overview]
Message-ID: <200704141435.10974.zzam@gentoo.org> (raw)
In-Reply-To: <200704120944.10520.zzam@gentoo.org>

[-- Attachment #1: Type: text/plain, Size: 1966 bytes --]

On Samstag, 14. April 2007, Matthias Schwarzott wrote:
> On Freitag, 13. April 2007, Matthias Schwarzott wrote:
> > On Donnerstag, 12. April 2007, Matthias Schwarzott wrote:
> >
> > xen-devices:
> > # udevinfo -a -p /sys/class/net/eth0
> >
> >   looking at device '/class/net/eth0':
> >     KERNEL=="eth0"
> >     SUBSYSTEM=="net"
> >     DRIVER==""
> >     ATTR{weight}=="64"
> >     ATTR{tx_queue_len}=="1000"
> >     ATTR{flags}=="0x1003"
> >     ATTR{mtu}=="1500"
> >     ATTR{carrier}=="1"
> >     ATTR{broadcast}=="ff:ff:ff:ff:ff:ff"
> >     ATTR{address}=="00:16:3e:08:25:1d"
> >
> >   looking at parent device '/devices/xen/vif-0':
> >     KERNELS=="vif-0"
> >     SUBSYSTEMS=="xen"
> >     DRIVERS=="vif"
> >     ATTRS{devtype}=="vif"
> >     ATTRS{nodename}=="device/vif/0"
> >
> >   looking at parent device '/devices/xen':
> >     KERNELS=="xen"
> >     SUBSYSTEMS==""
> >     DRIVERS==""
> >
> > Perhaps the KERNEL(S) attribute of the parent device can be used for
> > persistence (even though I don't know how the rule should look like) but
> > perhaps just KERNELS=="vif-0" will work. As I think the number refers to
> > the (n+1)-th network interface declared in xen-conf for this domain. And
> > that should be constant, even if mac changes.
> > Better solutions for xen-devices?
>
> Attached is an (untested) implementation, that
Now checked on one system - and corrected all errors :)
The dest of the device link did not has a subsystem link.
Now checking device/devtype == "vif".

> 1. Adds a METHOD setting to write_net_rules
> 2. Adds methods by-mac and by-xen-vif.
> If none specified checking $DEVPATH/device/subsystem - and use by-xen-vif
> in case subsystem is "xen".
> 3. by-mac does what was default before.
> 4. by-xen-vif: Look up the name of the device symlink (VIF_NAME) and adding
> a rule with KERNELS=="$VIF_NAME".
>
>
> For other devices perhaps more such special methods are required.
>

Matthias

-- 
Matthias Schwarzott (zzam)

[-- Attachment #2: udev-108-persistent-net-xen.diff --]
[-- Type: text/x-diff, Size: 1894 bytes --]

diff --git a/extras/rule_generator/write_net_rules b/extras/rule_generator/write_net_rules
index b709200..dd65407 100644
--- a/extras/rule_generator/write_net_rules
+++ b/extras/rule_generator/write_net_rules
@@ -85,21 +85,55 @@ if [ -z "$INTERFACE" ]; then
 	exit 1
 fi
 
-if [ "$1" ]; then
-	MAC_ADDR="$1"
+if [ "${1}" != "${1##by-}" ]; then
+	METHOD="${1}"
+	shift
 else
-	MAC_ADDR=$(sysread address)
-fi
+	# default method
+	METHOD='by-mac'
 
-if [ -z "$MAC_ADDR" ]; then
-	echo "No MAC address for $INTERFACE." >&2
-	exit 1
-fi
-if [ "$MAC_ADDR" = "00:00:00:00:00:00" ]; then
-	echo "NULL MAC address for $INTERFACE." >&2
-	exit 1
+	# get subsystem of device
+	devtype=$(sysread device/devtype)
+	if [ "$devtype" = "vif" ]; then
+		METHOD='by-xen-vif'
+	fi
 fi
 
+case "$METHOD" in
+	by-mac)
+	if [ "$1" ]; then
+		MAC_ADDR="$1"
+	else
+		MAC_ADDR=$(sysread address)
+	fi
+
+	if [ -z "$MAC_ADDR" ]; then
+		echo "No MAC address for $INTERFACE." >&2
+		exit 1
+	fi
+	if [ "$MAC_ADDR" = "00:00:00:00:00:00" ]; then
+		echo "NULL MAC address for $INTERFACE." >&2
+		exit 1
+	fi
+	RULE="ATTRS{address}==\"$MAC_ADDR\""
+	;;
+
+	by-xen-vif)
+	VIF_NAME="$(sysreadlink device)"
+	VIF_NAME=${VIF_NAME##*/}
+	if [ -z "$VIF_NAME" ]; then
+		echo "No VIF name for $INTERFACE." >&2
+		exit 1
+	fi
+	RULE="KERNELS==\"$VIF_NAME\""
+	;;
+
+        *)
+        echo "Invalid argument (must be either by-mac or by-xen-vif)." >&2
+        exit 1
+        ;;
+esac
+
 # Prevent concurrent processes from modifying the file at the same time.
 lock_rules_file
 
@@ -117,7 +151,7 @@ if interface_name_taken; then
 fi
 
 # the DRIVERS key is needed to not match bridges and VLAN sub-interfaces
-match="DRIVERS==\"?*\", ATTRS{address}==\"$MAC_ADDR\""
+match="DRIVERS==\"?*\", $RULE"
 if [ $basename = "ath" -o $basename = "wlan" ]; then
 	match="$match, ATTRS{type}==\"1\"" # do not match the wifi* interfaces
 fi

[-- Attachment #3: Type: text/plain, Size: 345 bytes --]

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

[-- Attachment #4: Type: text/plain, Size: 226 bytes --]

_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

  parent reply	other threads:[~2007-04-14 12:35 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-12  7:44 Excluding some device types from persistent-net (xen, s390) Matthias Schwarzott
2007-04-12 10:14 ` Kay Sievers
2007-04-12 10:33 ` Matthias Schwarzott
2007-04-12 11:33 ` Cornelia Huck
2007-04-12 12:30 ` Kay Sievers
2007-04-12 13:22 ` Matthias Schwarzott
2007-04-12 13:47 ` Cornelia Huck
2007-04-12 14:12 ` Mike Frysinger
2007-04-13 14:44 ` Cornelia Huck
2007-04-13 14:51 ` Mike Frysinger
2007-04-13 15:05 ` Cornelia Huck
2007-04-13 20:08 ` Matthias Schwarzott
2007-04-14 11:46 ` Matthias Schwarzott
2007-04-14 12:35 ` Matthias Schwarzott [this message]
2007-04-16  8:16 ` Cornelia Huck
2007-04-18 21:00 ` Matthias Schwarzott
2007-04-20 11:27 ` Cornelia Huck
2007-04-21 13:35 ` Matthias Schwarzott
2007-04-23  9:03 ` Cornelia Huck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200704141435.10974.zzam@gentoo.org \
    --to=zzam@gentoo.org \
    --cc=linux-hotplug@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.