From patchwork Mon Jan 14 09:59:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?SGVucnkgWWVuICjpoY/kv67muqsp?= X-Patchwork-Id: 10761933 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9971214E5 for ; Mon, 14 Jan 2019 10:02:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 88CC027FA5 for ; Mon, 14 Jan 2019 10:02:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8713F28B3D; Mon, 14 Jan 2019 10:02:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4799027FA5 for ; Mon, 14 Jan 2019 10:02:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=DmHBxlZKRD5sZHgiksBjRDWb13TO+NoKEGZaU5krCiE=; b=OxKxiEmIiL/jDn dTCn52HG9PKaQBcrJ06zfeHLc6IaWF93wxN3yVhhGvg/cYV25Q7oPdcMlStGLBHRfJY+yc0RZiD5D E/sjR3d2Gg0J7+EfOhrDZ79zJbwaVU3jWlHbRY36PMzw+Og5XlDM39IbhyQ1qKc/4by/f8hyqO9ju Ngt+f5/1ICmYXqp2m17m8TaQ/dzyphshwm0i35xqejkwxKfJFLW+7ZhxDTZLq0KRlaZnVVceoPq7C btm2iGErXMSKyFoSrUUUsN3JSY38J0tyZi2Y3wD0qlwhyzTqgywTd6YqqNN2jGEU7bXXD9aBBk/lt GCKKPCuV164MUsBorddA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1giz4d-0007ZD-NM; Mon, 14 Jan 2019 10:02:27 +0000 Received: from mailgw01.mediatek.com ([216.200.240.184]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1giz2P-0004EH-Ds; Mon, 14 Jan 2019 10:00:53 +0000 X-UUID: a773407c3c19455cbb9ee45d9c0cd75d-20190114 X-UUID: a773407c3c19455cbb9ee45d9c0cd75d-20190114 Received: from mtkcas68.mediatek.inc [(172.29.94.19)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLS) with ESMTP id 579763173; Mon, 14 Jan 2019 01:59:54 -0800 Received: from MTKMBS06N1.mediatek.inc (172.21.101.129) by MTKMBS62N1.mediatek.inc (172.29.193.41) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Mon, 14 Jan 2019 01:59:53 -0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs06n1.mediatek.inc (172.21.101.129) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Mon, 14 Jan 2019 17:59:51 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Mon, 14 Jan 2019 17:59:51 +0800 From: Henry Yen To: Pablo Neira Ayuso , "David S. Miller" Subject: [PATCH] netfilter: fix checking method of conntrack helper Date: Mon, 14 Jan 2019 17:59:43 +0800 Message-ID: <1547459983-15724-1-git-send-email-henry.yen@mediatek.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190114_020009_876075_1D91612A X-CRM114-Status: GOOD ( 10.87 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ryder Lee , Henry Yen , netdev@vger.kernel.org, Sean Wang , Weijie Gao , linux-kernel@vger.kernel.org, netfilter-devel@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This patch uses nfct_help() to detect whether an established connection needs conntrack helper instead of using test_bit(IPS_HELPER_BIT, &ct->status). The reason is that IPS_HELPER_BIT is only set when using explicit CT target. However, in the case that a device enables conntrack helper via command "echo 1 > /proc/sys/net/netfilter/nf_conntrack_helper", the status of IPS_HELPER_BIT will not present any change, and consequently it loses the checking ability in the context. Signed-off-by: Henry Yen Reviewed-by: Ryder Lee Tested-by: John Crispin --- net/netfilter/nft_flow_offload.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/net/netfilter/nft_flow_offload.c b/net/netfilter/nft_flow_offload.c index 974525eb92df..de4684cc4633 100644 --- a/net/netfilter/nft_flow_offload.c +++ b/net/netfilter/nft_flow_offload.c @@ -12,6 +12,7 @@ #include #include #include +#include struct nft_flow_offload { struct nft_flowtable *flowtable; @@ -71,6 +72,7 @@ static void nft_flow_offload_eval(const struct nft_expr *expr, struct flow_offload *flow; enum ip_conntrack_dir dir; struct nf_conn *ct; + const struct nf_conn_help *help; int ret; if (nft_flow_offload_skip(pkt->skb)) @@ -88,7 +90,8 @@ static void nft_flow_offload_eval(const struct nft_expr *expr, goto out; } - if (test_bit(IPS_HELPER_BIT, &ct->status)) + help = nfct_help(ct); + if (help) goto out; if (ctinfo == IP_CT_NEW ||