summaryrefslogtreecommitdiff
path: root/scripts/system/irq-affinity.pl
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2011-02-25 09:05:51 -0800
committerStephen Hemminger <stephen.hemminger@vyatta.com>2011-02-25 09:05:51 -0800
commitb541f5ffa7bf1c6951e01ae4814e0cd38adc42d5 (patch)
tree8333d62289fd4ecbb74e0bbbbe564fbeb5ce4a99 /scripts/system/irq-affinity.pl
parent018c1ac6286ad40d7fff612573a7efffafe0d480 (diff)
downloadvyatta-cfg-quagga-b541f5ffa7bf1c6951e01ae4814e0cd38adc42d5.tar.gz
vyatta-cfg-quagga-b541f5ffa7bf1c6951e01ae4814e0cd38adc42d5.zip
Don't set irq affinity if device is disabled
Bug 6784 No point in trying to force affinity if device is offline.
Diffstat (limited to 'scripts/system/irq-affinity.pl')
-rwxr-xr-xscripts/system/irq-affinity.pl18
1 files changed, 18 insertions, 0 deletions
diff --git a/scripts/system/irq-affinity.pl b/scripts/system/irq-affinity.pl
index 99d37bbc..23da4635 100755
--- a/scripts/system/irq-affinity.pl
+++ b/scripts/system/irq-affinity.pl
@@ -39,6 +39,19 @@ if ($mask eq 'auto') {
exit 0;
+# Test if device is in up by reading /sys/class/net/ethX/flags
+sub is_up {
+ my $ifname = shift;
+
+ open ( my $f, '<', "/sys/class/net/$ifname/flags" )
+ or return;
+ my $flags = <$f>;
+ chomp $flags;
+ close $f;
+
+ return hex($flags) & 1;
+}
+
# Get current irq assignments by reading /proc/interrupts
sub irqinfo {
my $irqmap;
@@ -252,6 +265,8 @@ sub affinity_mask {
check_mask($ifname, "irq", $irqmsk);
check_mask($ifname, "rps", $rpsmsk) if $rpsmsk;
+ return unless is_up($ifname);
+
my $irq = get_irq($ifname);
die "$ifname: attempt to assign affinity to device without irq\n"
unless (defined($irq));
@@ -275,6 +290,9 @@ sub affinity_mask {
# CPUs available to do that.
sub affinity_auto {
my $ifname = shift;
+
+ return unless is_up($ifname);
+
my $irqmap = irqinfo();
my @irqnames = keys %{$irqmap};