From patchwork Mon Oct 14 17:37:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yi-Hung Wei X-Patchwork-Id: 1176561 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="o1kQCC/X"; dkim-atps=neutral Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46sR100zgnz9sP4 for ; Tue, 15 Oct 2019 04:50:28 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 5DA4E2732; Mon, 14 Oct 2019 17:49:47 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id E91972726 for ; Mon, 14 Oct 2019 17:49:45 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pl1-f196.google.com (mail-pl1-f196.google.com [209.85.214.196]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 7D4AB89D for ; Mon, 14 Oct 2019 17:49:45 +0000 (UTC) Received: by mail-pl1-f196.google.com with SMTP id u12so8301960pls.12 for ; Mon, 14 Oct 2019 10:49:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=TQ3YssQIALvb7DySDxi/BHapzu9WNUp5D9TA5ihFSSQ=; b=o1kQCC/X1Mck/j5Jck+jzAwKWGxOsayCTEYkTeyqNqNyWd2uCs6owt39zUM7PTc0cA lCSgKPnwOgd8b+rqV4WbjUa6bF91TwWF5rb9M9rtu8jOO2AlPFTx9unnRtfw6smRbAqS 0COqJ37tXRjgqRfGAZnDCR9lDLMimuSVSYiBfluEQlYBHfR5FJcP08BC2sXuijIGWQU/ zfBBL/eYSqUUnfKlq2iOhyFtoUmKrGXAateDDKqQBUG1wXRAyFLOj1yEsEu6roN0JRAf xFF5cqZTX/m6RwIo/pAMn6F/4er2X8AA3GrOl2AED2rnWRvT2F3js+CUHU533gcaKifX nBfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=TQ3YssQIALvb7DySDxi/BHapzu9WNUp5D9TA5ihFSSQ=; b=Xg7xuIXtwahIKNJT3EApfDeV1/vm/Sup8Sgxw7meI8TEx5HD4e6hkWIDieyhtbTjyn wUdRWyaZw1yGfHg7Zx6Y5nGjCq0y1g+u8CgaeXRYnu9cXomnlQWLBd0OxMGFlHL7Byxw Ul4Aa6eTw74DP/w2jnqodRDCPRAqmFwf1sO7m27FmZ8Zle8qPDxhkWOEcwi0SgMpTX4v eCM/yxrc10IYHns7EtnZ18YbgVaO84P/wI/RswZK0W0mWLsNDq+pYzz8lm2I44mkx0ym XVEYmx5UUgAq6FfeXDZRf2yhk0/9kse/4VtX2NHlXUhsoHoRAUvuWQF7zkfYHyL+Ux15 QsAQ== X-Gm-Message-State: APjAAAUd71RXS8806mp1Mhv88yDGKRmzp+3z0D9bydjejSrIfrD52MbY nWXZwaXWJui0BB7STZV5JgPiyE68GWA= X-Google-Smtp-Source: APXvYqwfQj1157t/R4BWYekFLwi465o93FqIJTchcGepCbCQ4mfAayz9haJGs8EmdBalgFsMPOyeOA== X-Received: by 2002:a17:902:8691:: with SMTP id g17mr29580376plo.231.1571075384434; Mon, 14 Oct 2019 10:49:44 -0700 (PDT) Received: from Husky.eng.vmware.com ([66.170.99.1]) by smtp.gmail.com with ESMTPSA id n23sm16849700pff.137.2019.10.14.10.49.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 14 Oct 2019 10:49:43 -0700 (PDT) From: Yi-Hung Wei To: dev@openvswitch.org Date: Mon, 14 Oct 2019 10:37:41 -0700 Message-Id: <1571074671-31834-2-git-send-email-yihung.wei@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1571074671-31834-1-git-send-email-yihung.wei@gmail.com> References: <1571074671-31834-1-git-send-email-yihung.wei@gmail.com> X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH 01/11] datapath: Replace nf_ct_invert_tuplepr() with nf_ct_invert_tuple() X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org After upstream net-next commit 303e0c558959 ("netfilter: conntrack: avoid unneeded nf_conntrack_l4proto lookups") nf_ct_invert_tuplepr() is no longer available in the kernel. Ideally, we should be in sync with upstream kernel by calling nf_ct_invert_tuple() directly in conntrack.c. However, nf_ct_invert_tuple() has different function signature in older kernel, and it would be hard to replace that in the compat layer. Thus, we use pl_nf_ct_invert_tuple() in conntrack.c and maintain compatibility in the compat layer so that ovs kernel module runs smoothly in both new and old kernel. Signed-off-by: Yi-Hung Wei Reviewed-by: Yifeng Sun --- acinclude.m4 | 2 ++ datapath/conntrack.c | 2 +- .../linux/compat/include/net/netfilter/nf_conntrack_core.h | 14 ++++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/acinclude.m4 b/acinclude.m4 index 52f92870eaaa..4072a7c8f58a 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -697,6 +697,8 @@ AC_DEFUN([OVS_CHECK_LINUX_COMPAT], [ [nf_ct_set]) OVS_GREP_IFELSE([$KSRC/include/net/netfilter/nf_conntrack.h], [nf_ct_is_untracked]) + OVS_GREP_IFELSE([$KSRC/include/net/netfilter/nf_conntrack.h], + [nf_ct_invert_tuplepr]) OVS_GREP_IFELSE([$KSRC/include/net/netfilter/nf_conntrack_zones.h], [nf_ct_zone_init]) OVS_GREP_IFELSE([$KSRC/include/net/netfilter/nf_conntrack_l3proto.h], diff --git a/datapath/conntrack.c b/datapath/conntrack.c index e328afe1ad15..afdd65b4cb7c 100644 --- a/datapath/conntrack.c +++ b/datapath/conntrack.c @@ -668,7 +668,7 @@ ovs_ct_find_existing(struct net *net, const struct nf_conntrack_zone *zone, if (natted) { struct nf_conntrack_tuple inverse; - if (!nf_ct_invert_tuplepr(&inverse, &tuple)) { + if (!rpl_nf_ct_invert_tuple(&inverse, &tuple)) { pr_debug("ovs_ct_find_existing: Inversion failed!\n"); return NULL; } diff --git a/datapath/linux/compat/include/net/netfilter/nf_conntrack_core.h b/datapath/linux/compat/include/net/netfilter/nf_conntrack_core.h index 10158011fd4d..ad52bc9412d8 100644 --- a/datapath/linux/compat/include/net/netfilter/nf_conntrack_core.h +++ b/datapath/linux/compat/include/net/netfilter/nf_conntrack_core.h @@ -113,4 +113,18 @@ rpl_nf_conntrack_in(struct sk_buff *skb, const struct nf_hook_state *state) #define nf_conntrack_in rpl_nf_conntrack_in #endif /* HAVE_NF_CONNTRACK_IN_TAKES_NF_HOOK_STATE */ +#ifdef HAVE_NF_CT_INVERT_TUPLEPR +static inline bool rpl_nf_ct_invert_tuple(struct nf_conntrack_tuple *inverse, + const struct nf_conntrack_tuple *orig) +{ + return nf_ct_invert_tuplepr(inverse, orig); +} +#else +static inline bool rpl_nf_ct_invert_tuple(struct nf_conntrack_tuple *inverse, + const struct nf_conntrack_tuple *orig) +{ + return nf_ct_invert_tuple(inverse, orig); +} +#endif /* HAVE_NF_CT_INVERT_TUPLEPR */ + #endif /* _NF_CONNTRACK_CORE_WRAPPER_H */