diff options
author | Bob Gilligan <gilligan@vyatta.com> | 2011-02-01 10:27:27 -0800 |
---|---|---|
committer | Bob Gilligan <gilligan@vyatta.com> | 2011-02-01 10:52:23 -0800 |
commit | a85d727c301007fb6fff667e6899bcbc00d7b2be (patch) | |
tree | 998ce27b8ec8105e695038a4ca7de4c93ba098e7 /scripts/vyatta_net_name | |
parent | 18d8258e7b7191e5358f1e99999a3721eb9ef167 (diff) | |
download | vyatta-cfg-quagga-a85d727c301007fb6fff667e6899bcbc00d7b2be.tar.gz vyatta-cfg-quagga-a85d727c301007fb6fff667e6899bcbc00d7b2be.zip |
Bugfix 6156: Allow time for renaming to complete before running biosdevname
It appears that biosdevname can be confused if interface renaming is
being performed by other udev worker processes at the same time that
it is running. Since vyatta_net_name does protect the body of its
code with a lock, we can be sure that no other renaming will be
started in other udev worker processes while this one is running in
vyatta_net_name. But renaming being performed by other udev worker
processes that were triggered by previous executions of
vyatta_net_name may still be in progress. This change gives any
interface renaming that was called for by previous invocations of
vyatta_net_name a chance to complete before we call biosdevname.
(cherry picked from commit 9dd41e8481e84bf80fcb0e9c3d7843c8a0b20059)
Diffstat (limited to 'scripts/vyatta_net_name')
-rwxr-xr-x | scripts/vyatta_net_name | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/scripts/vyatta_net_name b/scripts/vyatta_net_name index 5de49b94..c3571f89 100755 --- a/scripts/vyatta_net_name +++ b/scripts/vyatta_net_name @@ -27,7 +27,7 @@ my $UDEVDIR = "/dev/.udev/"; my $VYATTAUDEV = $UDEVDIR . "vyatta"; my $LOCKFILE = $UDEVDIR . ".vyatta-lock"; my $UDEVLOG = $UDEVDIR . "log/"; -my $LOGFILE = $UDEVLOG . "vyatta-net-name"; +my $LOGFILE = $UDEVLOG . "vyatta-net-name.coldplug"; # Check if interface name is free to use sub is_available { @@ -85,6 +85,11 @@ sub biosdevname { # biosdevname works only on ethernet devices return $ifname unless ($ifname =~ /^eth/); + # Let the interface name changes ordered by previous invocations of this + # script complete before we call biosdevname. If we don't, biosdevame + # may generate incorrect name. + sleep 1; + my $biosname = `/sbin/biosdevname --policy all_ethN -i $ifname 2>>$UDEVLOG/biosdevname`; chomp $biosname; @@ -119,6 +124,12 @@ sub parse_config_boot { return $interfaces; } +sub logit { + my ($log, $msg) = @_; + my $now = localtime; + print $log "$now: $msg"; +} + # Determine network name to use based on Vyatta config during boot sub coldplug { my ($ifname, $hwaddr) = @_; @@ -127,7 +138,7 @@ sub coldplug { mkdir ($UDEVLOG); open (my $log, '>>', $LOGFILE) or die "Can't open $LOGFILE : $!"; - print {$log} "lookup $ifname $hwaddr\n"; + logit($log, "lookup $ifname $hwaddr\n"); # parse config file to produce map of existing hw-id values my $interfaces = parse_config_boot(); @@ -135,7 +146,7 @@ sub coldplug { # is name already in config file my $newname = $interfaces->{$hwaddr}; if ($newname) { - print {$log} "use hw-id $hwaddr in config mapped to '$newname'\n"; + logit($log, "use hw-id $hwaddr in config mapped to '$newname'\n"); return $newname; } @@ -153,13 +164,13 @@ sub coldplug { } $newname = biosdevname($ifname); - print {$log} "biosdevname for $ifname returned '$newname'\n"; + logit($log, "biosdevname for $ifname returned '$newname'\n"); unless (is_available($interfaces, $newname)) { $newname = find_available($interfaces, $newname); } - print {$log} "new name for '$ifname' is '$newname'\n", $ifname, $newname; + logit($log, "new name for '$ifname' is '$newname'\n"); close $log; leave_rescan_hint($newname, $hwaddr); |