From 75e88a7321a5f4730426d5376f711dd4b58a6705 Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Thu, 21 Feb 2008 13:29:31 +0100 Subject: [PATCH] Update compat code for new 2.6.25 code Signed-off-by: Jan Engelhardt --- extensions/compat_xtables.c | 56 +++++++++++++++++++++++++++++++++++++ extensions/compat_xtables.h | 5 ++-- extensions/compat_xtnu.h | 3 ++ extensions/xt_TEE.c | 2 +- 4 files changed, 62 insertions(+), 4 deletions(-) diff --git a/extensions/compat_xtables.c b/extensions/compat_xtables.c index fe94857..b1d8808 100644 --- a/extensions/compat_xtables.c +++ b/extensions/compat_xtables.c @@ -5,6 +5,8 @@ #include #include #include +#include +#include #include "compat_xtnu.h" #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19) && \ @@ -238,4 +240,58 @@ int xtnu_ip_route_me_harder(struct sk_buff *skb, unsigned int addr_type) EXPORT_SYMBOL_GPL(xtnu_ip_route_me_harder); #endif +#if LINUX_VERSION_CODE == KERNEL_VERSION(2, 6, 24) +static int __xtnu_ip_local_out(struct sk_buff *skb) +{ + struct iphdr *iph = ip_hdr(skb); + + iph->tot_len = htons(skb->len); + ip_send_check(iph); + return nf_hook(PF_INET, NF_IP_LOCAL_OUT, skb, NULL, + skb->dst->dev, dst_output); +} + +int xtnu_ip_local_out(struct sk_buff *skb) +{ + int err; + + err = __xtnu_ip_local_out(skb); + if (likely(err == 1)) + err = dst_output(skb); + + return err; +} +EXPORT_SYMBOL_GPL(xtnu_ip_local_out); +#elif LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 23) +static int __xtnu_ip_local_out(struct sk_buff **pskb) +{ + struct iphdr *iph = ip_hdr(*pskb); + + iph->tot_len = htons((*pskb)->len); + ip_send_check(iph); + return nf_hook(PF_INET, NF_IP_LOCAL_OUT, pskb, NULL, + (*pskb)->dst->dev, dst_output); +} + +int xtnu_ip_local_out(struct sk_buff *skb) +{ + int err; + + err = __xtnu_ip_local_out(&skb); + if (likely(err == 1)) + err = dst_output(skb); + + return err; +} +EXPORT_SYMBOL_GPL(xtnu_ip_local_out); +#endif + +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 24) +int xtnu_ip_route_output_key(void *net, struct rtable **rp, struct flowi *flp) +{ + return ip_route_output_flow(rp, flp, NULL, 0); +} +EXPORT_SYMBOL_GPL(xtnu_ip_route_output_key); +#endif + MODULE_LICENSE("GPL"); diff --git a/extensions/compat_xtables.h b/extensions/compat_xtables.h index c63bfc2..ab9ca01 100644 --- a/extensions/compat_xtables.h +++ b/extensions/compat_xtables.h @@ -9,9 +9,8 @@ # define NF_INET_FORWARD NF_IP_FORWARD # define NF_INET_LOCAL_OUT NF_IP_LOCAL_OUT # define NF_INET_POST_ROUTING NF_IP_POST_ROUTING -#endif - -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 24) +# define init_net xtnu_ip_route_output_key /* yes */ +# define ip_route_output_key xtnu_ip_route_output_key # include "compat_nfinetaddr.h" #endif diff --git a/extensions/compat_xtnu.h b/extensions/compat_xtnu.h index 64aeaa8..62d5c65 100644 --- a/extensions/compat_xtnu.h +++ b/extensions/compat_xtnu.h @@ -5,8 +5,10 @@ #include #include +struct flowi; struct module; struct net_device; +struct rtable; struct sk_buff; struct xtnu_match { @@ -61,6 +63,7 @@ static inline struct xtnu_target *xtcompat_nutarget(const struct xt_target *t) extern int xtnu_ip_route_me_harder(struct sk_buff *, unsigned int); extern int xtnu_register_match(struct xtnu_match *); +extern int xtnu_ip_route_output_key(void *, struct rtable **, struct flowi *); extern void xtnu_unregister_match(struct xtnu_match *); extern int xtnu_register_matches(struct xtnu_match *, unsigned int); extern void xtnu_unregister_matches(struct xtnu_match *, unsigned int); diff --git a/extensions/xt_TEE.c b/extensions/xt_TEE.c index 93980f2..c006913 100644 --- a/extensions/xt_TEE.c +++ b/extensions/xt_TEE.c @@ -62,7 +62,7 @@ static bool tee_routing(struct sk_buff *skb, }; /* Trying to route the packet using the standard routing table. */ - err = ip_route_output_key(&rt, &fl); + err = ip_route_output_key(&init_net, &rt, &fl); if (err != 0) { if (net_ratelimit()) pr_debug(KBUILD_MODNAME