Fix the condition extension for 2.6.16 kernels
Hi,
this is my first contribution to this project, so I suggest you to test it before accepting my code.
Anyway I did a really simple fix for the condition extension for 2.6.16 kernels.
diff -Nur patch-o-matic-ng-20060329.orig/patchlets/condition/linux/net/ipv4/netfilter/ipt_condition.c patch-o-matic-ng-20060329/patchlets/condition/linux/net/ipv4/netfilter/ipt_condition.c
---patch-o-matic-ng-20060329.orig/patchlets/condition/linux/net/ipv4/netfilter/ipt_condition.c
2003-12-18 19:47:52.000000000 +0100 +++ patch-o-matic-ng-20060329/patchlets/condition/linux/net/ipv4/netfilter/ipt_condition.c 2006-03-30 23:41:13.000000000 +0200
@@ -92,7 +92,7 @@
static int
match(const struct sk_buff *skb, const struct net_device *in,
const struct net_device *out, const void *matchinfo, int offset,
- const void *hdr, u_int16_t datalen, int *hotdrop)
+ unsigned int protoff, int *hotdrop)
{
const struct condition_info *info =
(const struct condition_info *) matchinfo;
@@ -116,7 +116,7 @@
static int
-checkentry(const char *tablename, const struct ipt_ip *ip, +checkentry(const char *tablename, const void *ip,
void *matchinfo, unsigned int matchsize, unsigned int hook_mask)
{
struct condition_info *info = (struct condition_info *) matchinfo;diff -Nur patch-o-matic-ng-20060329.orig/patchlets/condition/linux/net/ipv6/netfilter/ip6t_condition.c patch-o-matic-ng-20060329/patchlets/condition/linux/net/ipv6/netfilter/ip6t_condition.c
---patch-o-matic-ng-20060329.orig/patchlets/condition/linux/net/ipv6/netfilter/ip6t_condition.c
2003-12-20 17:38:19.000000000 +0100 +++ patch-o-matic-ng-20060329/patchlets/condition/linux/net/ipv6/netfilter/ip6t_condition.c 2006-03-30 23:41:01.000000000 +0200
@@ -88,7 +88,7 @@
static int
match(const struct sk_buff *skb, const struct net_device *in,
const struct net_device *out, const void *matchinfo, int offset,
- const void *hdr, u_int16_t datalen, int *hotdrop)
+ unsigned int protoff, int *hotdrop)
{
const struct condition6_info *info =
(const struct condition6_info *) matchinfo;
@@ -112,7 +112,7 @@
static int
-checkentry(const char *tablename, const struct ip6t_ip6 *ip, +checkentry(const char *tablename, const void *ip,
void *matchinfo, unsigned int matchsize, unsigned int hook_mask)
{
struct condition6_info *info =
@@ -232,7 +232,7 @@
proc_net_condition = proc_mkdir("ip6t_condition", proc_net);
if (proc_net_condition) {- errorcode = ipt_register_match(&condition_match);
+ errorcode = ip6t_register_match(&condition_match);
if (errorcode)
remove_proc_entry("ip6t_condition", proc_net);@@ -246,7 +246,7 @@
static void __exit
fini(void)
{
- ipt_unregister_match(&condition_match);
+ ip6t_unregister_match(&condition_match);
remove_proc_entry("ip6t_condition", proc_net);}
Signature · 3 lines
Bye,
Massimiliano Hofer
Nucleuspatchlets/condition/linux/net/ipv4/netfilter/ipt_condition.c +2 -2
@@ -92,7 +92,7 @@static int match (const struct sk_buff *skb,const struct net_device *in,const struct net_device *out,const void *matchinfo,int offset, -const void *hdr,u_int16_t datalen,int *hotdrop) +unsigned int protoff,int *hotdrop) {const struct condition_info *info = (const struct condition_info *) matchinfo;
@@ -116,7 +116,7 @@static int -checkentry (const char *tablename,const struct ipt_ip *ip, +checkentry (const char *tablename,const void *ip,void *matchinfo,unsigned int matchsize,unsigned int hook_mask) {struct condition_info *info = (struct condition_info *) matchinfo;
patchlets/condition/linux/net/ipv6/netfilter/ip6t_condition.c +4 -4
@@ -88,7 +88,7 @@static int match (const struct sk_buff *skb,const struct net_device *in,const struct net_device *out,const void *matchinfo,int offset, -const void *hdr,u_int16_t datalen,int *hotdrop) +unsigned int protoff,int *hotdrop) {const struct condition6_info *info = (const struct condition6_info *) matchinfo;
@@ -112,7 +112,7 @@static int -checkentry (const char *tablename,const struct ip6t_ip6 *ip, +checkentry (const char *tablename,const void *ip,void *matchinfo,unsigned int matchsize,unsigned int hook_mask) { struct condition6_info *info =
@@ -232,7 +232,7 @@ proc_net_condition =proc_mkdir ("ip6t_condition" , proc_net);if (proc_net_condition) { - errorcode =ipt_register_match (&condition_match); + errorcode =ip6t_register_match (&condition_match);if (errorcode)remove_proc_entry ("ip6t_condition" , proc_net);
@@ -246,7 +246,7 @@ static void __exitfini (void ) { -ipt_unregister_match (&condition_match); +ip6t_unregister_match (&condition_match);remove_proc_entry ("ip6t_condition" , proc_net); }
Quoted 1 line · Massimiliano Hofer
Hi,
Hi,
Quoted 2 lines
this is my first contribution to this project, so I suggest you to test it before accepting my code.
I think you should create a linux-2.6 directory as this modification prevents this extension from being usable in 2.4 kernels.
Quoted 2 lines
Anyway I did a really simple fix for the condition extension for 2.6.16 kernels.
BTW: Does it work or only compiles? ;) I remember some mails about porting condition to 2.6 raporting kernel crashes when accessing the proc interface.
Best regards,
Krzysztof Olędzki
Quoted 2 lines · Krzysztof Oledzki
I think you should create a linux-2.6 directory as this modification prevents this extension from being usable in 2.4 kernels.
Here you go.
Quoted 6 lines
Quoted 2 lines
Anyway I did a really simple fix for the condition extension for 2.6.16 kernels.
BTW: Does it work or only compiles? ;) I remember some mails about porting condition to 2.6 raporting kernel crashes when accessing the proc interface.
I tested it with IPv4 on x86 and x86_64. Everything works as expected, but the more testing the better, so you are welcome to do some more. :)
I don't have an IPv6 environment on hand and did no testing with it. I'll try to setup an IPv6 network in the coming days, but I think I should aim for a full merge of ipt and ip6t.
Signature · 3 lines
Saluti,
Massimiliano Hofer
Nucleuspatchlets/condition/linux-2.6.16/Documentation/Configure.help.ladd +8 -0
@@ -0,0 +1,8 @@ +CONFIG_IP_NF_MATCH_TOS +Condition variable match support +CONFIG_IP_NF_MATCH_CONDITION + This option allows you to match firewall rules against condition + variables stored in the /proc/net/ipt_condition directory. + + If you want to compile it as a module, say M here and read + Documentation/modules.txt. If unsure, say `N'.
patchlets/condition/linux-2.6.16/Documentation/Configure.help.ladd_2 +8 -0
@@ -0,0 +1,8 @@ +CONFIG_IP6_NF_MATCH_MARK +Condition variable match support +CONFIG_IP6_NF_MATCH_CONDITION + This option allows you to match firewall rules against condition + variables stored in the /proc/net/ipt_condition directory. + + If you want to compile it as a module, say M here and read + Documentation/modules.txt. If unsure, say `N'.
patchlets/condition/linux-2.6.16/include/linux/netfilter_ipv4/ipt_condition.h +11 -0
@@ -0,0 +1,11 @@ +#ifndef __IPT_CONDITION_MATCH__ +#define __IPT_CONDITION_MATCH__ + +#define CONDITION_NAME_LEN 32 + +struct condition_info { +char name[CONDITION_NAME_LEN ]; +int invert; +}; + +#endif
patchlets/condition/linux-2.6.16/include/linux/netfilter_ipv6/ip6t_condition.h +11 -0
@@ -0,0 +1,11 @@ +#ifndef __IP6T_CONDITION_MATCH__ +#define __IP6T_CONDITION_MATCH__ + +#define CONDITION6_NAME_LEN 32 + +struct condition6_info { +char name[CONDITION6_NAME_LEN ]; +int invert; +}; + +#endif
patchlets/condition/linux-2.6.16/net/ipv4/netfilter/Config.in.ladd +2 -0
@@ -0,0 +1,2 @@ + dep_tristate ' TOS match support' CONFIG_IP_NF_MATCH_TOS $CONFIG_IP_NF_IPTABLES + dep_tristate ' condition match support' CONFIG_IP_NF_MATCH_CONDITION $CONFIG_IP_NF_IPTABLES
patchlets/condition/linux-2.6.16/net/ipv4/netfilter/ipt_condition.c +256 -0
256 lines not on this page · raw message
patchlets/condition/linux-2.6.16/net/ipv4/netfilter/Kconfig.ladd +9 -0
@@ -0,0 +1,9 @@ +config IP_NF_MATCH_CONDITION + tristate 'condition match support' + depends on IP_NF_IPTABLES + help + This option allows you to match firewall rules against condition + variables stored in the /proc/net/ipt_condition directory. + + If you want to compile it as a module, say M here and read + Documentation/modules.txt. If unsure, say `N'.
patchlets/condition/linux-2.6.16/net/ipv4/netfilter/Makefile.ladd +2 -0
@@ -0,0 +1,2 @@ +obj-$(CONFIG_IP_NF_MATCH_TOS) += ipt_tos.o +obj-$(CONFIG_IP_NF_MATCH_CONDITION) += ipt_condition.o
patchlets/condition/linux-2.6.16/net/ipv6/netfilter/Config.in.ladd +2 -0
@@ -0,0 +1,2 @@ + dep_tristate ' limit match support' CONFIG_IP6_NF_MATCH_LIMIT $CONFIG_IP6_NF_IPTABLES + dep_tristate ' condition match support' CONFIG_IP6_NF_MATCH_CONDITION $CONFIG_IP6_NF_IPTABLES
patchlets/condition/linux-2.6.16/net/ipv6/netfilter/ip6t_condition.c +254 -0
254 lines not on this page · raw message
patchlets/condition/linux-2.6.16/net/ipv6/netfilter/Kconfig.ladd +9 -0
@@ -0,0 +1,9 @@ +config IP6_NF_MATCH_CONDITION + tristate 'condition match support' + depends on IP6_NF_IPTABLES + help + This option allows you to match firewall rules against condition + variables stored in the /proc/net/ipt_condition directory. + + If you want to compile it as a module, say M here and read + Documentation/modules.txt. If unsure, say `N'.
patchlets/condition/linux-2.6.16/net/ipv6/netfilter/Makefile.ladd +1 -0
@@ -0,0 +1 @@ +obj-$(CONFIG_IP6_NF_MATCH_CONDITION) += ip6t_condition.o