Tommy 碎碎念

Tommy Wu's blog

« 上一篇 | 下一篇 »

修正 ipp2p 出現 Couldn't load match `ipp2p' 的問題
post by tommy @ 11 九月, 2007 21:38

印象中, 好像換了 kernel 2.6.22 (或 2.6.21) 之後, 原本可以使用的 ipp2p 模組, 就沒有辦法正常使用了. 因為還是有用 l7-filter 來處理, 所以也就沒有特別去處理. 今天在 Google 上閒逛, 順手就把這個錯誤訊息打入, 果然看到有類似的問題 (不過... 我記得之前就找過, 沒看到有人反應過), 照著處理一下, 果然馬上就正常了.

由網頁上頭看來, 在 Debian 下頭, 使用 ld 產生的 iptables 的 shared library 會有問題, 改用 gcc 來處理就可以了.

--- ipp2p-0.8.2/Makefile 2006-12-09 03:17:52.000000000 +0200
+++ ipp2p-0.8.2-fix/Makefile 2006-12-09 03:10:37.000000000 +0200
@@ -64,7 +64,7 @@
 
libipt_ipp2p.so: libipt_ipp2p.c ipt_ipp2p.h
$(CC) $(CFLAGS) $(IPTABLES_OPTION) $(IPTABLES_INCLUDE) -fPIC -c libipt_ipp2p.c
- ld -shared -o libipt_ipp2p.so libipt_ipp2p.o
+ $(CC) -shared -o libipt_ipp2p.so libipt_ipp2p.o
 
clean:
-rm -f *.o *.so *.ko .*.cmd *.mod.c

如果你使用 kernel 2.6.22, 還需要修正一下 ipp2p 才可以, 可以使用 gentoo 上頭的這個  patch:

diff -Nru ipp2p-0.8.2.orig/ipt_ipp2p.c ipp2p-0.8.2/ipt_ipp2p.c
--- ipp2p-0.8.2.orig/ipt_ipp2p.c 2006-09-27 12:52:00.000000000 +0300
+++ ipp2p-0.8.2/ipt_ipp2p.c 2007-07-11 08:00:26.000000000 +0300
@@ -2,9 +2,18 @@
#include <linux/modversions.h>
#endif
#include <linux/module.h>
-#include <linux/netfilter_ipv4/ip_tables.h>
#include <linux/version.h>
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,21)
+# include <linux/netfilter/x_tables.h>
+# define ipt_register_match xt_register_match
+# define ipt_unregister_match xt_unregister_match
+# define ipt_match xt_match
+#else
+# include <linux/netfilter_ipv4/ip_tables.h>
//#include <linux/netfilter_ipv4/ipt_ipp2p.h>
+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,21) */
+
#include "ipt_ipp2p.h"
#include <net/tcp.h>
#include <net/udp.h>
@@ -748,7 +757,11 @@
{
const struct ipt_p2p_info *info = matchinfo;
unsigned char *haystack;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
+ struct iphdr *ip = ip_hdr(skb);
+#else
struct iphdr *ip = skb->nh.iph;
+#endif
int p2p_result = 0, i = 0;
// int head_len;
int hlen = ntohs(ip->tot_len)-(ip->ihl*4); /*hlen = packet-data length*/
@@ -831,7 +844,9 @@
const struct ipt_ip *ip,
#endif
void *matchinfo,
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,18)
unsigned int matchsize,
+#endif
unsigned int hook_mask)
{
/* Must specify -p tcp */
@@ -843,15 +858,6 @@
}

 
-// TODO: find out what this structure is for (scheme taken
-// from kernel sources)
-// content seems to have a length of 8 bytes
-// (at least on my x86 machine)
-struct ipp2p_match_info {
- long int dunno_what_this_is_for;
- long int i_also_dunno_what_this_is_for;
-};
-
static struct ipt_match ipp2p_match = {
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
{ NULL, NULL },
@@ -860,17 +866,16 @@
&checkentry,
NULL,
THIS_MODULE
-#endif
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,17))
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(2,6,17)
.name = "ipp2p",
.match = &match,
.checkentry = &checkentry,
.me = THIS_MODULE,
-#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,17)
+#else /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,17) */
.name = "ipp2p",
.match = &match,
.family = AF_INET,
- .matchsize = sizeof(struct ipp2p_match_info),
+ .matchsize = XT_ALIGN(sizeof(struct ipt_p2p_info)),
.checkentry = &checkentry,
.me = THIS_MODULE,
#endif

經過上頭的兩個修正後, 目前看起來在 2.6.22 下頭運作似乎是正常的了.

Del.icio.us Furl HEMiDEMi Technorati MyShare
迴響
暱稱:
標題:
個人網頁:
電子郵件:
authimage

迴響

  

Bad Behavior 已經阻擋了 60 個過去 7 天試圖闖關的垃圾迴響與引用。
Power by LifeType. Template design by JamesHuang. Valid XHTML and CSS