summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStig Thormodsrud <stig@vyatta.com>2008-06-04 11:32:23 -0700
committerStig Thormodsrud <stig@vyatta.com>2008-06-04 11:32:23 -0700
commitbca0ace007667fb9c2e634e0debd120fc58525d4 (patch)
treed9914b9a6a601971de919e0577d1216d43f20400
parentaca9f66546b7018beb53a6357a4f2e381e2590a5 (diff)
downloadvyatta-cfg-bca0ace007667fb9c2e634e0debd120fc58525d4.tar.gz
vyatta-cfg-bca0ace007667fb9c2e634e0debd120fc58525d4.zip
Add exception for /31 and /32 for ipv4 and /128 for ipv6
-rwxr-xr-xscripts/vyatta-interfaces.pl24
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)) {