From patchwork Sat Jul 6 10:45:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 1128431 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=redhat.com 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 45gpMv15pKz9sNH for ; Sat, 6 Jul 2019 20:48:09 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 6412C1B6F; Sat, 6 Jul 2019 10:48:06 +0000 (UTC) X-Original-To: ovs-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 37EE01AEC for ; Sat, 6 Jul 2019 10:45:10 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 9ACD8881 for ; Sat, 6 Jul 2019 10:45:09 +0000 (UTC) Received: by mail-wm1-f67.google.com with SMTP id z23so11949788wma.4 for ; Sat, 06 Jul 2019 03:45:09 -0700 (PDT) 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:date:message-id:mime-version :content-transfer-encoding; bh=uBWMWYSWBQ7TygSBCeE1EbhgYXMaVvu9csJMSsOk4kc=; b=fwgKWrTqzMu+/5GskH5KNde5xdMT2bf+zF79SyB06xGWDCmuJRb8UUQL/AAJnhiJF7 DgAzmxvbK3Z1/rtO+mQQMTbFkDzLCRjHqguM8glrn1yFqDY7i7alB94AnfSXzN3DgnlR ZLj1Z3QiAtx1WkVWWHS5doOPzZT1Yw3GxBWAXtwdnUjuy23XgxISI2KzAh2nB2xZFPWY iisEgqPE2kujNQquN7YiPkflk+VNb2yxiNwWPDwYBEHXD/Abi9N/4186NZPn6qoVIHhb hcjsbrGi1pRMQM66dkX/I/sVR/XTdcNF+s3Mjr+B51mivDdb0MXG43aiYbfx0gsGAfh/ iEkg== X-Gm-Message-State: APjAAAVp8f53EPhnh2Y7thui+mYCwPZROSItNEhuWjv/26hYAcvMlMBp HzekIbVDur+oh6XlLxDziBFFj6oFV/U= X-Google-Smtp-Source: APXvYqxeEqlJz7rU0Ic4vCYpyKrID9SApv4BKdjmGeclhQSSE0hi9REE+jiw9/A8VUEI0jQTUbT3mA== X-Received: by 2002:a1c:7e90:: with SMTP id z138mr7547402wmc.128.1562409908000; Sat, 06 Jul 2019 03:45:08 -0700 (PDT) Received: from localhost.localdomain ([151.66.63.253]) by smtp.gmail.com with ESMTPSA id y6sm8615412wrp.12.2019.07.06.03.45.04 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sat, 06 Jul 2019 03:45:04 -0700 (PDT) From: Lorenzo Bianconi To: ovs-dev@openvswitch.org Date: Sat, 6 Jul 2019 12:45:00 +0200 Message-Id: <034361495642a40f342187be63c7f54115296d16.1562402015.git.lorenzo.bianconi@redhat.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham 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] OVN: run local logical flows first in S_ROUTER_OUT_SNAT table 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 Run local logical flows first if the gw router port is scheduled on the local chassis in order to properly manage snat traffic Tested-by: Eran Kuris Acked-by: Numan Siddique Signed-off-by: Lorenzo Bianconi Acked-by: Mark Michelson --- Changes since v2: - fix compilation error Changes since v1: - add priority change in ovn-northd.8.xml --- ovn/northd/ovn-northd.8.xml | 3 ++- ovn/northd/ovn-northd.c | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/ovn/northd/ovn-northd.8.xml b/ovn/northd/ovn-northd.8.xml index 193aa210f..d2267de0e 100644 --- a/ovn/northd/ovn-northd.8.xml +++ b/ovn/northd/ovn-northd.8.xml @@ -2428,7 +2428,8 @@ nd_ns {

If the NAT rule cannot be handled in a distributed manner, then the flow above is only programmed on the - redirect-chassis. + redirect-chassis increasing flow priority by 128 in + order to be run first

diff --git a/ovn/northd/ovn-northd.c b/ovn/northd/ovn-northd.c index ba2719321..ce382ac89 100644 --- a/ovn/northd/ovn-northd.c +++ b/ovn/northd/ovn-northd.c @@ -6634,6 +6634,8 @@ build_lrouter_flows(struct hmap *datapaths, struct hmap *ports, count_1bits(ntohl(mask)) + 1, ds_cstr(&match), ds_cstr(&actions)); } else { + uint16_t priority = count_1bits(ntohl(mask)) + 1; + /* Distributed router. */ ds_clear(&match); ds_put_format(&match, "ip && ip4.src == %s" @@ -6643,6 +6645,7 @@ build_lrouter_flows(struct hmap *datapaths, struct hmap *ports, if (!distributed && od->l3redirect_port) { /* Flows for NAT rules that are centralized are only * programmed on the "redirect-chassis". */ + priority += 128; ds_put_format(&match, " && is_chassis_resident(%s)", od->l3redirect_port->json_key); } @@ -6657,8 +6660,8 @@ build_lrouter_flows(struct hmap *datapaths, struct hmap *ports, * nat->logical_ip with the longest mask gets a higher * priority. */ ovn_lflow_add(lflows, od, S_ROUTER_OUT_SNAT, - count_1bits(ntohl(mask)) + 1, - ds_cstr(&match), ds_cstr(&actions)); + priority, ds_cstr(&match), + ds_cstr(&actions)); } }