summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2009-04-28 11:22:59 -0700
committerStephen Hemminger <stephen.hemminger@vyatta.com>2009-04-28 11:22:59 -0700
commit0eaba8dad441707b699749f1ef80409e05897c4b (patch)
treeab8dc87c7e15dac18bf76ecd0b1ed9fb6af809e5 /scripts
parentac3a679d68fab97b0e261445a3bf926993119cdd (diff)
downloadvyatta-cfg-0eaba8dad441707b699749f1ef80409e05897c4b.tar.gz
vyatta-cfg-0eaba8dad441707b699749f1ef80409e05897c4b.zip
DHCP should be checking config not flags
If interface is down (because of release), then renew should still be able restart interface.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/vyatta-interfaces.pl33
1 files changed, 11 insertions, 22 deletions
diff --git a/scripts/vyatta-interfaces.pl b/scripts/vyatta-interfaces.pl
index 2310e77..25fefc9 100755
--- a/scripts/vyatta-interfaces.pl
+++ b/scripts/vyatta-interfaces.pl
@@ -402,40 +402,29 @@ sub is_valid_addr {
sub op_dhcp_command {
my ($op_command, $intf) = @_;
- if (!is_dhcp_enabled($intf)) {
- print "$intf is not using DHCP to get an IP address\n";
- exit 1;
- }
+ die "$intf is not using DHCP to get an IP address\n"
+ unless is_dhcp_enabled($intf);
- my $flags = get_sysfs_value($intf, 'flags');
- my $hex_flags = hex($flags);
- if (!($hex_flags & 0x1)) {
- print "$intf is disabled. Unable to release/renew lease\n";
- exit 1;
- }
+ die "$intf is disabled. Unable to release/renew lease\n"
+ if is_intf_disabled($intf);
my $tmp_dhclient_dir = '/var/run/vyatta/dhclient/';
my $release_file = $tmp_dhclient_dir . 'dhclient_release_' . $intf;
if ($op_command eq "dhcp-release") {
- if (-e $release_file) {
- print "IP address for $intf has already been released.\n";
- exit 1;
- } else {
- print "Releasing DHCP lease on $intf ...\n";
- stop_dhclient($intf);
- mkdir ($tmp_dhclient_dir) if (! -d $tmp_dhclient_dir );
- touch ($release_file);
- exit 0;
- }
+ die "IP address for $intf has already been released.\n"
+ if (-e $release_file);
+
+ print "Releasing DHCP lease on $intf ...\n";
+ stop_dhclient($intf);
+ mkdir ($tmp_dhclient_dir) if (! -d $tmp_dhclient_dir );
+ touch ($release_file);
} elsif ($op_command eq "dhcp-renew") {
print "Renewing DHCP lease on $intf ...\n";
run_dhclient($intf);
unlink ($release_file);
- exit 0;
}
exit 0;
-
}
sub is_valid_name {