From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matthias Schwarzott Date: Sat, 14 Apr 2007 12:35:10 +0000 Subject: Re: Excluding some device types from persistent-net (xen, s390) Message-Id: <200704141435.10974.zzam@gentoo.org> MIME-Version: 1 Content-Type: multipart/mixed; boundary="Boundary-00=_+pMIGo5CoyCztE5" List-Id: References: <200704120944.10520.zzam@gentoo.org> In-Reply-To: <200704120944.10520.zzam@gentoo.org> To: linux-hotplug@vger.kernel.org --Boundary-00=_+pMIGo5CoyCztE5 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Content-Disposition: inline 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) --Boundary-00=_+pMIGo5CoyCztE5 Content-Type: text/x-diff; charset="iso-8859-15"; name="udev-108-persistent-net-xen.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="udev-108-persistent-net-xen.diff" 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 --Boundary-00=_+pMIGo5CoyCztE5 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ------------------------------------------------------------------------- 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 --Boundary-00=_+pMIGo5CoyCztE5 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ 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 --Boundary-00=_+pMIGo5CoyCztE5--