netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Cc: davem@davemloft.net, netdev@vger.kernel.org
Subject: [PATCH 8/8] netfilter: nf_flow_table: do not remove offload when other netns's interface is down
Date: Mon, 22 Oct 2018 22:07:24 +0200	[thread overview]
Message-ID: <20181022200724.25806-9-pablo@netfilter.org> (raw)
In-Reply-To: <20181022200724.25806-1-pablo@netfilter.org>

From: Taehee Yoo <ap420073@gmail.com>

When interface is down, offload cleanup function(nf_flow_table_do_cleanup)
is called and that checks whether interface index of offload and
index of link down interface is same. but only interface index checking
is not enough because flowtable is not pernet list.
So that, if other netns's interface that has index is same with offload
is down, that offload will be removed.
This patch adds netns checking code to the offload cleanup routine.

Fixes: 59c466dd68e7 ("netfilter: nf_flow_table: add a new flow state for tearing down offloading")
Signed-off-by: Taehee Yoo <ap420073@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
 net/netfilter/nf_flow_table_core.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/net/netfilter/nf_flow_table_core.c b/net/netfilter/nf_flow_table_core.c
index d8125616edc7..c188e27972c7 100644
--- a/net/netfilter/nf_flow_table_core.c
+++ b/net/netfilter/nf_flow_table_core.c
@@ -478,14 +478,17 @@ EXPORT_SYMBOL_GPL(nf_flow_table_init);
 static void nf_flow_table_do_cleanup(struct flow_offload *flow, void *data)
 {
 	struct net_device *dev = data;
+	struct flow_offload_entry *e;
+
+	e = container_of(flow, struct flow_offload_entry, flow);
 
 	if (!dev) {
 		flow_offload_teardown(flow);
 		return;
 	}
-
-	if (flow->tuplehash[0].tuple.iifidx == dev->ifindex ||
-	    flow->tuplehash[1].tuple.iifidx == dev->ifindex)
+	if (net_eq(nf_ct_net(e->ct), dev_net(dev)) &&
+	    (flow->tuplehash[0].tuple.iifidx == dev->ifindex ||
+	     flow->tuplehash[1].tuple.iifidx == dev->ifindex))
 		flow_offload_dead(flow);
 }
 
-- 
2.11.0

  parent reply	other threads:[~2018-10-23  4:27 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-22 20:07 [PATCH 0/8] Netfilter fixes for net Pablo Neira Ayuso
2018-10-22 20:07 ` [PATCH 1/8] netfilter: nft_set_rbtree: allow loose matching of closing element in interval Pablo Neira Ayuso
2018-10-22 20:07 ` [PATCH 2/8] netfilter: nft_osf: usage from output path is not valid Pablo Neira Ayuso
2018-10-22 20:07 ` [PATCH 3/8] netfilter: xt_TEE: fix wrong interface selection Pablo Neira Ayuso
2018-10-22 20:07 ` [PATCH 4/8] netfilter: xt_TEE: add missing code to get interface index in checkentry Pablo Neira Ayuso
2018-10-22 20:07 ` [PATCH 5/8] netfilter: nft_compat: do not dump private area Pablo Neira Ayuso
2018-10-22 20:07 ` [PATCH 6/8] netfilter: xt_nat: fix DNAT target for shifted portmap ranges Pablo Neira Ayuso
2018-10-22 20:07 ` [PATCH 7/8] netfilter: nf_flow_table: remove flowtable hook flush routine in netns exit routine Pablo Neira Ayuso
2018-10-22 20:07 ` Pablo Neira Ayuso [this message]
2018-10-23  3:21 ` [PATCH 0/8] Netfilter fixes for net David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181022200724.25806-9-pablo@netfilter.org \
    --to=pablo@netfilter.org \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).