Dr. Werner Fink 2015-06-11 12:01:49 +00:00 committed by Git OBS Bridge
parent d585771c9a
commit cfdaac1aa1
5 changed files with 16 additions and 107 deletions

View File

@ -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}=""

View File

@ -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"

View File

@ -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

View File

@ -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

View File

@ -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/"