#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

COUNT=8
CPU=0
MASK=1

for x in /proc/irq/*  ; do
    if ls $x/eth* &> /dev/null ; then
        HEX=`printf "%x" $MASK`
        echo "$HEX" > $x/smp_affinity
        echo "Affinity set for $x to $HEX"
        MASK=$(($MASK * 2))
        CPU=$(($CPU + 1))
        if [ $CPU -gt $COUNT ] ; then
            CPU=0
            MASK=1
        fi

    fi
done

exit 0
