Skip to content

Commit 6d2188f

Browse files
vapieryoshfuji
authored andcommitted
[PATCH] [IPG]: handle pktgen setup in newer kernels.
Only load modules if kernel supports modules and try a little bit harder to locate the pg directory in /proc with newer kernels. Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
1 parent 75add97 commit 6d2188f

1 file changed

Lines changed: 17 additions & 6 deletions

File tree

ipg

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,32 @@
11
#! /bin/bash
22

3-
modprobe pg3
3+
if [ -e /proc/modules ] ; then
4+
modprobe pg3 >& /dev/null
5+
modprobe pktgen >& /dev/null
6+
fi
7+
8+
for PGDEV in /proc/net/pg /proc/net/pktgen/pg0 / ; do
9+
[ -e ${PGDEV} ] && break
10+
done
11+
if [ "${PGDEV}" = "/" ] ; then
12+
echo "Could not locate pg in /proc/net" 1>&2
13+
exit 1
14+
fi
415

516
function pgset() {
617
local result
718

8-
echo $1 > /proc/net/pg
19+
echo $1 > ${PGDEV}
920

10-
result=`cat /proc/net/pg | fgrep "Result: OK:"`
21+
result=`cat ${PGDEV} | fgrep "Result: OK:"`
1122
if [ "$result" = "" ]; then
12-
cat /proc/net/pg | fgrep Result:
23+
cat ${PGDEV} | fgrep Result:
1324
fi
1425
}
1526

1627
function pg() {
17-
echo inject > /proc/net/pg
18-
cat /proc/net/pg
28+
echo inject > ${PGDEV}
29+
cat ${PGDEV}
1930
}
2031

2132
pgset "odev eth0"

0 commit comments

Comments
 (0)