これ、超嵌ったのでTIPSとして書いておきます。
まず、PF_RINGは従来取りこぼしの多かったlibpcapによるパケットキャプチャ時にリングバッファ方式で動作することによりパケットキャプチャ効率を飛躍的に高めてパケットロストを激減させるというカーネルモジュールです。
まー、ひらたく言うと、チョースゲーんですわこれが。
というか、上の一文読んで胸がときめかない人はこのエントリーは読まないで下さい。
参考にしたページは
本家 http://www.ntop.org/PF_RING.html
あとここ http://www.cnblogs.com/xiaotie/archive/2006/04/20/379700.html
他にも見ましたが、嵌るだけなのであえてリンク貼りません。
英語で仕入れた情報を元にしたフィードバックなのでここからは英語で。
1. Download and install source RPM for kernel running on system
check "uname -r"
-If you use CentOS4.6 and stay in Japan at now, Your source RPM for kernel is here
rpm -Uvh kernel-<version>.src.rpm
-where <version> is the version from "uname -r"
-change your directory and add distribution patches to vanilla kernel
cd /usr/src/redhat/SPECS
rpmbuild -bp --target $(arch) kernel-2.6.spec
- Move kernel to /usr/src
mv /usr/src/redhat/BUILD/kernel-<version>/linux-<version> /usr/src
cd /usr/src
ln -s ./linux-<version> linux
cd /usr/src/linux
2. Installing PF_RING patches into kernel source
-change directory to your home
cd /home/<username>/
-make directory and download PF_RING
mkdir my_pf_ring_goes_here
cd my_pf_ring_goes_here
svn co https://svn.ntop.org/svn/ntop/trunk/PF_RING/
cd ./PF_RING
-Edit mkpatch.sh
# kernel identifiers.
VERSION=${VERSION:-2}
PATCHLEVEL=${PATCHLEVEL:-6}
SUBLEVEL=${SUBLEVEL:-9}
KERNEL_VERSION=$VERSION.$PATCHLEVEL.$SUBLEVEL
EXTRAVERSION=${EXTRAVERSION:--67.EL-$PATCH}
-Run mkpatch.sh
./mkpatch
- Copy the compressed patch file created by mkpatch.sh in the directory "workspace" to "/usr/src"
cp ./workspace/linux-2.6.9-67.EL-PF_RING.patch.gz /usr/src
- Run patch file to test for errors
zcat linux-2.6.9-67.EL-PF_RING.patch.gz | patch --dry-run -p0
-Run to apply patches
zcat linux-2.6.9-67.EL-PF_RING.patch.gz | patch -p0
3. Build kernel
cd /usr/src/linux
-Run menuconfig
make menuconfig
> Device Drivers
> Networking support
> Networking options
> PF_RING sockets < > to <M>
-...Or edit .config file
vi .config
-Go to under "# Networking options" and add this line
CONFIG_RING=m
-For example
#
# Networking options
#
CONFIG_PACKET=y
CONFIG_PACKET_MMAP=y
CONFIG_NETLINK_DEV=y
CONFIG_UNIX=y
CONFIG_NET_KEY=m
CONFIG_RING=m
CONFIG_INET=y
-FIY, I did both.
-Install
make
make modules_install
make install
-Check boot settings
ls -l /boot
-You need these lines
System.map -> System.map-2.6.9-prep
System.map-2.6.9-prep
initrd-2.6.9-prep.img
vmlinuz -> vmlinuz-2.6.9-prep
vmlinuz-2.6.9-prep
-Check grub.conf
less /boot/grub/grub.conf
-You need these lines
title CentOS (2.6.9-prep)
root (hd0,0)
kernel /vmlinuz-2.6.9-prep ro root=LABEL=/1
initrd /initrd-2.6.9-prep.img
-Reboot your OS and choice kernel what you installed
4. Build PF_RING enabled libpcap
-Copy ring.h file
cp /usr/src/linux/include/linux/ring.h /usr/include/linux
-Compile libpfring
cd <your home directory>/my_pf_ring_is_here/PF_RING/userland/libpfring
make
cp libpfring.a /usr/local/lib
cp pfring.h /usr/local/include
-Build libpcap
cd ../libpcap0.9.7-ring
./configure
make
make install
(default install is into /usr/local/include and /usr/local/lib)
5. Test
-Test by pcount
cd ../pcount
make
-Run pcount
./pcount
(Stop by <CTRL+C>)
-When PF_RING is activated, a new entry /proc/net/pf_ring is created
cat /proc/net/pf_ring/info