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: 541174 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id EF1E51402D4 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: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1033974AbbKGAGh (ORCPT ); Fri, 6 Nov 2015 19:06:37 -0500 Received: from mail-pa0-f54.google.com ([209.85.220.54]:33045 "EHLO mail-pa0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757418AbbKGAGT (ORCPT ); Fri, 6 Nov 2015 19:06:19 -0500 Received: by pabfh17 with SMTP id fh17so137162524pab.0 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=GdcQDsp7YI6u0IJ9TKZz9+mbVAJPBZ79yvCIKQjQC0Z42ATwxq/EGZt36Z72O1BhFX XmjW+KIvoVXy++tAkUYNfpV6sfVaIQ1ajRKroqxI0J+wAxMmsAcMIhH2zIFJOwPbOMOV ZsSoMnH5/oQdO2fe6+gwNGoDpPlYW/gn2JqQT9Jdl+pKhD+nI/JPIQ6KWInL2EGvWs1p GqI5t0YvIU5VnVLhUkwK68zxBzvBjp7W+oQL8Nmw+L1HtjGWhqMf4SQ5u5ViwQZmC89Q SMTongP7N0XJ8soiDO8HDyGFSLx5UPvyuQfFakGhq4pUsiZGrxVn4qO9djk2wt3T5btx MsGg== X-Gm-Message-State: ALoCoQldcHUIXPw+t6sWUgvzyxzhchj66Q1pycXiI6ayQRb/GB98oyMEQkGYtF2i2vCl954j8unW 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) From: Jarno Rajahalme To: netdev@vger.kernel.org Cc: netfilter-devel@vger.kernel.org, dev@openvswitch.org, jrajahalme@nicira.com Subject: [RFC PATCH net-next v2 4/8] openvswitch: Update the CT state key only after nf_conntrack_in(). Date: Fri, 6 Nov 2015 16:06:04 -0800 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> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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; }