From patchwork Tue Aug 27 15:25:21 2019
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Lorenzo Bianconi
X-Patchwork-Id: 1153919
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 46Ht5V720xz9sN4
for ;
Wed, 28 Aug 2019 01:26:54 +1000 (AEST)
Received: from mail.linux-foundation.org (localhost [127.0.0.1])
by mail.linuxfoundation.org (Postfix) with ESMTP id 8C49F17ED;
Tue, 27 Aug 2019 15:26:53 +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 7D78F17E1
for ; Tue, 27 Aug 2019 15:26:52 +0000 (UTC)
X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6
Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28])
by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 1A943710
for ; Tue, 27 Aug 2019 15:26:52 +0000 (UTC)
Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com
[209.85.221.71])
(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128
bits)) (No client certificate requested)
by mx1.redhat.com (Postfix) with ESMTPS id 697F02A09D2
for ; Tue, 27 Aug 2019 15:26:51 +0000 (UTC)
Received: by mail-wr1-f71.google.com with SMTP id k14so11584043wrv.2
for ; Tue, 27 Aug 2019 08:26:51 -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:mime-version:content-transfer-encoding;
bh=37YUTuxLyZAW78GgQtAcpfadyilkWN5JVDFUCliukGI=;
b=oz6gcBlwGmmpRSmwl9LQf6A0lvqUg/2ft1u/dJi0Z336BnhLbaCBqdCa4ZLfqRqT2t
fnLaDp6u/snnXr61q4IS1URFtZ/0zdsQc+r8F9hP1gAaHolfVbv0o7qPLieiuVW5KFfv
g/Gt1SAF7kLLT32rYKlVM6K1F8/F5XQ1TAfQYwkjjh/TWkamI3jgTvBPKrUdR+3tJfrc
tDACn3CZCUgleVc1O0Un8+ow3FW3F8l0gjK34K9NOwQvqOr6oHuRGXGbMnRX3lXn9hKS
KJNmHfXdFWbCaKlx6ymn73cEc8HxYSAvwZ+DTlp4nugl9VhXFeNcKmyB0A4QgjRcbEph
1aKg==
X-Gm-Message-State: APjAAAWFfnWvCbc+4Y/9sIdu6VyAwHU2buebw0F+C2tzQHT6otdipLB7
NxVcJANifoH9DXG7RF/eDdwvzRRTTv+QusVzG+M531NSY8Gyhda1Uio19zMCdD7ad1P+b3+eijE
eeWAvxDni2yg+6i7Amg==
X-Received: by 2002:a5d:698d:: with SMTP id
g13mr1619764wru.338.1566919609896;
Tue, 27 Aug 2019 08:26:49 -0700 (PDT)
X-Google-Smtp-Source:
APXvYqzJPyb3dZ1bZcAbcYnjVSmWVf0RsgnZPjQCfClFZAz6gBC/wh+B7zaRJtRox/X5sJ6ss4h01g==
X-Received: by 2002:a5d:698d:: with SMTP id
g13mr1619734wru.338.1566919609676;
Tue, 27 Aug 2019 08:26:49 -0700 (PDT)
Received: from localhost.localdomain.com (nat-pool-mxp-t.redhat.com.
[149.6.153.186]) by smtp.gmail.com with ESMTPSA id
4sm30050834wro.78.2019.08.27.08.26.48 for
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Tue, 27 Aug 2019 08:26:49 -0700 (PDT)
From: Lorenzo Bianconi
To: ovs-dev@openvswitch.org
Date: Tue, 27 Aug 2019 17:25:21 +0200
Message-Id:
X-Mailer: git-send-email 2.21.0
In-Reply-To:
References:
MIME-Version: 1.0
X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI
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 ovn 1/2] northd: introduce
build_empty_lb_event_flow routine
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
Introduce build_empty_lb_event_flow routine and remove open code
Signed-off-by: Lorenzo Bianconi
---
northd/ovn-northd.c | 63 ++++++++++++++++++++++++++-------------------
1 file changed, 37 insertions(+), 26 deletions(-)
diff --git a/northd/ovn-northd.c b/northd/ovn-northd.c
index ca128c996..9db8b43e2 100644
--- a/northd/ovn-northd.c
+++ b/northd/ovn-northd.c
@@ -4001,6 +4001,41 @@ ls_has_dns_records(const struct nbrec_logical_switch *nbs)
return false;
}
+static void
+build_empty_lb_event_flow(struct ovn_datapath *od, struct hmap *lflows,
+ struct smap_node *node, char *ip_address,
+ struct nbrec_load_balancer *lb, uint16_t port,
+ int addr_family, int pl)
+{
+ if (!controller_event_en || node->value[0]) {
+ return;
+ }
+
+ struct ds match = DS_EMPTY_INITIALIZER;
+ char *action;
+
+ if (addr_family == AF_INET) {
+ ds_put_format(&match, "ip4.dst == %s && %s",
+ ip_address, lb->protocol);
+ } else {
+ ds_put_format(&match, "ip6.dst == %s && %s",
+ ip_address, lb->protocol);
+ }
+ if (port) {
+ ds_put_format(&match, " && %s.dst == %u", lb->protocol,
+ port);
+ }
+ action = xasprintf("trigger_event(event = \"%s\", "
+ "vip = \"%s\", protocol = \"%s\", "
+ "load_balancer = \"" UUID_FMT "\");",
+ event_to_string(OVN_EVENT_EMPTY_LB_BACKENDS),
+ node->key, lb->protocol,
+ UUID_ARGS(&lb->header_.uuid));
+ ovn_lflow_add(lflows, od, pl, 130, ds_cstr(&match), action);
+ ds_destroy(&match);
+ free(action);
+}
+
static void
build_pre_lb(struct ovn_datapath *od, struct hmap *lflows)
{
@@ -4038,32 +4073,8 @@ build_pre_lb(struct ovn_datapath *od, struct hmap *lflows)
sset_add(&all_ips, ip_address);
}
- if (controller_event_en && !node->value[0]) {
- struct ds match = DS_EMPTY_INITIALIZER;
- char *action;
-
- if (addr_family == AF_INET) {
- ds_put_format(&match, "ip4.dst == %s && %s",
- ip_address, lb->protocol);
- } else {
- ds_put_format(&match, "ip6.dst == %s && %s",
- ip_address, lb->protocol);
- }
- if (port) {
- ds_put_format(&match, " && %s.dst == %u", lb->protocol,
- port);
- }
- action = xasprintf("trigger_event(event = \"%s\", "
- "vip = \"%s\", protocol = \"%s\", "
- "load_balancer = \"" UUID_FMT "\");",
- event_to_string(OVN_EVENT_EMPTY_LB_BACKENDS),
- node->key, lb->protocol,
- UUID_ARGS(&lb->header_.uuid));
- ovn_lflow_add(lflows, od, S_SWITCH_IN_PRE_LB, 120,
- ds_cstr(&match), action);
- ds_destroy(&match);
- free(action);
- }
+ build_empty_lb_event_flow(od, lflows, node, ip_address, lb,
+ port, addr_family, S_SWITCH_IN_PRE_LB);
free(ip_address);
From patchwork Tue Aug 27 15:25:22 2019
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Lorenzo Bianconi
X-Patchwork-Id: 1153921
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 46Ht6Q3HWcz9sMr
for ;
Wed, 28 Aug 2019 01:27:42 +1000 (AEST)
Received: from mail.linux-foundation.org (localhost [127.0.0.1])
by mail.linuxfoundation.org (Postfix) with ESMTP id 6946B182E;
Tue, 27 Aug 2019 15:27:40 +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 D8F741812
for ; Tue, 27 Aug 2019 15:27:39 +0000 (UTC)
X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6
Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28])
by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 2C1E5710
for ; Tue, 27 Aug 2019 15:27:39 +0000 (UTC)
Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com
[209.85.221.69])
(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128
bits)) (No client certificate requested)
by mx1.redhat.com (Postfix) with ESMTPS id 7F9D32CE905
for ; Tue, 27 Aug 2019 15:27:38 +0000 (UTC)
Received: by mail-wr1-f69.google.com with SMTP id b15so1015709wrp.21
for ; Tue, 27 Aug 2019 08:27:38 -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:mime-version:content-transfer-encoding;
bh=b23F15C132tR1hgiy2loE0+ypTD8VclcltMdoaLxs78=;
b=PSFmymWSQCY2NlZBOHR0yizRW4OqXxvWBDL/Tu+J5/7WIRLX4SuX7H/mpBcsxdxZWA
mhOfI+y55n6W/AyPPLTss5J14dPK6rWZBT5RRShA7cT2y9LzWYzRMc0K75/aMfhHMt+g
iJFWdvccUn70M33Q1NJekPxrjEZbeFY7siBGgmoE0H1ZsV3s4vLLvHzBbPT1x7KTX5b8
qlZ0Pm7VFxO1uT3bEf8z+Gb1RjNZdXhGVv54HLvN8G/4Ao/mOCj7Jq6QfWsEMTrTc4H1
yu7A55htFEYueHI/gjO4BRc5kh8a6wO3EWLHbuTcsb7CpPVF6GMx2kOdDX99tls9wHjK
9J5g==
X-Gm-Message-State: APjAAAXP5CtTSJ8APjp6v3FRFLGWhlYxTTxiN7UCJtPiIs2DYHhdoAAj
zFXHVesNWI2wOjpnMDapcJ9hEKUoeAPx2vl7xl05VdYVBnYlrLaWPXIs2M/mRKkrXc+jleUFaDH
SOotwsmTxTcu3dEm0bg==
X-Received: by 2002:a05:600c:2111:: with SMTP id
u17mr30571087wml.64.1566919656990;
Tue, 27 Aug 2019 08:27:36 -0700 (PDT)
X-Google-Smtp-Source:
APXvYqw91RAKrIYLlqgFSgMqEC69HRZ8tQT8QL1NyrLZ7fHvEzTMrewdfLWnf0IBfJJ9S5h54nyqUg==
X-Received: by 2002:a05:600c:2111:: with SMTP id
u17mr30571039wml.64.1566919656661;
Tue, 27 Aug 2019 08:27:36 -0700 (PDT)
Received: from localhost.localdomain.com (nat-pool-mxp-t.redhat.com.
[149.6.153.186]) by smtp.gmail.com with ESMTPSA id
4sm30050834wro.78.2019.08.27.08.27.35 for
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Tue, 27 Aug 2019 08:27:36 -0700 (PDT)
From: Lorenzo Bianconi
To: ovs-dev@openvswitch.org
Date: Tue, 27 Aug 2019 17:25:22 +0200
Message-Id:
X-Mailer: git-send-email 2.21.0
In-Reply-To:
References:
MIME-Version: 1.0
X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI
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 ovn 2/2] northd: add empty_lb controller_event for
logical router
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
Add empty load balancer controller_event support to logical router
pipeline. Update northd documentation even for logical switch pipeline
Signed-off-by: Lorenzo Bianconi
---
northd/ovn-northd.8.xml | 12 +++++++++
northd/ovn-northd.c | 19 +++++++++-----
tests/ovn.at | 57 ++++++++++++++++++++++++++++++++++++-----
3 files changed, 74 insertions(+), 14 deletions(-)
diff --git a/northd/ovn-northd.8.xml b/northd/ovn-northd.8.xml
index d45bb15dc..f58338880 100644
--- a/northd/ovn-northd.8.xml
+++ b/northd/ovn-northd.8.xml
@@ -301,6 +301,10 @@
Pre-stateful
to send IP packets to the connection tracker
for packet de-fragmentation before eventually advancing to ingress table
LB
.
+ If controller_event has been enabled and load balancing rules with
+ empty backends have been added in OVN_Northbound
, a 130 flow
+ is added to trigger ovn-controller events whenever the chassis receives a
+ packet for that particular VIP
Ingress Table 5: Pre-stateful
@@ -1757,6 +1761,14 @@ icmp6 {
+ -
+ If controller_event has been enabled for all the configured load
+ balancing rules for a Gateway router or Router with gateway port
+ in
OVN_Northbound
database that does not have configured
+ backends, a priority-130 flow is added to trigger ovn-controller events
+ whenever the chassis receives a packet for that particular VIP
+
+
-
For all the configured load balancing rules for a Gateway router or
Router with gateway port in
OVN_Northbound
database that
diff --git a/northd/ovn-northd.c b/northd/ovn-northd.c
index 9db8b43e2..d6ac8159e 100644
--- a/northd/ovn-northd.c
+++ b/northd/ovn-northd.c
@@ -6127,9 +6127,13 @@ get_force_snat_ip(struct ovn_datapath *od, const char *key_type, ovs_be32 *ip)
static void
add_router_lb_flow(struct hmap *lflows, struct ovn_datapath *od,
struct ds *match, struct ds *actions, int priority,
- const char *lb_force_snat_ip, char *backend_ips,
- bool is_udp, int addr_family)
+ const char *lb_force_snat_ip, struct smap_node *node,
+ bool is_udp, int addr_family, char *ip_addr,
+ uint16_t l4_port, struct nbrec_load_balancer *lb)
{
+ build_empty_lb_event_flow(od, lflows, node, ip_addr, lb,
+ l4_port, addr_family, S_ROUTER_IN_DNAT);
+
/* A match and actions for new connections. */
char *new_match = xasprintf("ct.new && %s", ds_cstr(match));
if (lb_force_snat_ip) {
@@ -6156,7 +6160,7 @@ add_router_lb_flow(struct hmap *lflows, struct ovn_datapath *od,
free(new_match);
free(est_match);
- if (!od->l3dgw_port || !od->l3redirect_port || !backend_ips) {
+ if (!od->l3dgw_port || !od->l3redirect_port || !node->value) {
return;
}
@@ -6171,7 +6175,7 @@ add_router_lb_flow(struct hmap *lflows, struct ovn_datapath *od,
ds_put_cstr(&undnat_match, "ip6 && (");
}
char *start, *next, *ip_str;
- start = next = xstrdup(backend_ips);
+ start = next = xstrdup(node->value);
ip_str = strsep(&next, ",");
bool backend_ips_found = false;
while (ip_str && ip_str[0]) {
@@ -7469,7 +7473,6 @@ build_lrouter_flows(struct hmap *datapaths, struct hmap *ports,
ds_put_format(&match, "ip && ip6.dst == %s",
ip_address);
}
- free(ip_address);
int prio = 110;
bool is_udp = lb->protocol && !strcmp(lb->protocol, "udp") ?
@@ -7490,8 +7493,10 @@ build_lrouter_flows(struct hmap *datapaths, struct hmap *ports,
od->l3redirect_port->json_key);
}
add_router_lb_flow(lflows, od, &match, &actions, prio,
- lb_force_snat_ip, node->value, is_udp,
- addr_family);
+ lb_force_snat_ip, node, is_udp,
+ addr_family, ip_address, port, lb);
+
+ free(ip_address);
}
}
sset_destroy(&all_ips);
diff --git a/tests/ovn.at b/tests/ovn.at
index c5281a09d..86078c400 100644
--- a/tests/ovn.at
+++ b/tests/ovn.at
@@ -14679,9 +14679,22 @@ ovn_start
# Create hypervisors hv[12].
# Add vif1[12] to hv1, vif2[12] to hv2
# Add all of the vifs to a single logical switch sw0.
+# Create logical router lr0
net_add n1
-ovn-nbctl ls-add sw0
+
+ovn-nbctl create Logical_Router name=lr0 options:chassis=hv1
+for i in 0 1; do
+ idx=$((i+1))
+ ovn-nbctl ls-add sw$i
+ ovn-nbctl lrp-add lr0 lrp$i 00:00:00:00:ff:0$idx 192.168.$idx.254/24
+ ovn-nbctl \
+ -- lsp-add sw$i lrp$i-attachment \
+ -- set Logical_Switch_Port lrp$i-attachment type=router \
+ options:router-port=lrp$i \
+ addresses='"00:00:00:00:ff:'0$idx'"'
+done
+
for i in 1 2; do
sim_add hv$i
as hv$i
@@ -14701,20 +14714,35 @@ for i in 1 2; do
done
done
+as hv1
+ovn-nbctl lsp-add sw1 sw1-p0 \
+ -- lsp-set-addresses sw1-p0 "00:00:00:00:00:33 192.168.2.11"
+ovs-vsctl -- add-port br-int vif33 -- \
+ set interface vif33 \
+ external-ids:iface-id=sw1-p0 \
+ options:tx_pcap=hv$i/vif33-tx.pcap \
+ options:rxq_pcap=hv$i/vif33-rx.pcap \
+ ofport-request=33
+
+
ovn-nbctl --wait=hv set NB_Global . options:controller_event=true
ovn-nbctl lb-add lb0 192.168.1.100:80 ""
ovn-nbctl ls-lb-add sw0 lb0
-uuid_lb=$(ovn-nbctl --bare --columns=_uuid find load_balancer name=lb0)
+uuid_lb0=$(ovn-nbctl --bare --columns=_uuid find load_balancer name=lb0)
+
+ovn-nbctl lb-add lb1 192.168.2.100:80 ""
+ovn-nbctl lr-lb-add lr0 lb1
+uuid_lb1=$(ovn-nbctl --bare --columns=_uuid find load_balancer name=lb1)
OVN_POPULATE_ARP
ovn-nbctl --timeout=3 --wait=hv sync
ovn-sbctl lflow-list
as hv1 ovs-ofctl dump-flows br-int
-packet="inport==\"sw0-p11\" && eth.src==00:00:00:00:00:11 && eth.dst==00:00:00:00:00:21 &&
- ip4 && ip.ttl==64 && ip4.src==192.168.1.11 && ip4.dst==192.168.1.100 &&
- tcp && tcp.src==10000 && tcp.dst==80"
-as hv1 ovs-appctl -t ovn-controller inject-pkt "$packet"
+packet0="inport==\"sw0-p11\" && eth.src==00:00:00:00:00:11 && eth.dst==00:00:00:00:00:21 &&
+ ip4 && ip.ttl==64 && ip4.src==192.168.1.11 && ip4.dst==192.168.1.100 &&
+ tcp && tcp.src==10000 && tcp.dst==80"
+as hv1 ovs-appctl -t ovn-controller inject-pkt "$packet0"
ovn-sbctl list controller_event
uuid=$(ovn-sbctl list controller_event | awk '/_uuid/{print $3}')
@@ -14728,12 +14756,27 @@ AT_CHECK([ovn-sbctl get controller_event $uuid event_info:protocol], [0], [dnl
tcp
])
AT_CHECK_UNQUOTED([ovn-sbctl get controller_event $uuid event_info:load_balancer], [0], [dnl
-"$uuid_lb"
+"$uuid_lb0"
])
AT_CHECK([ovn-sbctl get controller_event $uuid seq_num], [0], [dnl
1
])
+ovn-sbctl destroy controller_event $uuid
+packet1="inport==\"sw1-p0\" && eth.src==00:00:00:00:00:33 && eth.dst==00:00:00:00:ff:02 &&
+ ip4 && ip.ttl==64 && ip4.src==192.168.2.11 && ip4.dst==192.168.2.100 &&
+ tcp && tcp.src==10000 && tcp.dst==80"
+
+as hv1 ovs-appctl -t ovn-controller inject-pkt "$packet1"
+ovn-sbctl list controller_event
+uuid=$(ovn-sbctl list controller_event | awk '/_uuid/{print $3}')
+AT_CHECK([ovn-sbctl get controller_event $uuid event_type], [0], [dnl
+empty_lb_backends
+])
+AT_CHECK([ovn-sbctl get controller_event $uuid event_info:vip], [0], [dnl
+"192.168.2.100:80"
+])
+
OVN_CLEANUP([hv1], [hv2])
AT_CLEANUP