initial import
[patches.git] / iputils-ipg-tweaks.patch
CommitLineData
5e993f12 1Only load modules if kernel supports modules and try a little bit
2harder to locate the pg directory in /proc with newer kernels.
3
4Signed-off-by: Mike Frysinger <vapier@gentoo.org>
5
6--- a/ipg
7+++ b/ipg
8@@ -1,21 +1,32 @@
9 #! /bin/bash
10
11-modprobe pg3
12+if [ -e /proc/modules ] ; then
13+ modprobe pg3 >& /dev/null
14+ modprobe pktgen >& /dev/null
15+fi
16+
17+for PGDEV in /proc/net/pg /proc/net/pktgen/pg0 / ; do
18+ [ -e ${PGDEV} ] && break
19+done
20+if [ "${PGDEV}" = "/" ] ; then
21+ echo "Could not locate pg in /proc/net" 1>&2
22+ exit 1
23+fi
24
25 function pgset() {
26 local result
27
28- echo $1 > /proc/net/pg
29+ echo $1 > ${PGDEV}
30
31- result=`cat /proc/net/pg | fgrep "Result: OK:"`
32+ result=`cat ${PGDEV} | fgrep "Result: OK:"`
33 if [ "$result" = "" ]; then
34- cat /proc/net/pg | fgrep Result:
35+ cat ${PGDEV} | fgrep Result:
36 fi
37 }
38
39 function pg() {
40- echo inject > /proc/net/pg
41- cat /proc/net/pg
42+ echo inject > ${PGDEV}
43+ cat ${PGDEV}
44 }
45
46 pgset "odev eth0"