summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xscripts/vyatta-interfaces.pl43
-rw-r--r--templates/service/snmp/community/node.def2
2 files changed, 24 insertions, 21 deletions
diff --git a/scripts/vyatta-interfaces.pl b/scripts/vyatta-interfaces.pl
index 3b1473c9..30ba30fa 100755
--- a/scripts/vyatta-interfaces.pl
+++ b/scripts/vyatta-interfaces.pl
@@ -350,10 +350,9 @@ sub is_valid_addr_set {
my ($addr_net, $intf) = @_;
if ($addr_net eq "dhcp") {
- if ($intf eq "lo") {
- print "Error: can't use dhcp client on loopback interface\n";
- exit 1;
- }
+ die "Error: can't use dhcp client on loopback interface\n"
+ if ($intf eq "lo");
+
exit 0;
}
@@ -382,21 +381,16 @@ sub is_valid_addr_set {
#
# 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;
- }
- }
+ die "Can not assign network address as the IP address\n"
+ if ($ip->addr() eq $network->addr());
- if (is_ip_duplicate($intf, $addr_net)) {
- print "Error: duplicate address/prefix [$addr_net]\n";
- exit 1;
+ die "Can not assign broadcast address as the IP address\n"
+ if ($ip->addr() eq $bcast->addr());
}
+ die "Error: duplicate address/prefix [$addr_net]\n"
+ if (is_ip_duplicate($intf, $addr_net));
+
if ($version == 4) {
if ($net > 0 && $net <= 32) {
exit 0;
@@ -435,11 +429,10 @@ sub is_valid_addr_commit {
}
}
- if ($static_v4 == 1 && $dhcp == 1) {
- printf("Error configuring interface $intf: Can't configure static\n");
- printf("IPv4 address and DHCP on the same interface.\n");
- exit 1;
- }
+
+ die "Error configuring interface $intf: Can't configure static\n",
+ "IPv4 address and DHCP on the same interface.\n"
+ if ($static_v4 == 1 && $dhcp == 1);
exit 0;
}
@@ -490,10 +483,18 @@ sub is_valid_name {
my $intf = new Vyatta::Interface($name);
die "$name does not match any known interface name type\n"
unless $intf;
+
+ my $vif = $intf->vif();
+ die "$name is the name of VIF interface\n" ,
+ "Need to use \"interface ",$intf->physicalDevice()," vif $vif\"\n"
+ if $vif;
+
die "$name is a ", $intf->type(), " interface not an $type interface\n"
if ($type ne 'all' and $intf->type() ne $type);
+
die "$type interface $name does not exist on system\n"
unless grep { $name eq $_ } getInterfaces();
+
exit 0;
}
diff --git a/templates/service/snmp/community/node.def b/templates/service/snmp/community/node.def
index cf95bc27..32eb4800 100644
--- a/templates/service/snmp/community/node.def
+++ b/templates/service/snmp/community/node.def
@@ -1,3 +1,5 @@
tag:
type: txt
help: Set community name [REQUIRED]
+syntax:expression: pattern $VAR(@) "^[^%]+$" ; \
+ "Community string may not contain %"