summaryrefslogtreecommitdiff
path: root/scripts/vyatta_net_name
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2011-01-24 17:03:46 +1000
committerStephen Hemminger <stephen.hemminger@vyatta.com>2011-01-24 11:54:44 -0800
commit16db4272b78fb6d50fc92f6a24fbf12e2762c64f (patch)
tree607ad7ff74d9447c185ecd3393b2dc25743c95f0 /scripts/vyatta_net_name
parent418cbd74cd45093933e45eb47266d060e0250f67 (diff)
downloadvyatta-cfg-system-16db4272b78fb6d50fc92f6a24fbf12e2762c64f.tar.gz
vyatta-cfg-system-16db4272b78fb6d50fc92f6a24fbf12e2762c64f.zip
Revert "Add debug logging."
This reverts commit b1af934db367d589cf7c78b84e2181a1e72b2aaf. Loggging to /var/log does not work during boot. The root filesystem is read-only when udev is running this script. (cherry picked from commit 47301dbc029652f97847c9288d58c951db56d916)
Diffstat (limited to 'scripts/vyatta_net_name')
-rwxr-xr-xscripts/vyatta_net_name51
1 files changed, 6 insertions, 45 deletions
diff --git a/scripts/vyatta_net_name b/scripts/vyatta_net_name
index e4508c3d..43bed36d 100755
--- a/scripts/vyatta_net_name
+++ b/scripts/vyatta_net_name
@@ -26,7 +26,6 @@ my $UDEVDIR = "/dev/.udev";
my $VYATTAUDEV = $UDEVDIR . "/vyatta";
my $LOCKFILE = $UDEVDIR . "/.vyatta-lock";
my $VYATTACFG = "/opt/vyatta/config/active";
-my $LOGFILE = "/var/log/vyatta/vnn.log";
# Check if interface name is free to use
sub is_available {
@@ -79,13 +78,13 @@ sub leave_rescan_hint {
# Use biosdevname program (ethernet only)
# to try and find name based on PCI slot and DMI info
sub biosdevname {
- my ($ifname, $hwaddr) = @_;
+ my $ifname = shift;
# biosdevname renames wlanX to ethX ??
if ($ifname =~ /^eth/) {
my $biosname = `/sbin/biosdevname --policy all_ethN -i $ifname`;
chomp $biosname;
- logit("biosdevname recommends $biosname for $ifname $hwaddr\n");
+
return $biosname if ($biosname ne '');
}
return $ifname; # Fallback to existing name
@@ -115,10 +114,7 @@ sub coldplug {
# is name already in config file
my $newname = $interfaces->{$hwaddr};
- if ($newname) {
- logit("name for $ifname $hwaddr in config file is $newname\n");
- return $newname;
- }
+ return $newname if ($newname);
# add already assigned names
if (opendir(my $dir, $VYATTAUDEV)) {
@@ -133,11 +129,9 @@ sub coldplug {
}
}
- $newname = biosdevname($ifname, $hwaddr);
+ $newname = biosdevname($ifname);
unless (is_available($interfaces, $newname)) {
- logit("but $newname is not available for $ifname $hwaddr\n");
$newname = find_available($interfaces, $newname);
- logit("So we will use $newname instead for $ifname $hwaddr\n");
}
leave_rescan_hint($newname, $hwaddr);
@@ -167,16 +161,11 @@ sub hotplug {
}
my $newname = $interfaces->{$hwaddr};
- if ($newname) {
- logit("hotplug: name for $ifname $hwaddr in config file is $newname\n");
- return $newname
- }
+ return $newname if ($newname);
- $newname = biosdevname($ifname, $hwaddr);
+ $newname = biosdevname($ifname);
unless (is_available($interfaces, $newname)) {
- logit("but $newname is not available for $ifname $hwaddr\n");
$newname = find_available($interfaces, $newname);
- logit("So we will use $newname instead for $ifname $hwaddr\n");
}
syslog(LOG_INFO, "new name for '%s' is '%s'", $ifname, $newname);
@@ -199,22 +188,6 @@ sub unlock_file {
$LOCKF = undef;
}
-my $LOGF;
-
-sub open_logfile {
- open ($LOGF, '>>', $LOGFILE)
- or die "Can't open log file $LOGFILE : $!";
-}
-
-sub close_logfile {
- close($LOGF);
-}
-
-sub logit {
- my $now = localtime;
- print $LOGF "$now: @_";
-}
-
# This script is called from udev with two arguments
# it outputs the new name (if any) to stdout
if ($#ARGV != 1) {
@@ -226,24 +199,12 @@ my $ifname = $ARGV[0];
my $hwaddr = $ARGV[1];
lock_file;
-
-# Need to log to file instead of syslog because this can be called by
-# udev running early in boot before syslog is started.
-open_logfile;
-
-logit("Starting vyatta_net_name for $ifname $hwaddr\n");
-
my $newname;
if ( -d $VYATTACFG ) {
$newname = hotplug($ifname, $hwaddr);
} else {
$newname = coldplug($ifname, $hwaddr);
}
-
-logit("Returning $newname for $ifname $hwaddr\n");
-
-close_logfile;
-
unlock_file;
print "$newname\n" if ($newname);