diff options
author | Stig Thormodsrud <stig@vyatta.com> | 2008-06-04 11:32:23 -0700 |
---|---|---|
committer | Stig Thormodsrud <stig@vyatta.com> | 2008-06-04 11:32:23 -0700 |
commit | bca0ace007667fb9c2e634e0debd120fc58525d4 (patch) | |
tree | d9914b9a6a601971de919e0577d1216d43f20400 | |
parent | aca9f66546b7018beb53a6357a4f2e381e2590a5 (diff) | |
download | vyatta-cfg-bca0ace007667fb9c2e634e0debd120fc58525d4.tar.gz vyatta-cfg-bca0ace007667fb9c2e634e0debd120fc58525d4.zip |
Add exception for /31 and /32 for ipv4 and /128 for ipv6
-rwxr-xr-x | scripts/vyatta-interfaces.pl | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/scripts/vyatta-interfaces.pl b/scripts/vyatta-interfaces.pl index ad059c5..b465476 100755 --- a/scripts/vyatta-interfaces.pl +++ b/scripts/vyatta-interfaces.pl @@ -474,13 +474,23 @@ sub is_valid_addr { my $ip = NetAddr::IP->new($addr_net); my $network = $ip->network(); my $bcast = $ip->broadcast(); - if ($ip->addr() eq $network->addr()) { - print "Can not assign network address as the IP address\n"; - exit 1; - } - if ($ip->addr() eq $bcast->addr()) { - print "Can not assign broadcast address as the IP address\n"; - exit 1; + + if ($ip->version == 4 and $ip->masklen() == 31) { + # + # RFC3021 allows for /31 to treat both address as host addresses + # + } elsif ($ip->masklen() != $ip->bits()) { + # + # allow /32 for ivp4 and /128 for ipv6 + # + if ($ip->addr() eq $network->addr()) { + print "Can not assign network address as the IP address\n"; + exit 1; + } + if ($ip->addr() eq $bcast->addr()) { + print "Can not assign broadcast address as the IP address\n"; + exit 1; + } } if (is_dhcp_enabled($intf)) { |