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 /scripts | |
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.
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/vyatta-irqaffin | 46 |
1 files changed, 46 insertions, 0 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 } |