From cfdaac1aa1c9f34e6950824ddde0208f053506cdcfdf3e4d472f9ebd78d7e24b Mon Sep 17 00:00:00 2001 From: "Dr. Werner Fink" Date: Thu, 11 Jun 2015 12:01:49 +0000 Subject: [PATCH] . OBS-URL: https://build.opensuse.org/package/show/Base:System/udev-persistent-ifnames?expand=0&rev=2 --- 75-persistent-net-generator.rules | 3 ++ 76-net-sriov-names.rules | 19 -------- net-set-sriov-names | 79 ------------------------------- udev-persistent-ifnames.changes | 6 +++ udev-persistent-ifnames.spec | 16 +++---- 5 files changed, 16 insertions(+), 107 deletions(-) delete mode 100644 76-net-sriov-names.rules delete mode 100644 net-set-sriov-names diff --git a/75-persistent-net-generator.rules b/75-persistent-net-generator.rules index bbd3241..32881c4 100644 --- a/75-persistent-net-generator.rules +++ b/75-persistent-net-generator.rules @@ -75,6 +75,9 @@ ENV{LAYER2}!="0", ATTR{dev_id}=="?*", ENV{MATCHDEVID}="$attr{dev_id}" # do not use "locally administered" MAC address ENV{MATCHADDR}=="?[2367abef]:*", ENV{MATCHADDR}="" +# if mac is "locally administered", then use $id (KERNELS) and $driver (DRIVERS) +ENV{MATCHADDR}=="", DRIVERS=="?*", SUBSYSTEMS=="pci", ENV{MATCHID}="$id", ENV{MATCHDRV}="$driver" + # do not use empty address ENV{MATCHADDR}=="00:00:00:00:00:00", ENV{MATCHADDR}="" diff --git a/76-net-sriov-names.rules b/76-net-sriov-names.rules deleted file mode 100644 index 78b9674..0000000 --- a/76-net-sriov-names.rules +++ /dev/null @@ -1,19 +0,0 @@ -# do not edit this file, it will be overwritten on update -# -# rename SRIOV virtual function interfaces - -ACTION=="remove", GOTO="net-sriov-names_end" -SUBSYSTEM!="net", GOTO="net-sriov-names_end" -KERNEL!="eth*", GOTO="net-sriov-names_end" -NAME=="?*", GOTO="net-sriov-names_end" - -IMPORT{cmdline}="net.ifnames" -ENV{net.ifnames}=="1", GOTO="net-sriov-names_end" - -SUBSYSTEM=="net", SUBSYSTEMS=="pci", ACTION=="add", NAME=="?*", ENV{INTERFACE_NEW}="$name" -SUBSYSTEM=="net", SUBSYSTEMS=="pci", ACTION=="add", IMPORT{program}="net-set-sriov-names" - -# rename interface if needed -ENV{INTERFACE_NEW}=="?*", NAME="$env{INTERFACE_NEW}" - -LABEL="net-sriov-names_end" diff --git a/net-set-sriov-names b/net-set-sriov-names deleted file mode 100644 index 94ee5a4..0000000 --- a/net-set-sriov-names +++ /dev/null @@ -1,79 +0,0 @@ -#!/bin/bash -e -# -# This script is run to rename virtual interfaces -# - -if [ -n "$UDEV_LOG" ]; then - if [ "$UDEV_LOG" -ge 7 ]; then - set -x - fi -fi - -# according to dev_new_index(), ifindex is within [1, INT_MAX] -int_max=$(/usr/bin/getconf INT_MAX) -ifindex_before() { - a=$1 - b=$2 - - ((0 < (b - a) && (b - a) < int_max / 2 || - -1 * int_max < (b - a) && (b - a) < -1 * int_max / 2)) -} - -rename_interface() { - local src_net=$1 - local dest_net=$2 - local err=0 - - /sbin/ip link set dev $src_net down - /sbin/ip link set dev $src_net name $dest_net -} - -if [ -z "$INTERFACE" ]; then - echo "missing \$INTERFACE" >&2 - exit 1 -fi - -if [ -e "/sys/class/net/$INTERFACE/device/physfn" ]; then - pf=$(ls -1 "/sys/class/net/$INTERFACE/device/physfn/net") - if [ $(echo "$pf" | wc -l) -ne 1 ]; then - echo "too many pf's" >&2 - exit 1 - fi - read vfindex < "/sys/class/net/$INTERFACE/ifindex" - read pfindex < "/sys/class/net/$pf/ifindex" - if ifindex_before $pfindex $vfindex; then - bus_info=$(basename $(readlink "/sys/class/net/$INTERFACE/device")) - for virtfn in "/sys/class/net/$pf/device/"virtfn*; do - if [ "$(basename $(readlink "$virtfn"))" = "$bus_info" ]; then - vfnum=$(basename "$virtfn") - vfnum=${vfnum#virtfn} - echo "INTERFACE_NEW=$pf.vf$vfnum" - exit 0 - fi - done - fi -fi - -read pfindex < "/sys/class/net/$INTERFACE/ifindex" -shopt -s nullglob -for virtfn in "/sys/class/net/$INTERFACE/device/"virtfn*; do - vf=$(ls -1 "$virtfn/net") - if [ $(echo "$vf" | wc -l) -ne 1 ]; then - echo "too many vf's" >&2 - exit 1 - fi - read vfindex < "/sys/class/net/$vf/ifindex" - if ifindex_before $vfindex $pfindex; then - vfnum=$(basename "$virtfn") - vfnum=${vfnum#virtfn} - if [ "$INTERFACE_NEW" ]; then - new_name=$INTERFACE_NEW - else - new_name=$INTERFACE - fi - new_name="$new_name.vf$vfnum" - if [ "$vf" != "$new_name" ]; then - rename_interface "$vf" "$new_name" - fi - fi -done diff --git a/udev-persistent-ifnames.changes b/udev-persistent-ifnames.changes index d43190f..d19b6e8 100644 --- a/udev-persistent-ifnames.changes +++ b/udev-persistent-ifnames.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Thu Jun 11 12:00:09 UTC 2015 - werner@suse.de + +- rules: support "locally administered" mac address in persistent rules (bnc#921831) +- rules: drop 76-net-sriov-names.rules and net-set-sriov-names (bnc#921831) + ------------------------------------------------------------------- Mon May 18 18:27:59 UTC 2015 - jengelh@inai.de diff --git a/udev-persistent-ifnames.spec b/udev-persistent-ifnames.spec index 28567b6..71237b6 100644 --- a/udev-persistent-ifnames.spec +++ b/udev-persistent-ifnames.spec @@ -1,7 +1,7 @@ # # spec file for package udev-persistent-ifnames # -# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2015 SUSE LINUX Products GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,19 +17,17 @@ Name: udev-persistent-ifnames -Version: 0 +Version: 0.1 Release: 0 Summary: Persistent classic network interface naming scheme License: GPL-2.0 Group: System/Base -Source: 75-persistent-net-generator.rules -Source2: 76-net-sriov-names.rules -Source3: rule_generator.functions -Source4: write_net_rules -Source5: net-set-sriov-names +Source0: 75-persistent-net-generator.rules +Source1: rule_generator.functions +Source2: write_net_rules BuildArch: noarch -BuildRoot: %_tmppath/%name-%version-build +BuildRoot: %{_tmppath}/%{name}-%{version}-build %description This package, when installed, disables the default "Predictable @@ -54,7 +52,7 @@ install -pm0644 \ "%_sourcedir"/*.rules \ "$b/%_prefix/lib/udev/rules.d/" install -pm0755 \ - "%_sourcedir"/{net-set-sriov-names,rule_generator.functions} \ + "%_sourcedir"/rule_generator.functions \ "%_sourcedir"/write_net_rules \ "$b/%_prefix/lib/udev/"