]> git.ipfire.org Git - thirdparty/xtables-addons.git/commitdiff
compat: add check for pskb relocation
authorJan Engelhardt <jengelh@computergmbh.de>
Tue, 1 Apr 2008 06:15:01 +0000 (08:15 +0200)
committerJan Engelhardt <jengelh@computergmbh.de>
Tue, 1 Apr 2008 07:12:38 +0000 (09:12 +0200)
The Xtables-addons compat layer does not support pskb relocation
(result of possible memory allocation in kernels before 2.6.24) and
we just assume it does not happen. Add a check to warn if relocation
did happen and packet loss is to be expected.

extensions/compat_xtables.c

index 3952295ccd0953b855219dcc88a390a298540aa5..a2e3d81d1dea9b09adf30f0abfd9a6c906a0889b 100644 (file)
 #include "compat_skbuff.h"
 #include "compat_xtnu.h"
 
+static inline int unable(const char *cause)
+{
+       if (net_ratelimit())
+               printk(KERN_ERR KBUILD_MODNAME
+                      ": compat layer limits reached (%s) - dropping packets\n", cause);
+       return -1;
+}
+
 #if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 22)
 static int xtnu_match_run(const struct sk_buff *skb,
     const struct net_device *in, const struct net_device *out,
@@ -288,11 +296,17 @@ EXPORT_SYMBOL_GPL(xtnu_request_find_match);
 #if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 23)
 int xtnu_ip_route_me_harder(struct sk_buff *skb, unsigned int addr_type)
 {
+       struct sk_buff *nskb = skb;
+       int ret;
+
 #if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 18)
-       return ip_route_me_harder(&skb);
+       ret = ip_route_me_harder(&skb);
 #elif LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 23)
-       return ip_route_me_harder(&skb, addr_type);
+       ret = ip_route_me_harder(&nskb, addr_type);
 #endif
+       if (nskb != skb)
+               return unable(__func__);
+       return ret;
 }
 EXPORT_SYMBOL_GPL(xtnu_ip_route_me_harder);
 #endif