Repository navigation
Expand file tree
/
Copy pathnetmap_set_adapter.sh
More file actions
executable file
·68 lines (54 loc) · 1.6 KB
/
Copy pathnetmap_set_adapter.sh
File metadata and controls
executable file
·68 lines (54 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/sh
#set -x # for debugging
if [ -z "$NMSRC" ]; then
NMSRC=~/netmap-release
fi
DRIVER="ixgbe"
#IF="eth0" # force an interface
if [ ! -f ${NMSRC}/LINUX/netmap_lin.ko ]; then
echo "LINUX/netmap_lin.ko missing. Please compile netmap."
exit 1
fi
if [ ! -f ${NMSRC}/LINUX/${DRIVER}/${DRIVER}.ko ]; then
echo "LINUX/${DRIVER}/${DRIVER}.ko missing."
echo "Please compile netmap or make sure to have netmap support for ${DRIVER}"
exit 1
fi
NMLOADED=$(lsmod | grep netmap_lin | wc -l)
DRVLOADED=$(lsmod | grep "${DRIVER}" | wc -l)
# Unload the driver
if [ $DRVLOADED != "0" ]; then
sudo rmmod "$DRIVER"
fi
# Load netmap
if [ $NMLOADED == "0" ]; then
sudo insmod ${NMSRC}/LINUX/netmap_lin.ko
fi
if [ "$1" == "g" ]; then
# In order to use generic netmap adapter, load the original driver module, that doesn't
# have netmap support
sudo modprobe ${DRIVER}
echo "Generic netmap adapter."
else
# Use the driver modified with netmap support
sudo insmod ${NMSRC}/LINUX/${DRIVER}/${DRIVER}.ko
echo "Native netmap adapter."
fi
# Wait a bit for interface name changing
sleep 2
# Find all interfaces
IFLIST=$(ip link | grep -o "^[0-9]\+: [^:]\+" | awk '{print $2}')
IFLIST=$(echo ${IFLIST})
# Find the interface that match the driver $DRIVER
for i in $IFLIST; do
drv=$(sudo ethtool -i $i 2> /dev/null | grep "driver" | awk '{print $2}')
if [ "$drv" == "$DRIVER" ]; then
IF=$i
echo " Found interface \"${IF}\""
fi
done
if [ "$IF" == "" ]; then
echo "No interface using ${DRIVER} driver was found."
exit 1
fi
sudo ip link set ${IF} up