diff options
author | John Southworth <john.southworth@vyatta.com> | 2011-02-07 14:24:26 -0600 |
---|---|---|
committer | John Southworth <john.southworth@vyatta.com> | 2011-02-07 14:24:26 -0600 |
commit | bc3658682531c35a4015c46913acfa95972ba77d (patch) | |
tree | 594d7e7d190c3bef54b15a18e90e90b3f2e2b8d4 /scripts | |
parent | 9d9813280dca4c6657a5570568bae54360f0afbc (diff) | |
parent | cf21f8a49f22efcb0a0ce0a99ba2755269320a9b (diff) | |
download | vyatta-cfg-quagga-bc3658682531c35a4015c46913acfa95972ba77d.tar.gz vyatta-cfg-quagga-bc3658682531c35a4015c46913acfa95972ba77d.zip |
Merge branch 'napa' of git.vyatta.com:/git/vyatta-cfg-system into napa
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/keepalived/vyatta-keepalived.pl | 4 | ||||
-rwxr-xr-x | scripts/system/irq-affinity.pl | 8 | ||||
-rwxr-xr-x | scripts/vyatta-interfaces.pl | 24 | ||||
-rwxr-xr-x | scripts/vyatta_net_name | 21 |
4 files changed, 40 insertions, 17 deletions
diff --git a/scripts/keepalived/vyatta-keepalived.pl b/scripts/keepalived/vyatta-keepalived.pl index 9b8358d2..7a113469 100755 --- a/scripts/keepalived/vyatta-keepalived.pl +++ b/scripts/keepalived/vyatta-keepalived.pl @@ -391,11 +391,12 @@ sub remove_from_changes { sub vrrp_update_config { my @errs = (); - my $output = "#\n# autogenerated by $0\n#\n\n"; + my $output; my $config = new Vyatta::Config; my $vrrp_instances = 0; + %HoA_sync_groups = (); foreach my $name ( getInterfaces() ) { my $intf = new Vyatta::Interface($name); next unless $intf; @@ -427,6 +428,7 @@ sub vrrp_update_config { if ( defined $sync_groups && $sync_groups ne "" ) { $output = $sync_groups . $output; } + $output = "#\n# autogenerated by $0\n#\n\n" . $output; keepalived_write_file( $conf_file, $output ); } return ( $vrrp_instances, @errs ); diff --git a/scripts/system/irq-affinity.pl b/scripts/system/irq-affinity.pl index ed8063ff..cf68c0d1 100755 --- a/scripts/system/irq-affinity.pl +++ b/scripts/system/irq-affinity.pl @@ -157,7 +157,11 @@ sub first_cpu { unless defined($ifunit); my $threads = threads_per_core(); - return ( $ifunit * $threads ) % $cpus; + # Give the load first to one CPU of each hyperthreaded core, then + # if there are enough NICs, give the load to the other CPU of + # each core. + my $ht_wrap = (($ifunit * $threads) / $cpus) % $threads; + return ((($ifunit * $threads) + $ht_wrap) % $cpus); } # Assignment for multi-queue NICs @@ -229,7 +233,7 @@ sub check_mask { die "$ifname: $name mask $mask has no bits set\n" if ($m == 0); - die "$ifname: $name mask $mask to large for number of CPU's: $cpus\n" + die "$ifname: $name mask $mask too large for number of CPU's: $cpus\n" if ($m >= 1 << $cpus); } diff --git a/scripts/vyatta-interfaces.pl b/scripts/vyatta-interfaces.pl index efefca9a..94a822e0 100755 --- a/scripts/vyatta-interfaces.pl +++ b/scripts/vyatta-interfaces.pl @@ -190,13 +190,16 @@ sub is_intf_disabled { } sub run_dhclient { - my $intf = shift; + my ($intf, $op_mode) = @_; - my ($intf_config_file, $intf_process_id_file, $intf_leases_file) - = generate_dhclient_intf_files($intf); - dhcp_update_config($intf_config_file, $intf); + my ($intf_config_file, $intf_process_id_file, $intf_leases_file) + = generate_dhclient_intf_files($intf); - return if is_intf_disabled($intf); + # perform config mode actions if not called from op-mode + if (!defined $op_mode) { + dhcp_update_config($intf_config_file, $intf); + return if is_intf_disabled($intf); + } my $cmd = "$dhcp_daemon -pf $intf_process_id_file -x $intf 2> /dev/null; rm -f $intf_process_id_file 2> /dev/null;"; $cmd .= "$dhcp_daemon -q -nw -cf $intf_config_file -pf $intf_process_id_file -lf $intf_leases_file $intf 2> /dev/null &"; @@ -206,9 +209,12 @@ sub run_dhclient { } sub stop_dhclient { - my $intf = shift; + my ($intf, $op_mode) = @_; - return if is_intf_disabled($intf); + # perform config mode actions if not called from op-mode + if (!defined $op_mode) { + return if is_intf_disabled($intf); + } my ($intf_config_file, $intf_process_id_file, $intf_leases_file) = generate_dhclient_intf_files($intf); @@ -325,12 +331,12 @@ sub dhcp { if (-e $release_file); print "Releasing DHCP lease on $intf ...\n"; - stop_dhclient($intf); + stop_dhclient($intf, 'op_mode'); mkdir ($tmp_dhclient_dir) if (! -d $tmp_dhclient_dir ); touch ($release_file); } elsif ($request eq "renew") { print "Renewing DHCP lease on $intf ...\n"; - run_dhclient($intf); + run_dhclient($intf, 'op_mode'); unlink ($release_file); } elsif ($request eq "start") { print "Starting DHCP client on $intf ...\n"; diff --git a/scripts/vyatta_net_name b/scripts/vyatta_net_name index 5de49b94..c3571f89 100755 --- a/scripts/vyatta_net_name +++ b/scripts/vyatta_net_name @@ -27,7 +27,7 @@ my $UDEVDIR = "/dev/.udev/"; my $VYATTAUDEV = $UDEVDIR . "vyatta"; my $LOCKFILE = $UDEVDIR . ".vyatta-lock"; my $UDEVLOG = $UDEVDIR . "log/"; -my $LOGFILE = $UDEVLOG . "vyatta-net-name"; +my $LOGFILE = $UDEVLOG . "vyatta-net-name.coldplug"; # Check if interface name is free to use sub is_available { @@ -85,6 +85,11 @@ sub biosdevname { # biosdevname works only on ethernet devices return $ifname unless ($ifname =~ /^eth/); + # Let the interface name changes ordered by previous invocations of this + # script complete before we call biosdevname. If we don't, biosdevame + # may generate incorrect name. + sleep 1; + my $biosname = `/sbin/biosdevname --policy all_ethN -i $ifname 2>>$UDEVLOG/biosdevname`; chomp $biosname; @@ -119,6 +124,12 @@ sub parse_config_boot { return $interfaces; } +sub logit { + my ($log, $msg) = @_; + my $now = localtime; + print $log "$now: $msg"; +} + # Determine network name to use based on Vyatta config during boot sub coldplug { my ($ifname, $hwaddr) = @_; @@ -127,7 +138,7 @@ sub coldplug { mkdir ($UDEVLOG); open (my $log, '>>', $LOGFILE) or die "Can't open $LOGFILE : $!"; - print {$log} "lookup $ifname $hwaddr\n"; + logit($log, "lookup $ifname $hwaddr\n"); # parse config file to produce map of existing hw-id values my $interfaces = parse_config_boot(); @@ -135,7 +146,7 @@ sub coldplug { # is name already in config file my $newname = $interfaces->{$hwaddr}; if ($newname) { - print {$log} "use hw-id $hwaddr in config mapped to '$newname'\n"; + logit($log, "use hw-id $hwaddr in config mapped to '$newname'\n"); return $newname; } @@ -153,13 +164,13 @@ sub coldplug { } $newname = biosdevname($ifname); - print {$log} "biosdevname for $ifname returned '$newname'\n"; + logit($log, "biosdevname for $ifname returned '$newname'\n"); unless (is_available($interfaces, $newname)) { $newname = find_available($interfaces, $newname); } - print {$log} "new name for '$ifname' is '$newname'\n", $ifname, $newname; + logit($log, "new name for '$ifname' is '$newname'\n"); close $log; leave_rescan_hint($newname, $hwaddr); |