compat: properly clamp return value from skb_make_writable()

This commit is contained in:
Jan Engelhardt
2008-07-10 17:39:34 +02:00
parent 419006eff9
commit 5956a3354e

View File

@@ -12,11 +12,12 @@
#include "compat_skbuff.h" #include "compat_skbuff.h"
#include "compat_xtnu.h" #include "compat_xtnu.h"
static inline int unable(const char *cause) static inline int unable(const char *cause, unsigned int c)
{ {
if (net_ratelimit()) if (net_ratelimit())
printk(KERN_ERR KBUILD_MODNAME printk(KERN_ERR KBUILD_MODNAME
": compat layer limits reached (%s) - dropping packets\n", cause); ": compat layer limits reached (%s) - "
"dropping packets (%u so far)\n", cause, c);
return -1; return -1;
} }
@@ -296,6 +297,7 @@ EXPORT_SYMBOL_GPL(xtnu_request_find_match);
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 23) #if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 23)
int xtnu_ip_route_me_harder(struct sk_buff *skb, unsigned int addr_type) int xtnu_ip_route_me_harder(struct sk_buff *skb, unsigned int addr_type)
{ {
static unsigned int rmh_counter;
struct sk_buff *nskb = skb; struct sk_buff *nskb = skb;
int ret; int ret;
@@ -306,19 +308,20 @@ int xtnu_ip_route_me_harder(struct sk_buff *skb, unsigned int addr_type)
ret = ip_route_me_harder(&nskb, addr_type); ret = ip_route_me_harder(&nskb, addr_type);
#endif #endif
if (nskb != skb) if (nskb != skb)
return unable(__func__); return unable(__func__, ++rmh_counter);
return ret; return ret;
} }
EXPORT_SYMBOL_GPL(xtnu_ip_route_me_harder); EXPORT_SYMBOL_GPL(xtnu_ip_route_me_harder);
int xtnu_skb_make_writable(struct sk_buff *skb, unsigned int len) int xtnu_skb_make_writable(struct sk_buff *skb, unsigned int len)
{ {
static unsigned int mkw_counter;
struct sk_buff *nskb = skb; struct sk_buff *nskb = skb;
int ret; int ret;
ret = skb_make_writable(&skb, len); ret = skb_make_writable(&skb, len);
if (nskb != skb) if (nskb != skb)
return unable(__func__); return unable(__func__, ++mkw_counter) <= 0 ? false : true;
return ret; return ret;
} }
EXPORT_SYMBOL_GPL(xtnu_skb_make_writable); EXPORT_SYMBOL_GPL(xtnu_skb_make_writable);