From patchwork Thu Sep 20 14:46:02 2018
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Lorenzo Bianconi
X-Patchwork-Id: 972481
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 42GKL64mSqz9sBZ
for ;
Fri, 21 Sep 2018 00:46:22 +1000 (AEST)
Received: from mail.linux-foundation.org (localhost [127.0.0.1])
by mail.linuxfoundation.org (Postfix) with ESMTP id A0462152D;
Thu, 20 Sep 2018 14:46:19 +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 040A71529
for ; Thu, 20 Sep 2018 14:46:18 +0000 (UTC)
X-Greylist: whitelisted by SQLgrey-1.7.6
Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com
[209.85.221.65])
by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 4E4867CE
for ; Thu, 20 Sep 2018 14:46:17 +0000 (UTC)
Received: by mail-wr1-f65.google.com with SMTP id a108-v6so9671129wrc.13
for ; Thu, 20 Sep 2018 07:46:17 -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:subject:date:message-id:in-reply-to
:references;
bh=5LtvcbxwT8YmUxBXW7h0CtFPcapc8QouEeTnwdAwmbs=;
b=O3yc59jRPjB7lMvwTMsSizWi3hIC7cLdtoWOnxTmJeZYfcz3UEQB1v9fOcenowQhJe
2Kfi7cJRsKKn3wzi5G7Gq3DNq6nCovjes/EtX2YMPdWcp/yk4oCmht5n02vIb1IrLPd3
/zpIWugeDH5Naq3KHyKWkMoBpyi+uBdweoqSRde+Ys7+RvZraJqf77CiWbNlEJfbPT2w
YRfaOZPYDsZzAZPB/85oQVxf8CwTgS5jndK3Eq6KqlXUnYuSJooJYLEs/4UM3gIjSo7Z
NfIMJ+aiqbLGwopTs6iSyFILPsQBBhKacsD2aUMmwhjS7HJFvj9ECQqFprH6ND5pydFy
IDAA==
X-Gm-Message-State: APzg51CMXTgJq+8wxzE8OCpFCyx6LOrxYHMSn6+9o79XzHAqUpd8C3Jt
uT2xOFlUR9+6DjfJ572LksZG7cfNpE4=
X-Google-Smtp-Source:
ANB0VdYvHkZcCZMepI3UFcCGn1e+1w5v6cRNiLS3uwWlpIM8UpPRFspqpOCpUmvxyNxMm6NTbUbh8Q==
X-Received: by 2002:adf:d08c:: with SMTP id
y12-v6mr33509472wrh.152.1537454775327;
Thu, 20 Sep 2018 07:46:15 -0700 (PDT)
Received: from localhost.localdomain.com (nat-pool-mxp-t.redhat.com.
[149.6.153.186]) by smtp.gmail.com with ESMTPSA id
c12-v6sm18738460wrr.6.2018.09.20.07.46.14 for
(version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);
Thu, 20 Sep 2018 07:46:14 -0700 (PDT)
From: Lorenzo Bianconi
To: dev@openvswitch.org
Date: Thu, 20 Sep 2018 16:46:02 +0200
Message-Id:
X-Mailer: git-send-email 2.17.1
In-Reply-To:
References:
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 v2] OVN: add CT_LB action to ovn-trace
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
Add CT_LB action to ovn-trace utility in order to fix the
following ovn-trace error if a load balancer rule is added to
OVN configuration
ct_next(ct_state=est|trk /* default (use --ct to customize) */) {
*** ct_lb action not implemented;
};
Add '--lb_dst' option in order to specify the ip address to use
in VIP pool. If --lb_dst is not provided the destination ip will be
randomly choosen
Signed-off-by: Lorenzo Bianconi
Acked-by: Mark Michelson
---
Changes since v1:
- update ovn-trace manual
- reset to 0 lb_dst when it is consumed by ct_lb action
---
ovn/utilities/ovn-trace.8.xml | 12 ++++++-
ovn/utilities/ovn-trace.c | 64 +++++++++++++++++++++++++++++++++--
2 files changed, 72 insertions(+), 4 deletions(-)
diff --git a/ovn/utilities/ovn-trace.8.xml b/ovn/utilities/ovn-trace.8.xml
index 83b397f3a..3d75c7b86 100644
--- a/ovn/utilities/ovn-trace.8.xml
+++ b/ovn/utilities/ovn-trace.8.xml
@@ -255,7 +255,11 @@
ct_lb
- Not yet implemented; currently implemented as a no-op.
+ Forks the pipeline. In one fork, sets ip4.dst
(or
+ ip6.dst
) to the ip provided with --lb_dst
+ option (or to an ip randomly chosen from VIP pool). In the other fork,
+ the pipeline continues without change after the ct_lb
+ action
ct_commit
@@ -424,6 +428,12 @@
+ --lb_dst
[=
ip]
+
+ Selects an ip from VIP pool to use as destination of the packet.
+ lb_dst is not available in daemon mode
+
+
--friendly-names
--no-friendly-names
diff --git a/ovn/utilities/ovn-trace.c b/ovn/utilities/ovn-trace.c
index 7ca3d97aa..ee4583deb 100644
--- a/ovn/utilities/ovn-trace.c
+++ b/ovn/utilities/ovn-trace.c
@@ -46,6 +46,7 @@
#include "stream.h"
#include "unixctl.h"
#include "util.h"
+#include "random.h"
VLOG_DEFINE_THIS_MODULE(ovntrace);
@@ -77,6 +78,9 @@ static uint32_t *ct_states;
static size_t n_ct_states;
static size_t ct_state_idx;
+/* --lb_dst: load balancer destination info */
+static struct ovnact_ct_lb_dst lb_dst;
+
/* --friendly-names, --no-friendly-names: Whether to substitute human-friendly
* port and datapath names for the awkward UUIDs typically used in the actual
* logical flows. */
@@ -186,6 +190,16 @@ parse_ct_option(const char *state_s_)
ct_states[n_ct_states++] = state;
}
+static void
+parse_lb_option(const char *s)
+{
+ if (ip_parse(s, &lb_dst.ipv4)) {
+ lb_dst.family = AF_INET;
+ } else if (ipv6_parse(s, &lb_dst.ipv6)) {
+ lb_dst.family = AF_INET6;
+ }
+}
+
static void
parse_options(int argc, char *argv[])
{
@@ -202,7 +216,8 @@ parse_options(int argc, char *argv[])
OPT_NO_FRIENDLY_NAMES,
DAEMON_OPTION_ENUMS,
SSL_OPTION_ENUMS,
- VLOG_OPTION_ENUMS
+ VLOG_OPTION_ENUMS,
+ OPT_LB_DST
};
static const struct option long_options[] = {
{"db", required_argument, NULL, OPT_DB},
@@ -217,6 +232,7 @@ parse_options(int argc, char *argv[])
{"no-friendly-names", no_argument, NULL, OPT_NO_FRIENDLY_NAMES},
{"help", no_argument, NULL, 'h'},
{"version", no_argument, NULL, 'V'},
+ {"lb_dst", required_argument, NULL, OPT_LB_DST},
DAEMON_LONG_OPTIONS,
VLOG_LONG_OPTIONS,
STREAM_SSL_LONG_OPTIONS,
@@ -274,6 +290,10 @@ parse_options(int argc, char *argv[])
use_friendly_names = false;
break;
+ case OPT_LB_DST:
+ parse_lb_option(optarg);
+ break;
+
case 'h':
usage();
@@ -1822,6 +1842,45 @@ execute_ct_nat(const struct ovnact_ct_nat *ct_nat,
* flow, not ct_flow. */
}
+static void
+execute_ct_lb(const struct ovnact_ct_lb *ct_lb,
+ const struct ovntrace_datapath *dp, struct flow *uflow,
+ enum ovnact_pipeline pipeline, struct ovs_list *super)
+{
+ struct flow ct_lb_flow = *uflow;
+
+ if (ct_lb->n_dsts) {
+ int i, dest = random_range(ct_lb->n_dsts);
+
+ for (i = 0; i < ct_lb->n_dsts; i++) {
+ if ((lb_dst.family == AF_INET &&
+ ct_lb->dsts[i].ipv4 == lb_dst.ipv4) ||
+ (lb_dst.family == AF_INET6 &&
+ ipv6_addr_equals(&ct_lb->dsts[i].ipv6,
+ &lb_dst.ipv6))) {
+ dest = i;
+ break;
+ }
+ }
+ if (i < ct_lb->n_dsts) {
+ memset(&lb_dst, 0, sizeof(struct ovnact_ct_lb_dst));
+ }
+
+ if (ct_lb->dsts->family == AF_INET6) {
+ ct_lb_flow.ipv6_dst = ct_lb->dsts[dest].ipv6;
+ } else {
+ ct_lb_flow.nw_dst = ct_lb->dsts[dest].ipv4;
+ }
+ if (ct_lb->dsts->port > 0) {
+ ct_lb_flow.tp_dst = ct_lb->dsts->port;
+ }
+ }
+
+ struct ovntrace_node *node = ovntrace_node_append(
+ super, OVNTRACE_NODE_TRANSFORMATION, "ct_lb");
+ trace__(dp, &ct_lb_flow, ct_lb->ltable, pipeline, &node->subs);
+}
+
static void
execute_log(const struct ovnact_log *log, struct flow *uflow,
struct ovs_list *super)
@@ -1910,8 +1969,7 @@ trace_actions(const struct ovnact *ovnacts, size_t ovnacts_len,
break;
case OVNACT_CT_LB:
- ovntrace_node_append(super, OVNTRACE_NODE_ERROR,
- "*** ct_lb action not implemented");
+ execute_ct_lb(ovnact_get_CT_LB(a), dp, uflow, pipeline, super);
break;
case OVNACT_CT_CLEAR: