From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matthias Schwarzott Date: Sat, 14 Apr 2007 11:46:32 +0000 Subject: Re: Excluding some device types from persistent-net (xen, s390) Message-Id: <200704141346.32131.zzam@gentoo.org> MIME-Version: 1 Content-Type: multipart/mixed; boundary="Boundary-00=_Y8LIG/lA36groNU" List-Id: References: <200704120944.10520.zzam@gentoo.org> In-Reply-To: <200704120944.10520.zzam@gentoo.org> To: linux-hotplug@vger.kernel.org --Boundary-00=_Y8LIG/lA36groNU Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline 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 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 PS: by-path could also be added. -- Matthias Schwarzott (zzam) --Boundary-00=_Y8LIG/lA36groNU Content-Type: text/x-diff; charset="iso-8859-1"; 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..47f14cf 100644 --- a/extras/rule_generator/write_net_rules +++ b/extras/rule_generator/write_net_rules @@ -85,20 +85,57 @@ 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) + # get subsystem of device + SUBSYSTEM=$(sysreadlink device/subsystem) + SUBSYSTEM=${SUBSYSTEM##*/} + case $SUBSYSTEM in + xen) + METHOD='by-xen-vif' + ;; + *) + METHOD='by-mac' + ;; + esac 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 +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 +154,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=_Y8LIG/lA36groNU 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=_Y8LIG/lA36groNU 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=_Y8LIG/lA36groNU--