From patchwork Mon Nov 26 16:48:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Darrell Ball X-Patchwork-Id: 1003335 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="KVWAiXa2"; 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 433XwD2vGyz9s0n for ; Tue, 27 Nov 2018 03:50:20 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id F30B6B66; Mon, 26 Nov 2018 16:48:56 +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 2FB21B44 for ; Mon, 26 Nov 2018 16:48:55 +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 E306D711 for ; Mon, 26 Nov 2018 16:48:54 +0000 (UTC) Received: by mail-pl1-f196.google.com with SMTP id u6so14144074plm.8 for ; Mon, 26 Nov 2018 08:48:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=qJ9eWmYUygcqkKByNS+5uQ0TEx82KZdIjxSVdlNXJYI=; b=KVWAiXa2WRiIHD7q0ifskh5uQwqeDz0gUMWvRqpvlqbZWeHYY88fJM4hMqOAq3HN4z gv7XLm4elynfUoZ9ApsNSwE+UUjYHaRRxGIB8725IRRfrSu4GPqihUUy2cwpzXo6sXVS BXhyzjomvN4gtZtwBrUexNVftdvWNc9MJvBkkveFYA42IIaoy4SYeR1j2H9udA2Ruk8/ Fpx/Ng86icXMDe9GMZGsMVB394bvkcMXxhpZkEZgSVYHqtaXnL8RnsSMUh5utufofZCU OXY2MpxxTJrm90GwIg1qfRFSnFPXSS0aMqtSaemslfXShABGYOkpCZR2F5NBu0w5b1vK xSpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=qJ9eWmYUygcqkKByNS+5uQ0TEx82KZdIjxSVdlNXJYI=; b=Co5woWOXBlnWvhJRHR9xcXjeXQvaYsByIizH6SIEfuNHQpu2huRWn0DL0hkT4DJhxX RS3wvcHPnGfnnUhKRzjCMw8CROfDGES5A0+MoMzgbVvu6TlKU8gODMsfRasygQFz1rbG jvgRdMT2Q0gDAwZWRHRTiC8G/r4R2wcuFxxUAaiAp6Md60qC9AfAZ42a69k9F1yOJ8XB MYMy6qkIstmHzoVElSAPXwyCvCSzBED2Pvr9uPDlTW09SYtaW1gb1nulk3Rk7LEc/fwG PEjGBgHOs6OhcVEvzQ6ZurHE8bU+nwdD99edbBIxHmF3TGP0CvsAroEQh9RHHtM4hssB 0IpQ== X-Gm-Message-State: AA+aEWa0IdukqntBb1xh1LB7jbz4RvM3gMGZ+hep4rV8yxorFPTF2b9v bUCWzfuNCeDCgOGjSN7XKVo= X-Google-Smtp-Source: AFSGD/UUcRi0aLDjmCtXdVNqOIFi/0Up8fqYo3BTw1ABqIZlHJBWSihfNNqxqBzKadKd+3Nrqq7bCA== X-Received: by 2002:a17:902:20c8:: with SMTP id v8mr9768976plg.319.1543250934548; Mon, 26 Nov 2018 08:48:54 -0800 (PST) Received: from ubuntu.localdomain (c-76-102-76-212.hsd1.ca.comcast.net. [76.102.76.212]) by smtp.gmail.com with ESMTPSA id q199sm2684040pfc.97.2018.11.26.08.48.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 26 Nov 2018 08:48:53 -0800 (PST) From: Darrell Ball To: dlu998@gmail.com, dev@openvswitch.org Date: Mon, 26 Nov 2018 08:48:39 -0800 Message-Id: <1543250920-115500-3-git-send-email-dlu998@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1543250920-115500-1-git-send-email-dlu998@gmail.com> References: <1543250920-115500-1-git-send-email-dlu998@gmail.com> X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE autolearn=no version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [patch v3 3/4] conntrack: Enforce conn_type for flush 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 The user should only reference a conntrack entry by the forward direction context, as per 'conntrack_flush()', enforce this by checking for 'default' conn_type. The likelihood of a user not using the original tuple is low, but it should be guarded against, logged and documented. Signed-off-by: Darrell Ball --- Backport to 2.9. v3: Move backport hint out of commit message. Remove warning log conditional for now. lib/conntrack.c | 3 ++- lib/dpctl.man | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/conntrack.c b/lib/conntrack.c index bb3eeca..f6ff90a 100644 --- a/lib/conntrack.c +++ b/lib/conntrack.c @@ -2572,9 +2572,10 @@ conntrack_flush_tuple(struct conntrack *ct, const struct ct_dpif_tuple *tuple, ct_lock_lock(&ct->buckets[bucket].lock); conn_key_lookup(&ct->buckets[bucket], &ctx, time_msec()); - if (ctx.conn) { + if (ctx.conn && ctx.conn->conn_type == CT_CONN_TYPE_DEFAULT) { conn_clean(ct, ctx.conn, &ct->buckets[bucket]); } else { + VLOG_WARN("Must flush tuple using the original pre-NATed tuple"); error = ENOENT; } ct_lock_unlock(&ct->buckets[bucket].lock); diff --git a/lib/dpctl.man b/lib/dpctl.man index 9b13e0d..fe0aec9 100644 --- a/lib/dpctl.man +++ b/lib/dpctl.man @@ -237,6 +237,8 @@ If \fBzone\fR=\fIzone\fR is specified, only flushes the connections in .IP If \fIct-tuple\fR is provided, flushes the connection entry specified by \fIct-tuple\fR in \fIzone\fR. The zone defaults to 0 if it is not provided. +The userspace connection tracker requires flushing with the original pre-NATed +tuple and a warning log will be otherwise generated. An example of an IPv4 ICMP \fIct-tuple\fR: .IP "ct_nw_src=10.1.1.1,ct_nw_dst=10.1.1.2,ct_nw_proto=1,icmp_type=8,icmp_code=0,icmp_id=10"