From 464c848d9a821de9f98495d5d8802ac0eb00314a Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Tue, 16 Feb 2010 08:53:23 -0800 Subject: 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. --- scripts/vyatta-interfaces.pl | 35 ++++++++++++++--------------------- 1 file changed, 14 insertions(+), 21 deletions(-) (limited to 'scripts') 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; } -- cgit v1.2.3