diff options
author | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2010-02-16 08:53:23 -0800 |
---|---|---|
committer | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2010-02-16 10:24:37 -0800 |
commit | 464c848d9a821de9f98495d5d8802ac0eb00314a (patch) | |
tree | e50ecf31a00a3f9d3ebf9ed6ad6144ae3dfb87d6 /scripts | |
parent | def0f16b44e005d743a90318a8e425d7bc0f2db0 (diff) | |
download | vyatta-cfg-system-464c848d9a821de9f98495d5d8802ac0eb00314a.tar.gz vyatta-cfg-system-464c848d9a821de9f98495d5d8802ac0eb00314a.zip |
Use die function for failures
die prints to standard error, so any interface failures show up
in error file during boot, rather than being lost in trace messages.
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/vyatta-interfaces.pl | 35 |
1 files changed, 14 insertions, 21 deletions
diff --git a/scripts/vyatta-interfaces.pl b/scripts/vyatta-interfaces.pl index 7494d12a..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; } |