diff options
author | Bob Gilligan <gilligan@vyatta.com> | 2008-02-04 14:20:42 -0800 |
---|---|---|
committer | Bob Gilligan <gilligan@vyatta.com> | 2008-02-04 14:20:42 -0800 |
commit | 8239413851eb99c62fb9422c6bc9222f1e22e4e4 (patch) | |
tree | f43bdbd2474e61db2ad6e417e39c196744782ff8 | |
parent | 7b05d404a16526976f6e144c29f40a8881db19e1 (diff) | |
download | vyatta-cfg-8239413851eb99c62fb9422c6bc9222f1e22e4e4.tar.gz vyatta-cfg-8239413851eb99c62fb9422c6bc9222f1e22e4e4.zip |
Bugfix: 2653
Don't allow the bitmask argument of the smp_affinity parameter to
contain more bits than there are CPUs on the system.
-rw-r--r-- | scripts/vyatta-irqaffin | 46 | ||||
-rw-r--r-- | templates/interfaces/ethernet/node.tag/smp_affinity/node.def | 18 |
2 files changed, 63 insertions, 1 deletions
diff --git a/scripts/vyatta-irqaffin b/scripts/vyatta-irqaffin index 90222e0..1f63ebe 100644 --- a/scripts/vyatta-irqaffin +++ b/scripts/vyatta-irqaffin @@ -1,5 +1,29 @@ + #!/bin/bash # +# **** License **** +# Version: VPL 1.0 +# +# The contents of this file are subject to the Vyatta Public License +# Version 1.0 ("License"); you may not use this file except in +# compliance with the License. You may obtain a copy of the License at +# http://www.vyatta.com/vpl +# +# Software distributed under the License is distributed on an "AS IS" +# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +# the License for the specific language governing rights and limitations +# under the License. +# +# This code was originally developed by Vyatta, Inc. +# Portions created by Vyatta are Copyright (C) 2008 Vyatta, Inc. +# All Rights Reserved. +# +# Author: Robert E. Gilligan +# Date: 2008 +# Description: +# +# **** End License **** +# # CLI back-end script to manipulate NIC interrupt CPU affinity. # # Provides sub-commands to: @@ -53,6 +77,28 @@ get_mask() echo "Invalid characters in hex mask: $exmask" return 1 fi + + # Make sure that mask holds at least one bit, and holds no more bits + # than we have CPUs. + + if [ ${mask} -eq 0 ]; then + echo "Mask can not be 0." + return 1 + fi + + numcpus=`grep -c -e "^processor" /proc/cpuinfo` + + declare -i maxmask=(2**numcpus) + let maxmask=maxmask-1 + + declare -i intmask=0x${mask} + + if [ $intmask -gt $maxmask ]; then + maxmaskhex=`printf "%x" ${maxmask}` + echo "Mask is too large. Maximum hexidecimal bitmask is: ${maxmaskhex}" + return 1 + fi + return 0 } diff --git a/templates/interfaces/ethernet/node.tag/smp_affinity/node.def b/templates/interfaces/ethernet/node.tag/smp_affinity/node.def index cd1ef41..edc78de 100644 --- a/templates/interfaces/ethernet/node.tag/smp_affinity/node.def +++ b/templates/interfaces/ethernet/node.tag/smp_affinity/node.def @@ -1,6 +1,22 @@ -multi: +# +# +# Configuration template for interface.ethernet.name.smp_affinity +# +# Configure the CPUs that the associated interface will interrupt. +# SMP affinity is configured by a hexidecimal bitmask that specifies the +# CPUs that the system can interrupt. The SMP affinity bitmask must contain +# at least one bits, and may only contain as many bits as there are CPUs on +# the system. +# + type: txt + help: Set CPU interrupt affinity mask for this interface + +comp_help: Hexidecimal bitmask representing CPUs that this NIC will interrupt + syntax:expression: exec "/opt/vyatta/sbin/vyatta-irqaffin check $VAR(../@) $VAR(@)" + create:expression: "sudo /opt/vyatta/sbin/vyatta-irqaffin set $VAR(../@) $VAR(@)"; "Error setting CPU affinity mask $VAR(@) on interface $VAR(../@)" + delete:expression: "sudo /opt/vyatta/sbin/vyatta-irqaffin reset (../@)"; "Error deleting CPU affinity mask on interface $VAR(../@)" |