From patchwork Thu May 30 08:16:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: solomon X-Patchwork-Id: 1107601 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="sSwEj0lX"; 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 45F0yn6D5yz9s3Z for ; Thu, 30 May 2019 18:25:53 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 000CC35F5; Thu, 30 May 2019 08:25:49 +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 7BC3D35A3 for ; Thu, 30 May 2019 08:16:59 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pg1-f193.google.com (mail-pg1-f193.google.com [209.85.215.193]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 4045A6C5 for ; Thu, 30 May 2019 08:16:59 +0000 (UTC) Received: by mail-pg1-f193.google.com with SMTP id f25so1556875pgv.10 for ; Thu, 30 May 2019 01:16:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:message-id:date:user-agent:mime-version :content-language:content-transfer-encoding; bh=Z2OnUge7r8+RaXPZVhB6BQyREqH0NVYNi0gLz8eAG+0=; b=sSwEj0lXVfgQWPjoo4MPDnwjGbNhprG+eAvgvI0jy2wqHmd9YxEofeLAOWIOjH5uem Az86lrUKFbZ+Ye8K2dfQ0cD+TcSAAI4TF9ml+ddArQov+3PXHgfPC8WuSn7Nci5/gG4m acqM6pSiwQgO5M296bomgqU5EE6qw61f5NxK4gKJ7UgkUnmuqfvuWK4B9OZJ4iRPJ84J 5aQWuPMY2oaFgB7LCX8dPminCbtzCcpWrs92iA59venIEaE3LDEES7jiwIDXknbFz44y 078WYY9mXPt/SRVROeT6BmMAzQ3Y8wuwmbqnLiRyxci/sKg5ugo1MhjESNXFyp97WJAw 01aw== 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:message-id:date:user-agent :mime-version:content-language:content-transfer-encoding; bh=Z2OnUge7r8+RaXPZVhB6BQyREqH0NVYNi0gLz8eAG+0=; b=NgQjla5PPm7exqqATKp6zRvsi4FYdyEs31jx7o1X7enbMNMa6F+61oTOE31ygSUvB2 4D5ht1yaHbke+If6zxB4X/Q/4B6J0nd4cMdJNKkDBaUvdoOBW9gMprpmdzFaRJwVOn2m C3v4mTbMSgiYVoZY813/N88Q9JtkQiNZAaZJaiZIuS31I51mvNsD2FpJSZhpqDiCeWNS EZT+jYF2JmDWAjnZFaiP4bp2mwLApdT9+oJx6RtMM67vGmaJ+A0iQMtGiwgL5H0A0hZS zOJvwWskvXpt81x2m2bgMy8sDCgTrNKqiPXHtH2dkqJ2NLxLrc3YoRnDXTw71q0yp2NO zWtA== X-Gm-Message-State: APjAAAWoWmTkLU1G82AXI0yhR+FhLrx+yOPqv1giM3rciFBhHdR1st8d hRDyTt+mLWcSLzFrQDWz/aCvOSv1 X-Google-Smtp-Source: APXvYqynnAsO5wbnclUjq4Xi87tNwd/BtZ1PDCCdZOG5muXouCp+zvKOZBuD9hZ+T+rROT/XgtamiA== X-Received: by 2002:a62:4c5:: with SMTP id 188mr2509666pfe.19.1559204218628; Thu, 30 May 2019 01:16:58 -0700 (PDT) Received: from solomondeMacBook-Pro.local ([47.88.227.51]) by smtp.gmail.com with ESMTPSA id s27sm4352219pfd.18.2019.05.30.01.16.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 May 2019 01:16:57 -0700 (PDT) From: solomon X-Google-Original-From: solomon To: Darrell Ball Message-ID: <11b206a7-e805-ea30-6dca-c872b8b5f6e1@gmail.com> Date: Thu, 30 May 2019 16:16:54 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:60.0) Gecko/20100101 Thunderbird/60.6.0 MIME-Version: 1.0 Content-Language: en-US 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 Cc: ovs dev Subject: [ovs-dev] [PATCH]ovs:conntrack: ignore port for icmp/icmpv6 protocol 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: , Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org conntrack will not work for icmp/icmpv6 protocol, if the src/dst port is set in nat. like this: actions=ct(nat(dst=172.16.1.100:5000),commit,table=40) This patch fix this. This bug is introduced by commit 4cd0481c9e. commit 4cd0481c9e8b30bca5c0394f4e94ae126bde4908 Author: Darrell Ball Date: Mon Feb 25 15:36:31 2019 -0800 conntrack: Fix wasted work for ICMP NAT. Signed-off-by: solomon Signed-off-by: solomon Signed-off-by: Darrell Ball --- lib/conntrack.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/conntrack.c b/lib/conntrack.c index d7d48a43a..9d6b8a358 100644 --- a/lib/conntrack.c +++ b/lib/conntrack.c @@ -2039,10 +2039,14 @@ nat_select_range_tuple(struct conntrack *ct, const struct conn *conn, while (true) { if (conn->nat_info->nat_action & NAT_ACTION_SRC) { nat_conn->rev_key.dst.addr = ct_addr; - nat_conn->rev_key.dst.port = htons(port); + if (pat_enabled) { + nat_conn->rev_key.dst.port = htons(port); + } } else { nat_conn->rev_key.src.addr = ct_addr; - nat_conn->rev_key.src.port = htons(port); + if (pat_enabled) { + nat_conn->rev_key.src.port = htons(port); + } } uint32_t conn_hash = conn_key_hash(&nat_conn->rev_key,