[ovs-dev] [PATCH] compat: Properly handle fragment lru.

Joe Stringer joe at ovn.org
Mon Aug 1 21:08:50 UTC 2016


In kernels <=3.16 there is an LRU for managing fragment queues for IPv4
and IPv6. Because the backport code comes from more recent upstream
versions of Linux, this LRU management was missing from ip_frag_queue()
and nf_ct_frag6_queue().

Fixes: 595e069a0634 ("compat: Backport IPv4 reassembly.")
Signed-off-by: Joe Stringer <joe at ovn.org>
---
 acinclude.m4                                  | 1 +
 datapath/linux/compat/include/net/inet_frag.h | 6 ++++++
 datapath/linux/compat/ip_fragment.c           | 1 +
 datapath/linux/compat/nf_conntrack_reasm.c    | 1 +
 4 files changed, 9 insertions(+)

diff --git a/acinclude.m4 b/acinclude.m4
index 7a714b2cb624..49f0781bf184 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -435,6 +435,7 @@ AC_DEFUN([OVS_CHECK_LINUX_COMPAT], [
                         [rwlock])
   OVS_FIND_FIELD_IFELSE([$KSRC/include/net/inet_frag.h], [inet_frag_queue],
                         [list_evictor])
+  OVS_GREP_IFELSE([$KSRC/include/net/inet_frag.h], [inet_frag_lru_move])
   OVS_GREP_IFELSE([$KSRC/include/net/inetpeer.h], [vif],
                   [OVS_DEFINE([HAVE_INETPEER_VIF_SUPPORT])])
 
diff --git a/datapath/linux/compat/include/net/inet_frag.h b/datapath/linux/compat/include/net/inet_frag.h
index 332b1a6db950..dee1eaf80642 100644
--- a/datapath/linux/compat/include/net/inet_frag.h
+++ b/datapath/linux/compat/include/net/inet_frag.h
@@ -24,6 +24,12 @@ static inline bool inet_frag_evicting(struct inet_frag_queue *q)
 #endif /* HAVE_INET_FRAG_EVICTING */
 
 #ifndef HAVE_CORRECT_MRU_HANDLING
+/* Upstream commit 3fd588eb90bf ("inet: frag: remove lru list") dropped this
+ * function, but we call it from our compat code. Provide a noop version. */
+#ifndef HAVE_INET_FRAG_LRU_MOVE
+#define inet_frag_lru_move(q)
+#endif
+
 static inline void rpl_sub_frag_mem_limit(struct netns_frags *nf, int i)
 {
 	__percpu_counter_add(&nf->mem, -i, frag_percpu_counter_batch);
diff --git a/datapath/linux/compat/ip_fragment.c b/datapath/linux/compat/ip_fragment.c
index e707c607fb30..b0f5d0e4c411 100644
--- a/datapath/linux/compat/ip_fragment.c
+++ b/datapath/linux/compat/ip_fragment.c
@@ -552,6 +552,7 @@ found:
 	}
 
 	skb_dst_drop(skb);
+	inet_frag_lru_move(&qp->q);
 	return -EINPROGRESS;
 
 err:
diff --git a/datapath/linux/compat/nf_conntrack_reasm.c b/datapath/linux/compat/nf_conntrack_reasm.c
index a66d00f8065e..e633443d16e0 100644
--- a/datapath/linux/compat/nf_conntrack_reasm.c
+++ b/datapath/linux/compat/nf_conntrack_reasm.c
@@ -285,6 +285,7 @@ found:
 		qp_flags(fq) |= INET_FRAG_FIRST_IN;
 	}
 
+	inet_frag_lru_move(&fq->q);
 	return 0;
 
 discard_fq:
-- 
2.9.0




More information about the dev mailing list