compat: backport truesize arg increase on skb_add_rx_frag()
authorLuis R. Rodriguez <mcgrof@frijolero.org>
Mon, 2 Apr 2012 22:55:19 +0000 (15:55 -0700)
committerLuis R. Rodriguez <mcgrof@frijolero.org>
Mon, 2 Apr 2012 23:22:52 +0000 (16:22 -0700)
This backports 50269e19 by just calling the older kernel routine,
and discarding the new argument. We treat kernels older than 2.6.28
a bit differently, given that those kernels lacked this routine
completely.

commit 50269e19ad990e79eeda101fc6df80cffd5d4831
Author: Eric Dumazet <eric.dumazet@gmail.com>
Date:   Fri Mar 23 23:59:33 2012 +0000

    net: add a truesize parameter to skb_add_rx_frag()

    skb_add_rx_frag() API is misleading.

    Network skbs built with this helper can use uncharged kernel memory and
    eventually stress/crash machine in OOM.

    Add a 'truesize' parameter and then fix drivers in followup patches.

Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
mcgrof@tux ~/linux-stable (git::master)$ git describe --contains 50269e19
v3.4-rc1~84^2~1

mcgrof@tux ~/compat (git::master)$ ckmake
Trying kernel                  3.3.0-030300rc2-generic  [OK]
Trying kernel                     3.2.2-030202-generic  [OK]
Trying kernel                    3.1.10-030110-generic  [OK]
Trying kernel                    3.0.18-030018-generic  [OK]
Trying kernel                  2.6.39-02063904-generic  [OK]
Trying kernel                  2.6.38-02063808-generic  [OK]
Trying kernel                  2.6.37-02063706-generic  [OK]
Trying kernel                  2.6.36-02063604-generic  [OK]
Trying kernel                  2.6.35-02063512-generic  [OK]
Trying kernel                  2.6.34-02063410-generic  [OK]
Trying kernel                  2.6.33-02063305-generic  [OK]
Trying kernel                  2.6.32-02063255-generic  [OK]
Trying kernel                  2.6.31-02063113-generic  [OK]
Trying kernel                  2.6.30-02063010-generic  [OK]
Trying kernel                  2.6.29-02062906-generic  [OK]
Trying kernel                  2.6.28-02062810-generic  [OK]
Trying kernel                    2.6.27-020627-generic  [OK]
Trying kernel                    2.6.26-020626-generic  [OK]
Trying kernel                    2.6.25-020625-generic  [OK]
Trying kernel                    2.6.24-020624-generic  [OK]

Signed-off-by: Luis R. Rodriguez <mcgrof@frijolero.org>
compat/compat-2.6.28.c
include/linux/compat-2.6.28.h
include/linux/compat-3.4.h

index 235dbfa..0ae8f46 100644 (file)
@@ -303,7 +303,7 @@ unsigned long round_jiffies_up(unsigned long j)
 }
 EXPORT_SYMBOL_GPL(round_jiffies_up);
 
-void skb_add_rx_frag(struct sk_buff *skb, int i, struct page *page, int off,
+void v2_6_28_skb_add_rx_frag(struct sk_buff *skb, int i, struct page *page, int off,
                int size)
 {
        skb_fill_page_desc(skb, i, page, off, size);
@@ -311,7 +311,7 @@ void skb_add_rx_frag(struct sk_buff *skb, int i, struct page *page, int off,
        skb->data_len += size;
        skb->truesize += size;
 }
-EXPORT_SYMBOL_GPL(skb_add_rx_frag);
+EXPORT_SYMBOL_GPL(v2_6_28_skb_add_rx_frag);
 
 void tty_write_unlock(struct tty_struct *tty)
 {
index e336f39..3980989 100644 (file)
@@ -246,7 +246,7 @@ static inline void skb_queue_splice_tail(const struct sk_buff_head *list,
 
 unsigned long round_jiffies_up(unsigned long j);
 
-extern void skb_add_rx_frag(struct sk_buff *skb, int i, struct page *page,
+extern void v2_6_28_skb_add_rx_frag(struct sk_buff *skb, int i, struct page *page,
                            int off, int size);
 
 #define wake_up_interruptible_poll(x, m)                       \
index 0a6a8ea..e82e52f 100644 (file)
@@ -6,6 +6,15 @@
 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
 
 #include <linux/etherdevice.h>
+#include <linux/skbuff.h>
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28))
+#define skb_add_rx_frag(skb, i, page, off, size, truesize) \
+       v2_6_28_skb_add_rx_frag(skb, i, page, off, size)
+#else
+#define skb_add_rx_frag(skb, i, page, off, size, truesize) \
+       skb_add_rx_frag(skb, i, page, off, size)
+#endif
 
 #ifdef CONFIG_X86_X32_ABI
 #define COMPAT_USE_64BIT_TIME \