summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorrbalocca <rbalocca@vyatta.com>2008-04-26 10:58:47 -0700
committerrbalocca <rbalocca@vyatta.com>2008-04-26 10:58:47 -0700
commitdc9a3772e2e74b94e9026e371af493004a4c7feb (patch)
treea219bdead1e1c72568ea5bdc7e0c98174f3f8adf /scripts
parent7cb99a90634ed0685eac3a61b7c3cfcd274d8fe1 (diff)
parent4eb7f7ce4b1628192a0535e8d642e21d4aa39838 (diff)
downloadvyatta-cfg-dc9a3772e2e74b94e9026e371af493004a4c7feb.tar.gz
vyatta-cfg-dc9a3772e2e74b94e9026e371af493004a4c7feb.zip
Merge branch 'glendale' into hollywood
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/vyatta-interfaces.pl33
-rwxr-xr-xscripts/vyatta-watchlink-exclude.pl186
2 files changed, 1 insertions, 218 deletions
diff --git a/scripts/vyatta-interfaces.pl b/scripts/vyatta-interfaces.pl
index abbf6a8..aa82b78 100755
--- a/scripts/vyatta-interfaces.pl
+++ b/scripts/vyatta-interfaces.pl
@@ -319,10 +319,7 @@ sub update_eth_addrs {
}
if ($version == 4) {
- # revert this gruesome hack when quagga static route initialization
- # is fixed.
- #return system("ip addr add $addr broadcast + dev $intf");
- return system("ip link set $intf down; ip link set $intf up; ip addr add $addr broadcast + dev $intf");
+ return system("ip addr add $addr broadcast + dev $intf");
}
if ($version == 6) {
return system("ip -6 addr add $addr dev $intf");
@@ -371,34 +368,6 @@ sub delete_eth_addrs {
or die "Could not exec ip?";
}
-
- # Destroy watchlink's internal status so it doesn't erronously
- # restore the address when link is restored
- my $statusfile = '/var/linkstatus/' . if_nametoindex($intf);
-
- # Use tie to treat file as array
- my $tie = tie my @status, 'Tie::File', $statusfile
- or die "can't open $statusfile";
-
- $tie->flock(LOCK_EX); # Block out watchlink
- $tie = undef; # Drop reference so untie will work
-
- my $ip = NetAddr::IP->new($addr);
- my $recno = 0;
- foreach my $line (@status) {
- chomp $line;
-
- # The format of watchlink file is host byte order (IPV6??)
- my ($ifindex, $raddr, $bcast, $prefix) = split (/,/, $line);
- my $laddr = htonl($raddr);
- my $this = NetAddr::IP->new("$laddr/$prefix");
- if ($ip eq $this) {
- splice @status, $recno, 1; # delete the line
- } else {
- $recno++;
- }
- }
- untie @status;
exit 0;
}
diff --git a/scripts/vyatta-watchlink-exclude.pl b/scripts/vyatta-watchlink-exclude.pl
deleted file mode 100755
index b7a8916..0000000
--- a/scripts/vyatta-watchlink-exclude.pl
+++ /dev/null
@@ -1,186 +0,0 @@
-#!/usr/bin/perl
-#
-# Module: vyatta-watchlink-exclude.pl
-#
-# **** License ****
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License version 2 as
-# published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# General Public License for more details.
-#
-# A copy of the GNU General Public License is available as
-# `/usr/share/common-licenses/GPL' in the Debian GNU/Linux distribution
-# or on the World Wide Web at `http://www.gnu.org/copyleft/gpl.html'.
-# You can also obtain it by writing to the Free Software Foundation,
-# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
-# MA 02110-1301, USA.
-#
-# This code was originally developed by Vyatta, Inc.
-# Portions created by Vyatta are Copyright (C) 2007 Vyatta, Inc.
-# All Rights Reserved.
-#
-# Author: Stig Thormodsrud
-# Date: March 2008
-# Description: Script to update watchlink exclude file
-#
-# **** End License ****
-#
-
-#
-# parameters:
-# --id="" : owner of exclude line (e.g. vrrp, ha) [required]
-# --action="" : add or remove [required]
-# --intf="" : interface [required for add]
-# --ipaddr="" : ip address or network to execlude [optional]
-# --signal : should watchlink get signaled [optional]
-#
-# Expected format of exclude file:
-#
-# <interface> [ <ipv4addr> | <ipv4net> ] # id
-#
-
-use Getopt::Long;
-use POSIX;
-
-use strict;
-use warnings;
-
-my $exclude_file = '/var/linkstatus/exclude';
-my $watchlink_pid = '/var/run/vyatta/quagga/watchlink.pid';
-
-sub read_exclude_file {
- my $FILE;
- my @lines = ();
- if (! -e $exclude_file) {
- return @lines;
- }
- open($FILE, "<", $exclude_file) or die "Error: read() $!";
- @lines = <$FILE>;
- close($FILE);
- chomp @lines;
- return @lines;
-}
-
-sub write_exclude_file {
- my @lines = @_;
-
- my $FILE;
- open($FILE, ">", $exclude_file) or die "Error: write() $!";
- if (scalar(@lines) > 0) {
- print $FILE join("\n", @lines), "\n";
- }
- close($FILE);
-}
-
-sub remove_exclude_id {
- my ($id, @lines) = @_;
-
- my @new_lines;
- my $match = 0;
- foreach my $line (@lines) {
- if ($line =~ /# $id$/) {
- $match++;
- } else {
- push @new_lines, $line;
- }
- }
- if ($match < 1) {
- print "$0: no match found for $id";
- }
- return @new_lines;
-}
-
-sub remove_exclude_line {
- my ($remove_line, @lines) = @_;
-
- my @new_lines;
- my $match = 0;
- foreach my $line (@lines) {
- if ($line eq $remove_line) {
- $match++;
- } else {
- push @new_lines, $line;
- }
- }
- if ($match < 1) {
- print "$0: no match found for $remove_line";
- }
- return @new_lines;
-}
-
-sub is_exclude_dup {
- my ($new_line, @lines) = @_;
-
- my $frag = substr($new_line, 0, index($new_line, ' #'));
- foreach my $line (@lines) {
- if (substr($line, 0, index($line, ' #')) eq $frag) {
- return 1;
- }
- }
- return 0;
-}
-
-
-#
-# main
-#
-
-my ($opt_id, $opt_action, $opt_intf, $opt_ipaddr, $opt_ipnet, $opt_signal);
-
-GetOptions("id=s" => \$opt_id,
- "action=s" => \$opt_action,
- "intf=s" => \$opt_intf,
- "ipaddr=s" => \$opt_ipaddr,
- "signal!" => \$opt_signal,
- );
-
-if (!(defined $opt_id and defined $opt_action)) {
- die "Error: parameters --id --action must be set";
-}
-
-if ($opt_action ne "add" and $opt_action ne "remove") {
- die "Error: --action must be \"add\" or \"remove\" ";
-}
-
-if ($opt_action eq "add" and !defined($opt_intf)) {
- die "Error: --intf must be set for \"add\"";
-}
-
-my @lines = read_exclude_file();
-my $new_line = "$opt_intf ";
-if (defined $opt_ipaddr) {
- $new_line .= "$opt_ipaddr ";
-}
-if (defined $opt_id) {
- $new_line .= "# $opt_id";
-}
-
-if ($opt_action eq "add") {
- if (! is_exclude_dup($new_line, @lines)) {
- push @lines, $new_line;
- }
-} elsif (defined $opt_intf) {
- @lines = remove_exclude_line($new_line, @lines);
-} else {
- @lines = remove_exclude_id($opt_id, @lines);
-}
-write_exclude_file(@lines);
-
-if (defined $opt_signal) {
- if (! -e $watchlink_pid) {
- #
- # watchlink may have been disabled, so don't treat
- # this as an error
- #
- exit 0;
- }
- my $pid = `cat $watchlink_pid`;
- chomp $pid;
- system("kill -10 $pid");
-}
-
-# end of file