summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@vyos.io>2020-07-26 20:21:17 +0700
committerGitHub <noreply@github.com>2020-07-26 20:21:17 +0700
commit730b4c4e6400898ee31ae3340dd3a9472f7ff981 (patch)
tree49b82916160461daba0e909789ef92acd75497d1
parenta6c49f5f40ccc69bd770a26262ecad6038e39288 (diff)
parentfd3c4e039f6bd1de25e2cf5bdca017d64bf2d16b (diff)
downloadvyatta-cfg-system-730b4c4e6400898ee31ae3340dd3a9472f7ff981.tar.gz
vyatta-cfg-system-730b4c4e6400898ee31ae3340dd3a9472f7ff981.zip
Merge pull request #124 from L6NqLW/T2476
bonding: T2476: fix mac address override for bond member interfaces
-rwxr-xr-xscripts/vyatta-interfaces.pl44
1 files changed, 26 insertions, 18 deletions
diff --git a/scripts/vyatta-interfaces.pl b/scripts/vyatta-interfaces.pl
index f6fa717a..6f29c4c2 100755
--- a/scripts/vyatta-interfaces.pl
+++ b/scripts/vyatta-interfaces.pl
@@ -258,24 +258,32 @@ sub update_mac {
my $intf = new Vyatta::Interface($name);
$intf or die "Unknown interface name/type: $name\n";
- # maybe nothing needs to change
- my $oldmac = $intf->hw_address();
- exit 0 if (lc($oldmac) eq lc($mac));
-
- # try the direct approach
- if (system("sudo ip link set $name address $mac") == 0) {
- exit 0;
- } elsif ($intf->up()) {
-
- # some hardware can not change MAC address if up
- system "sudo ip link set $name down"
- and die "Could not set $name down\n";
- system "sudo ip link set $name address $mac"
- and die "Could not set $name address\n";
- system "sudo ip link set $name up"
- and die "Could not set $name up\n";
- } else {
- die "Could not set mac address for $name\n";
+ my $config = new Vyatta::Config;
+ $config->setLevel($intf->path());
+ my $bond = $config->returnValue("bond-group");
+
+ # we need to skip this for bond member interfaces
+ if (!defined($bond)) {
+
+ # maybe nothing needs to change
+ my $oldmac = $intf->hw_address();
+ exit 0 if (lc($oldmac) eq lc($mac));
+
+ # try the direct approach
+ if (system("sudo ip link set $name address $mac") == 0) {
+ exit 0;
+ } elsif ($intf->up()) {
+
+ # some hardware can not change MAC address if up
+ system "sudo ip link set $name down"
+ and die "Could not set $name down\n";
+ system "sudo ip link set $name address $mac"
+ and die "Could not set $name address\n";
+ system "sudo ip link set $name up"
+ and die "Could not set $name up\n";
+ } else {
+ die "Could not set mac address for $name\n";
+ }
}
exit 0;