|
Lines 52-57
Link Here
|
| 52 |
} |
52 |
} |
| 53 |
|
53 |
|
| 54 |
check_if_name_is_free() { |
54 |
check_if_name_is_free() { |
|
|
55 |
# we set it to no at the begining |
| 56 |
WRITE_RULE=no |
| 57 |
# First call: check whether there is an entry for this card! If so, get out of here! Return the name of the persistent IF in PERSISTENT_NAME |
| 58 |
PERSISTENT_NAME=`grep -m 1 "^[^#].*{address}==\"${DEV_ID}\", IMPORT=\"/lib/udev/rename_netiface" $RULE_FILE | sed 's/.*rename\_netiface %k //g; s/\"//g'` |
| 59 |
if [ "${PERSISTENT_NAME}" != "" ]; then |
| 60 |
return 0 |
| 61 |
fi |
| 62 |
# if we come across this point, we set WRITE_RULE to yes |
| 63 |
WRITE_RULE=yes |
| 64 |
# Second call: check whether the IF is used by some card! |
| 55 |
grep -qs "^[^#].*rename_netiface %k $NEWNAME\"" $RULE_FILE && return 1 |
65 |
grep -qs "^[^#].*rename_netiface %k $NEWNAME\"" $RULE_FILE && return 1 |
| 56 |
cat $USED_IFACE_FILE_STUB* \ |
66 |
cat $USED_IFACE_FILE_STUB* \ |
| 57 |
| grep -vs "$DEV_ID" \ |
67 |
| grep -vs "$DEV_ID" \ |
|
Lines 105-111
Link Here
|
| 105 |
esac |
115 |
esac |
| 106 |
# Also check if interface is not an vlan interface |
116 |
# Also check if interface is not an vlan interface |
| 107 |
test -f "/proc/net/vlan/$OLDNAME" && exit 0 |
117 |
test -f "/proc/net/vlan/$OLDNAME" && exit 0 |
| 108 |
declare -i IFNUM=${OLDNAME##$NAMEBASE} |
118 |
# in contrast to the original script, searching should always start at IFNUM=0, |
|
|
119 |
# because we do not know about configurations of the past! |
| 120 |
declare -i IFNUM=0 |
| 109 |
|
121 |
|
| 110 |
if [ "$PHYSDEVBUS" == ccwgroup ] ; then |
122 |
if [ "$PHYSDEVBUS" == ccwgroup ] ; then |
| 111 |
get_device_id() { |
123 |
get_device_id() { |
|
Lines 135-146
Link Here
|
| 135 |
# currently has. If this name is already occupied, then increase the |
147 |
# currently has. If this name is already occupied, then increase the |
| 136 |
# number and try again. |
148 |
# number and try again. |
| 137 |
# To check if a name is occupied we have to look in |
149 |
# To check if a name is occupied we have to look in |
| 138 |
# /etc/udev/rules.d/60-net_*.rules and in /tmp/used_interface_names*. |
150 |
# /etc/udev/rules.d/30-net_*.rules and in /tmp/used_interface_names*. |
| 139 |
# The latter serves as temporary registration file to avoid race |
151 |
# The latter serves as temporary registration file to avoid race |
| 140 |
# conditions. It will be removed when the script exits. |
152 |
# conditions. It will be removed when the script exits. |
| 141 |
|
153 |
|
| 142 |
NEWNAME=$OLDNAME |
154 |
NEWNAME=$OLDNAME |
| 143 |
get_device_id "$OLDNAME" "$2" |
155 |
get_device_id "$OLDNAME" |
| 144 |
if [ -z "$DEV_ID" ] ; then |
156 |
if [ -z "$DEV_ID" ] ; then |
| 145 |
error_exit 4 "no device id for $OLDNAME" |
157 |
error_exit 4 "no device id for $OLDNAME" |
| 146 |
fi |
158 |
fi |
|
Lines 172-179
Link Here
|
| 172 |
error_exit 6 "could not get a free persistent interfacename" \ |
184 |
error_exit 6 "could not get a free persistent interfacename" \ |
| 173 |
"for $OLDNAME ($DEV_ID)" |
185 |
"for $OLDNAME ($DEV_ID)" |
| 174 |
done |
186 |
done |
| 175 |
WRITE_RULE=yes |
|
|
| 176 |
info_mesg "$OLDNAME: new persistent name for $DEV_ID is $NEWNAME" |
187 |
info_mesg "$OLDNAME: new persistent name for $DEV_ID is $NEWNAME" |
|
|
188 |
# check whether we expect our IF at a certain location! |
| 189 |
if [ "${PERSISTENT_NAME}" != "" ]; then |
| 190 |
# check whether the expected name of our IF differs from what we get! |
| 191 |
if [ ${NEWNAME} != ${PERSISTENT_NAME} ] ; then |
| 192 |
if [ -d /sys/class/net/${PERSISTENT_NAME} ]; then |
| 193 |
if nameif -r "${PERSISTENT_NAME}" "${NEWNAME}" 2>/dev/null 1>&2; then |
| 194 |
write_rule || error_exit 8 "Name ${PERSISTENT_NAME} for ${DEV_ID} is NOT" \ |
| 195 |
"persistent" |
| 196 |
info_mesg "${NEWNAME} -> ${PERSISTENT_NAME}: immediate success" |
| 197 |
fi |
| 198 |
usleep $((RANDOM%600+700))000 |
| 199 |
fi |
| 200 |
NEWNAME="${PERSISTENT_NAME}" |
| 201 |
fi |
| 202 |
fi |
| 177 |
fi |
203 |
fi |
| 178 |
if [ -z "$NEWNAME" ] ; then |
204 |
if [ -z "$NEWNAME" ] ; then |
| 179 |
error_exit 7 "cannot get a valid new interface name" |
205 |
error_exit 7 "cannot get a valid new interface name" |