summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Southworth <john.southworth@vyatta.com>2011-12-14 15:34:47 -0800
committerJohn Southworth <john.southworth@vyatta.com>2011-12-14 15:34:47 -0800
commitaa1faf9d97178b5189a75a56bd654f873485845e (patch)
tree2390710062ba4f443949114d72bc92424f53dd38
parent98fa41fd93072816f414ec7b248998ba1bffb100 (diff)
downloadvyatta-cfg-system-aa1faf9d97178b5189a75a56bd654f873485845e.tar.gz
vyatta-cfg-system-aa1faf9d97178b5189a75a56bd654f873485845e.zip
Verify user defined mac addresses are not VRRP mac addresses
-rwxr-xr-xscripts/vyatta-interfaces.pl14
1 files changed, 13 insertions, 1 deletions
diff --git a/scripts/vyatta-interfaces.pl b/scripts/vyatta-interfaces.pl
index 2b75dba5..463139da 100755
--- a/scripts/vyatta-interfaces.pl
+++ b/scripts/vyatta-interfaces.pl
@@ -249,7 +249,17 @@ sub update_mac {
exit 0;
}
-
+
+sub is_vrrp_mac {
+ my @octets = @_;
+ return 1 if (hex($octets[0]) == 0 &&
+ hex($octets[1]) == 0 &&
+ hex($octets[2]) == 94 &&
+ hex($octets[3]) == 0 &&
+ hex($octets[4]) == 1);
+ return 0;
+}
+
sub is_valid_mac {
my ($mac, $intf) = @_;
my @octets = split /:/, $mac;
@@ -258,6 +268,8 @@ sub is_valid_mac {
((hex($octets[0]) & 1) == 0) or die "Error: $mac is a multicast address\n";
+ is_vrrp_mac(@octets) and die "Error: $mac is a vrrp mac address\n";
+
my $sum = 0;
$sum += hex( $_) foreach @octets;
( $sum != 0 ) or die "Error: zero is not a valid address\n";