From patchwork Sat Nov 7 00:06:04 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jarno Rajahalme X-Patchwork-Id: 541175 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (li376-54.members.linode.com [96.126.127.54]) by ozlabs.org (Postfix) with ESMTP id F41DE1401B5 for ; Sat, 7 Nov 2015 11:06:41 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=nicira_com.20150623.gappssmtp.com header.i=@nicira_com.20150623.gappssmtp.com header.b=H6ZPiB3u; dkim-atps=neutral Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id F2D2F109A4; Fri, 6 Nov 2015 16:06:22 -0800 (PST) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx1e4.cudamail.com (mx1.cudamail.com [69.90.118.67]) by archives.nicira.com (Postfix) with ESMTPS id 03FE7109A0 for ; Fri, 6 Nov 2015 16:06:21 -0800 (PST) Received: from bar5.cudamail.com (unknown [192.168.21.12]) by mx1e4.cudamail.com (Postfix) with ESMTPS id 7A0F41E0059 for ; Fri, 6 Nov 2015 17:06:20 -0700 (MST) X-ASG-Debug-ID: 1446854780-09eadd0366363b0001-byXFYA Received: from mx1-pf1.cudamail.com ([192.168.24.1]) by bar5.cudamail.com with ESMTP id sRZsIpHAtYRNGPRe (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 06 Nov 2015 17:06:20 -0700 (MST) X-Barracuda-Envelope-From: jrajahalme@nicira.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.24.1 Received: from unknown (HELO mail-pa0-f54.google.com) (209.85.220.54) by mx1-pf1.cudamail.com with ESMTPS (RC4-SHA encrypted); 7 Nov 2015 00:06:19 -0000 Received-SPF: unknown (mx1-pf1.cudamail.com: Multiple SPF records returned) X-Barracuda-RBL-Trusted-Forwarder: 209.85.220.54 Received: by pasz6 with SMTP id z6so141368836pas.2 for ; Fri, 06 Nov 2015 16:06:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nicira_com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=JW4/53exuJ7E8uA9JJZYDcdterg09AUYvEFUx41GsvM=; b=H6ZPiB3u82pOqdOO/fqfhucUXFsOorooCbSaV7jH/gweA22uAjLwHrir6NOrHFFwyQ Ib74SIm3c3tsqlG5o8XaU2t4X0aaoKQdXcFzFmKKZ+rkEjPpAgp+aVmsxMlnFjhFCTrR DXLsIx8NCJ+y/LTCRZIe36ZWPsb+0CAIZIn2RFXlBhSaiZlZ3EaX4a4q7pRZVSEzfqBy czyw+5VNkOWRjO+PYllwNkEydhd7HrdERRdlE2aVZGpu1I1rJrfrdJoTmvx+jm+h+gh3 MMI6pVuDal1NiHRwWczpJedrPxfBVpE4eK4GyrQUz4yz/qf0uyaWjlTADk8KT5B9LknJ 4cCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=JW4/53exuJ7E8uA9JJZYDcdterg09AUYvEFUx41GsvM=; b=WrXgcVNYNCfBYdu+Nzyj1hVqrXeZ5JXc/Xs/U8MHpFwWlvE5Rfi9keiRe0u72Fuvoz uc9j4PHRXM1z0HukMo0iBgXi6lsBVguqR3C3WB7yHIl7mimTyNGfR8T4OMuJFkqnP64x H/+CT6Z64OmZvVuzs83d/w0PPu30F/zWeufJWZTnclLxOKQb9l/UN6Gnlc7RS9Hca7Od lYBlvWSJKoizcerf1rRvp2IP74US0EtfoyX3Oe0VKn6LyXKfbF5PQp8mFKOl9LzpSspI SdjEEKlLZiaRr/44JI2o0Y/mrcc8NaRfwOkbm9Afc/LKHSsBfnJjxemZ4h4eEsbcx1Qy 9JvQ== X-Gm-Message-State: ALoCoQni7Ve6wvA86BM2SHubVOAa71J0MbPwgvV7jyN8dniqg3d+I6TO2PNwpFN9tIymsY1T4hRa X-Received: by 10.68.179.228 with SMTP id dj4mr21556277pbc.112.1446854779302; Fri, 06 Nov 2015 16:06:19 -0800 (PST) Received: from sc9-mailhost3.vmware.com ([208.91.1.34]) by smtp.gmail.com with ESMTPSA id l16sm2160090pbq.22.2015.11.06.16.06.18 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 06 Nov 2015 16:06:18 -0800 (PST) X-CudaMail-Envelope-Sender: jrajahalme@nicira.com X-Barracuda-Apparent-Source-IP: 208.91.1.34 From: Jarno Rajahalme To: netdev@vger.kernel.org X-CudaMail-Whitelist-To: dev@openvswitch.org X-CudaMail-MID: CM-E1-1105094453 X-CudaMail-DTE: 110615 X-CudaMail-Originating-IP: 209.85.220.54 Date: Fri, 6 Nov 2015 16:06:04 -0800 X-ASG-Orig-Subj: [##CM-E1-1105094453##][RFC PATCH net-next v2 4/8] openvswitch: Update the CT state key only after nf_conntrack_in(). Message-Id: <1446854768-38299-5-git-send-email-jrajahalme@nicira.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1446854768-38299-1-git-send-email-jrajahalme@nicira.com> References: <1446854768-38299-1-git-send-email-jrajahalme@nicira.com> X-Barracuda-Connect: UNKNOWN[192.168.24.1] X-Barracuda-Start-Time: 1446854780 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://web.cudamail.com:443/cgi-mod/mark.cgi X-ASG-Whitelist: Header =?UTF-8?B?eFwtY3VkYW1haWxcLXdoaXRlbGlzdFwtdG8=?= X-Virus-Scanned: by bsmtpd at cudamail.com X-Barracuda-BRTS-Status: 1 Cc: dev@openvswitch.org, netfilter-devel@vger.kernel.org Subject: [ovs-dev] [RFC PATCH net-next v2 4/8] openvswitch: Update the CT state key only after nf_conntrack_in(). X-BeenThere: dev@openvswitch.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dev-bounces@openvswitch.org Sender: "dev" Only a successful nf_conntrack_in() call can effect a connection state change, so if suffices to update the key only after the nf_conntrack_in() returns. This change is needed for the later NAT patches. Signed-off-by: Jarno Rajahalme --- net/openvswitch/conntrack.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/net/openvswitch/conntrack.c b/net/openvswitch/conntrack.c index a28a819..10f4a6e 100644 --- a/net/openvswitch/conntrack.c +++ b/net/openvswitch/conntrack.c @@ -194,7 +194,6 @@ static int ovs_ct_set_mark(struct sk_buff *skb, struct sw_flow_key *key, struct nf_conn *ct; u32 new_mark; - /* The connection could be invalid, in which case set_mark is no-op. */ ct = nf_ct_get(skb, &ctinfo); if (!ct) @@ -385,6 +384,10 @@ static bool skb_nfct_cached(const struct net *net, const struct sk_buff *skb, return true; } +/* Pass 'skb' through conntrack in 'net', using zone configured in 'info', if + * not done already. Update key with new CT state after passing the packet + * through conntrack. + */ static int __ovs_ct_lookup(struct net *net, struct sw_flow_key *key, const struct ovs_conntrack_info *info, struct sk_buff *skb) @@ -410,14 +413,14 @@ static int __ovs_ct_lookup(struct net *net, struct sw_flow_key *key, skb) != NF_ACCEPT) return -ENOENT; + ovs_ct_update_key(skb, key, true); + if (ovs_ct_helper(skb, info->family) != NF_ACCEPT) { WARN_ONCE(1, "helper rejected packet"); return -EINVAL; } } - ovs_ct_update_key(skb, key, true); - return 0; }