diff options
author | Michael Larson <slioch@slioch.vyatta.com> | 2010-06-21 11:09:51 -0700 |
---|---|---|
committer | Michael Larson <slioch@slioch.vyatta.com> | 2010-06-21 11:09:51 -0700 |
commit | d801c05f63b0b16f485b176db64e3147ad7d3086 (patch) | |
tree | 9829f0bf340a55986aa6d11f1b1d8d5334306abd /scripts/vyatta-interfaces.pl | |
parent | 6d59b5077ef1834379a950437b01d15d687c7a53 (diff) | |
parent | 7369bf61abd3eed1fdd17a56908cf2c0ffc9843f (diff) | |
download | vyatta-cfg-quagga-d801c05f63b0b16f485b176db64e3147ad7d3086.tar.gz vyatta-cfg-quagga-d801c05f63b0b16f485b176db64e3147ad7d3086.zip |
Merge branch 'larkspur' of http://git.vyatta.com/vyatta-cfg-system into larkspur
Diffstat (limited to 'scripts/vyatta-interfaces.pl')
-rwxr-xr-x | scripts/vyatta-interfaces.pl | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/scripts/vyatta-interfaces.pl b/scripts/vyatta-interfaces.pl index 90d8dfc7..a303c82c 100755 --- a/scripts/vyatta-interfaces.pl +++ b/scripts/vyatta-interfaces.pl @@ -47,10 +47,11 @@ use warnings; my $dhcp_daemon = '/sbin/dhclient'; -my ($eth_update, $eth_delete, $addr_set, @addr_commit, $dev, $mac, $mac_update); +my ($eth_update, $eth_delete, $addr_set, $dev, $mac, $mac_update); +my %skip_interface; my ($check_name, $show_names, $intf_cli_path, $vif_name, $warn_name); my ($check_up, $show_path, $dhcp_command); -my @speed_duplex; +my (@speed_duplex, @addr_commit); sub usage { print <<EOF; @@ -80,6 +81,7 @@ GetOptions("eth-addr-update=s" => \$eth_update, "dhcp=s" => \$dhcp_command, "check=s" => \$check_name, "show=s" => \$show_names, + "skip=s" => sub { $skip_interface{$_[1]} = 1 }, "vif=s" => \$vif_name, "warn" => \$warn_name, "path" => \$show_path, @@ -312,14 +314,14 @@ sub update_mac { if (POSIX::strtoul($flags) & 1) { # NB: Perl 5 system return value is bass-ackwards - system "sudo ip link set $intf down" + system "ip link set $intf down" and die "Could not set $intf down ($!)\n"; - system "sudo ip link set $intf address $mac" + system "ip link set $intf address $mac" and die "Could not set $intf address ($!)\n"; - system "sudo ip link set $intf up" + system "ip link set $intf up" and die "Could not set $intf up ($!)\n"; } else { - system "sudo ip link set $intf address $mac" + system "ip link set $intf address $mac" and die "Could not set $intf address ($!)\n"; } exit 0; @@ -356,6 +358,13 @@ sub is_valid_addr_set { exit 0; } + if ($addr_net eq "dhcpv6") { + die "Error: can't use dhcpv6 client on loopback interface\n" + if ($intf eq "lo"); + + exit 0; + } + my ($addr, $net); if ($addr_net =~ m/^([0-9a-fA-F\.\:]+)\/(\d+)$/) { $addr = $1; @@ -423,7 +432,7 @@ sub is_valid_addr_commit { $dhcp = 1; } else { my $version = is_ip_v4_or_v6($addr); - if ($version == 4) { + if (defined($version) && $version == 4) { $static_v4 = 1; } } @@ -516,6 +525,7 @@ sub show_interfaces { foreach my $name (@interfaces) { my $intf = new Vyatta::Interface($name); next unless $intf; # skip unknown types + next if $skip_interface{$name}; next unless ($type eq 'all' || $type eq $intf->type()); if ($vif_name) { |