From patchwork Mon Dec 17 22:43:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Darrell Ball X-Patchwork-Id: 1014820 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="CvAqH573"; 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 43Jc180nlqz9s1c for ; Tue, 18 Dec 2018 09:54:51 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 50834F69; Mon, 17 Dec 2018 22:43:37 +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 6311FD51 for ; Mon, 17 Dec 2018 22:43:35 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wm1-f68.google.com (mail-wm1-f68.google.com [209.85.128.68]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id B0639764 for ; Mon, 17 Dec 2018 22:43:34 +0000 (UTC) Received: by mail-wm1-f68.google.com with SMTP id c126so842421wmh.0 for ; Mon, 17 Dec 2018 14:43:34 -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=cu6b5u8FUzuUEE+etOgLdnVL99mSe9HYsp/xdRodyJk=; b=CvAqH573RxVRCaH+6ZXdTxfslskxMGOEo5my9tgjoPTtchbI9SZNlpiPOORGJUm4ey fkxXQRXMfTqdARYFTfmTtnimDpLfbuh+pUWpYXm8IkxoHPVC/msKrglYM696lZBNS2ZI F3a0VxybY6OCXtAnCVuwfzPrs7si6EBNiLIkNZiyXWoXAJwQL3+fhKP812720Mb4GbY7 2ovMQJ6OXfHAA0/T3bhnJr42rD0rclTwVdsxLg73BqEjhYCHOVdldbvlgKYEMNrSAOtE WbnAevs9rZQ4eBdN5kWqHUDEPhznCJPhZKUs9K7w9NaAmB+wGhGs2y3AnV68rPSL3QtG V4eQ== 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=cu6b5u8FUzuUEE+etOgLdnVL99mSe9HYsp/xdRodyJk=; b=BLYOuNDbGQ+X0yeZgW0OfuD6qEGiDkyw/0r8IFveO00pgBdbKssgVUv4RVaR25uaNa sM8wNIFiCwspe3slPPFWKG9jbI5iDscM57x7c2XrU17Fc1ln2fZxShkVJ1+pDL4+8RHx 7RQB2SfD6efw6WcHrYWamO/e9DQvYpXRX4Uc0jHq+vqK3l9Q0ZBXmUKnX7PQFomnnHKj CGHb2grOwdLo3e9d7qzGdOeh2/z/+Y/ceq8+Ss1O/yfEn92LVWMRPjqErl7bfbVy6zDY PmQnMq8SxJV46hCIyAbO2uBByNL5S4xxvWTPMm5tdRRPrwsX6jZ5SdTNavsHkUWzmoge ENWA== X-Gm-Message-State: AA+aEWYoEWBhoBM9hj+ju/LdbdgHdKVr4trERX4YHkcdSS8CsIj7nj9d apRF3OI+9DSnNAVM2gPSjM8= X-Google-Smtp-Source: AFSGD/V2sdaFmL8vMm0dYFTfKnFfFV2Xyu1BlOjFGZczrcSiAIwpgIT9AaE5NQIXVeDe0NGjiN9v6Q== X-Received: by 2002:a1c:2c6:: with SMTP id 189mr778909wmc.21.1545086613311; Mon, 17 Dec 2018 14:43:33 -0800 (PST) Received: from ubuntu.localdomain ([208.91.2.1]) by smtp.gmail.com with ESMTPSA id q9sm1262566wrv.26.2018.12.17.14.43.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 17 Dec 2018 14:43:32 -0800 (PST) From: Darrell Ball To: dlu998@gmail.com, dev@openvswitch.org Date: Mon, 17 Dec 2018 14:43:13 -0800 Message-Id: <1545086594-125228-3-git-send-email-dlu998@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1545086594-125228-1-git-send-email-dlu998@gmail.com> References: <1545086594-125228-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 v4 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 92b2db4..41232f4 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"