summaryrefslogtreecommitdiff
path: root/scripts/vyatta_net_name
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/vyatta_net_name')
-rwxr-xr-xscripts/vyatta_net_name39
1 files changed, 28 insertions, 11 deletions
diff --git a/scripts/vyatta_net_name b/scripts/vyatta_net_name
index 53ae9fba..825bf86f 100755
--- a/scripts/vyatta_net_name
+++ b/scripts/vyatta_net_name
@@ -21,7 +21,7 @@ use Sys::Syslog qw(:standard :macros);
use Fcntl qw(:flock);
my $BOOTFILE = "/opt/vyatta/etc/config/config.boot";
-my $VYATTACFG = "/opt/vyatta/config/active";
+my $VYATTACFG = "/opt/vyatta/config/active/interfaces";
my $UDEVDIR = "/run/udev/";
my $VYATTAUDEV = $UDEVDIR . "vyatta";
@@ -137,7 +137,7 @@ sub logit {
# Determine network name to use based on Vyatta config during boot
sub coldplug {
- my ($ifname, $hwaddr) = @_;
+ my ($ifname, $hwaddr, $predef_ifname) = @_;
# at this time root directory is read-only so use log file instead
mkdir ($UDEVLOG);
@@ -168,8 +168,14 @@ sub coldplug {
}
}
- $newname = biosdevname($ifname);
- logit($log, "biosdevname for $ifname returned '$newname'\n");
+ if ($predef_ifname) {
+ $newname = $predef_ifname;
+ logit($log, "predefined interface name for $ifname returned '$newname'\n");
+ }
+ else {
+ $newname = biosdevname($ifname);
+ logit($log, "biosdevname for $ifname returned '$newname'\n");
+ }
unless (is_available($interfaces, $newname)) {
$newname = find_available($interfaces, $newname);
@@ -185,7 +191,7 @@ sub coldplug {
# Determine name from active config
sub hotplug {
- my ($ifname, $hwaddr) = @_;
+ my ($ifname, $hwaddr, $predef_ifname) = @_;
# real filesystem available use real logging
openlog("vyatta-net-name", "", LOG_DAEMON);
@@ -211,8 +217,14 @@ sub hotplug {
return $newname;
}
- $newname = biosdevname($ifname);
- syslog(LOG_DEBUG, "biosdevname for %s returned '%s'", $ifname, $newname);
+ if ($predef_ifname) {
+ $newname = $predef_ifname;
+ syslog(LOG_DEBUG, "predefined interface name for %s returned '%s'", $ifname, $newname);
+ }
+ else{
+ $newname = biosdevname($ifname);
+ syslog(LOG_DEBUG, "biosdevname for %s returned '%s'", $ifname, $newname);
+ }
unless (is_available($interfaces, $newname)) {
$newname = find_available($interfaces, $newname);
@@ -238,21 +250,26 @@ sub unlock_file {
$LOCKF = undef;
}
-# This script is called from udev with two arguments
+# This script is called from udev with two or three arguments
# it outputs the new name (if any) to stdout
-if ($#ARGV != 1) {
+if ($#ARGV > 2 or $#ARGV < 1) {
die "vyatta_net_name called with wrong args:" . join(' ', @ARGV) . "\n";
}
my $ifname = $ARGV[0];
my $hwaddr = $ARGV[1];
+my $predef_ifname = "";
+if ($ARGV[2]){
+ $predef_ifname = $ARGV[2];
+}
+
lock_file;
my $newname;
if ( -d $VYATTACFG ) {
- $newname = hotplug($ifname, $hwaddr);
+ $newname = hotplug($ifname, $hwaddr, $predef_ifname);
} else {
- $newname = coldplug($ifname, $hwaddr);
+ $newname = coldplug($ifname, $hwaddr, $predef_ifname);
}
unlock_file;