[PATCH 4/8] header: adapt change of parameter in {add,sub}_frag_mem_limit()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In older kernel versions the first parameter is "struct inet_frag_queue
*q", now it is "struct netns_frags *nf", This patch adds the new
versions of this function to all kernel versions older than 4.3.

This change was done in upstream Linux kernel in this commit:
commit 0e60d245a0be7fdbb723607f1d6621007916b252
Author: Florian Westphal <fw@xxxxxxxxx>
Date:   Thu Jul 23 12:05:38 2015 +0200

    inet: frag: change *_frag_mem_limit functions to take netns_frags as argument

Signed-off-by: Hauke Mehrtens <hauke@xxxxxxxxxx>
---
 backport/backport-include/net/inet_frag.h | 38 +++++++++++++++++++++----------
 1 file changed, 26 insertions(+), 12 deletions(-)

diff --git a/backport/backport-include/net/inet_frag.h b/backport/backport-include/net/inet_frag.h
index 3c9e11a..e36224e 100644
--- a/backport/backport-include/net/inet_frag.h
+++ b/backport/backport-include/net/inet_frag.h
@@ -11,18 +11,6 @@ static inline int frag_mem_limit(struct netns_frags *nf)
 	return atomic_read(&nf->mem);
 }
 
-#define sub_frag_mem_limit LINUX_BACKPORT(sub_frag_mem_limit)
-static inline void sub_frag_mem_limit(struct inet_frag_queue *q, int i)
-{
-	atomic_sub(i, &q->net->mem);
-}
-
-#define add_frag_mem_limit LINUX_BACKPORT(add_frag_mem_limit)
-static inline void add_frag_mem_limit(struct inet_frag_queue *q, int i)
-{
-	atomic_add(i, &q->net->mem);
-}
-
 #define init_frag_mem_limit LINUX_BACKPORT(init_frag_mem_limit)
 static inline void init_frag_mem_limit(struct netns_frags *nf)
 {
@@ -40,5 +28,31 @@ void inet_frag_maybe_warn_overflow(struct inet_frag_queue *q,
 				   const char *prefix);
 #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0) */
 
+/* the type of the paramater changed with kernel 4.3 */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)
+#define sub_frag_mem_limit LINUX_BACKPORT(sub_frag_mem_limit)
+static inline void sub_frag_mem_limit(struct netns_frags *nf, int i)
+{
+	atomic_sub(i, &nf->mem);
+}
+
+#define add_frag_mem_limit LINUX_BACKPORT(add_frag_mem_limit)
+static inline void add_frag_mem_limit(struct netns_frags *nf, int i)
+{
+	atomic_add(i, &nf->mem);
+}
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(4,3,0)
+#define sub_frag_mem_limit LINUX_BACKPORT(sub_frag_mem_limit)
+static inline void sub_frag_mem_limit(struct netns_frags *nf, int i)
+{
+	__percpu_counter_add(&nf->mem, -i, frag_percpu_counter_batch);
+}
+
+#define add_frag_mem_limit LINUX_BACKPORT(add_frag_mem_limit)
+static inline void add_frag_mem_limit(struct netns_frags *nf, int i)
+{
+	__percpu_counter_add(&nf->mem, i, frag_percpu_counter_batch);
+}
+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,3,0) */
 
 #endif /* __BACKPORT__NET_FRAG_H__ */
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe backports" in



[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux