|
|
5f9769 |
From 36a57e7a388277d1e45f0cadd8e2601490a76b2d Mon Sep 17 00:00:00 2001
|
|
|
5f9769 |
From: Dumitru Ceara <dceara@redhat.com>
|
|
|
5f9769 |
Date: Wed, 3 Feb 2021 20:36:30 +0100
|
|
|
5f9769 |
Subject: [PATCH 1/4] binding: Correctly set Port_Binding.up for
|
|
|
5f9769 |
container/virtual ports.
|
|
|
5f9769 |
|
|
|
5f9769 |
For port bindings that are children of other port bindings (container
|
|
|
5f9769 |
and virtual ports) set Port_Binding.up directly, when claimed, if their
|
|
|
5f9769 |
parent bindings are already up.
|
|
|
5f9769 |
|
|
|
5f9769 |
For non-VIF port bindings maintain compatibility with older versions
|
|
|
5f9769 |
and set Port_Binding.up as soon as they are claimed.
|
|
|
5f9769 |
|
|
|
5f9769 |
Reported-by: Ben Pfaff <blp@ovn.org>
|
|
|
5f9769 |
Fixes: 4d3cb42b076b ("binding: Set Logical_Switch_Port.up when all OVS flows are installed.")
|
|
|
5f9769 |
Signed-off-by: Dumitru Ceara <dceara@redhat.com>
|
|
|
5f9769 |
Signed-off-by: Numan Siddique <numans@ovn.org>
|
|
|
5f9769 |
(cherry picked from upstream commit aae25e67b1ba86e34d670eb808de86f7ba66c3c0)
|
|
|
5f9769 |
|
|
|
5f9769 |
Conflicts:
|
|
|
5f9769 |
tests/ovn.at
|
|
|
5f9769 |
|
|
|
5f9769 |
Change-Id: I17c5a4d0f89868190c81c7221caadf29959064b1
|
|
|
5f9769 |
---
|
|
|
5f9769 |
controller-vtep/binding.c | 3 +++
|
|
|
5f9769 |
controller/binding.c | 47 +++++++++++++++++++++++++++++++++++++++++------
|
|
|
5f9769 |
tests/ovn.at | 32 ++++++++++++++++++++++++++------
|
|
|
5f9769 |
3 files changed, 70 insertions(+), 12 deletions(-)
|
|
|
5f9769 |
|
|
|
5f9769 |
diff --git a/controller-vtep/binding.c b/controller-vtep/binding.c
|
|
|
5f9769 |
index 8337715..d28a598 100644
|
|
|
5f9769 |
--- a/controller-vtep/binding.c
|
|
|
5f9769 |
+++ b/controller-vtep/binding.c
|
|
|
5f9769 |
@@ -109,7 +109,10 @@ update_pb_chassis(const struct sbrec_port_binding *port_binding_rec,
|
|
|
5f9769 |
port_binding_rec->chassis->name,
|
|
|
5f9769 |
chassis_rec->name);
|
|
|
5f9769 |
}
|
|
|
5f9769 |
+
|
|
|
5f9769 |
+ bool up = true;
|
|
|
5f9769 |
sbrec_port_binding_set_chassis(port_binding_rec, chassis_rec);
|
|
|
5f9769 |
+ sbrec_port_binding_set_up(port_binding_rec, &up, 1);
|
|
|
5f9769 |
}
|
|
|
5f9769 |
}
|
|
|
5f9769 |
|
|
|
5f9769 |
diff --git a/controller/binding.c b/controller/binding.c
|
|
|
5f9769 |
index d44f635..353debe 100644
|
|
|
5f9769 |
--- a/controller/binding.c
|
|
|
5f9769 |
+++ b/controller/binding.c
|
|
|
5f9769 |
@@ -864,21 +864,52 @@ get_lport_type(const struct sbrec_port_binding *pb)
|
|
|
5f9769 |
return LP_UNKNOWN;
|
|
|
5f9769 |
}
|
|
|
5f9769 |
|
|
|
5f9769 |
+/* For newly claimed ports, if 'notify_up' is 'false':
|
|
|
5f9769 |
+ * - set the 'pb.up' field to true if 'pb' has no 'parent_pb'.
|
|
|
5f9769 |
+ * - set the 'pb.up' field to true if 'parent_pb.up' is 'true' (e.g., for
|
|
|
5f9769 |
+ * container and virtual ports).
|
|
|
5f9769 |
+ * Otherwise request a notification to be sent when the OVS flows
|
|
|
5f9769 |
+ * corresponding to 'pb' have been installed.
|
|
|
5f9769 |
+ */
|
|
|
5f9769 |
+static void
|
|
|
5f9769 |
+claimed_lport_set_up(const struct sbrec_port_binding *pb,
|
|
|
5f9769 |
+ const struct sbrec_port_binding *parent_pb,
|
|
|
5f9769 |
+ const struct sbrec_chassis *chassis_rec,
|
|
|
5f9769 |
+ bool notify_up)
|
|
|
5f9769 |
+{
|
|
|
5f9769 |
+ if (!notify_up) {
|
|
|
5f9769 |
+ bool up = true;
|
|
|
5f9769 |
+ if (!parent_pb || (parent_pb->n_up && parent_pb->up[0])) {
|
|
|
5f9769 |
+ sbrec_port_binding_set_up(pb, &up, 1);
|
|
|
5f9769 |
+ }
|
|
|
5f9769 |
+ return;
|
|
|
5f9769 |
+ }
|
|
|
5f9769 |
+
|
|
|
5f9769 |
+ if (pb->chassis != chassis_rec) {
|
|
|
5f9769 |
+ binding_iface_bound_add(pb->logical_port);
|
|
|
5f9769 |
+ }
|
|
|
5f9769 |
+}
|
|
|
5f9769 |
+
|
|
|
5f9769 |
/* Returns false if lport is not claimed due to 'sb_readonly'.
|
|
|
5f9769 |
* Returns true otherwise.
|
|
|
5f9769 |
*/
|
|
|
5f9769 |
static bool
|
|
|
5f9769 |
claim_lport(const struct sbrec_port_binding *pb,
|
|
|
5f9769 |
+ const struct sbrec_port_binding *parent_pb,
|
|
|
5f9769 |
const struct sbrec_chassis *chassis_rec,
|
|
|
5f9769 |
const struct ovsrec_interface *iface_rec,
|
|
|
5f9769 |
- bool sb_readonly, struct hmap *tracked_datapaths)
|
|
|
5f9769 |
+ bool sb_readonly, bool notify_up,
|
|
|
5f9769 |
+ struct hmap *tracked_datapaths)
|
|
|
5f9769 |
{
|
|
|
5f9769 |
+ if (!sb_readonly) {
|
|
|
5f9769 |
+ claimed_lport_set_up(pb, parent_pb, chassis_rec, notify_up);
|
|
|
5f9769 |
+ }
|
|
|
5f9769 |
+
|
|
|
5f9769 |
if (pb->chassis != chassis_rec) {
|
|
|
5f9769 |
if (sb_readonly) {
|
|
|
5f9769 |
return false;
|
|
|
5f9769 |
}
|
|
|
5f9769 |
|
|
|
5f9769 |
- binding_iface_bound_add(pb->logical_port);
|
|
|
5f9769 |
if (pb->chassis) {
|
|
|
5f9769 |
VLOG_INFO("Changing chassis for lport %s from %s to %s.",
|
|
|
5f9769 |
pb->logical_port, pb->chassis->name,
|
|
|
5f9769 |
@@ -1041,8 +1072,12 @@ consider_vif_lport_(const struct sbrec_port_binding *pb,
|
|
|
5f9769 |
if (lbinding_set) {
|
|
|
5f9769 |
if (can_bind) {
|
|
|
5f9769 |
/* We can claim the lport. */
|
|
|
5f9769 |
- if (!claim_lport(pb, b_ctx_in->chassis_rec, lbinding->iface,
|
|
|
5f9769 |
- !b_ctx_in->ovnsb_idl_txn,
|
|
|
5f9769 |
+ const struct sbrec_port_binding *parent_pb =
|
|
|
5f9769 |
+ lbinding->parent ? lbinding->parent->pb : NULL;
|
|
|
5f9769 |
+
|
|
|
5f9769 |
+ if (!claim_lport(pb, parent_pb, b_ctx_in->chassis_rec,
|
|
|
5f9769 |
+ lbinding->iface, !b_ctx_in->ovnsb_idl_txn,
|
|
|
5f9769 |
+ !lbinding->parent,
|
|
|
5f9769 |
b_ctx_out->tracked_dp_bindings)){
|
|
|
5f9769 |
return false;
|
|
|
5f9769 |
}
|
|
|
5f9769 |
@@ -1246,8 +1281,8 @@ consider_nonvif_lport_(const struct sbrec_port_binding *pb,
|
|
|
5f9769 |
b_ctx_out->tracked_dp_bindings);
|
|
|
5f9769 |
|
|
|
5f9769 |
update_local_lport_ids(pb, b_ctx_out);
|
|
|
5f9769 |
- return claim_lport(pb, b_ctx_in->chassis_rec, NULL,
|
|
|
5f9769 |
- !b_ctx_in->ovnsb_idl_txn,
|
|
|
5f9769 |
+ return claim_lport(pb, NULL, b_ctx_in->chassis_rec, NULL,
|
|
|
5f9769 |
+ !b_ctx_in->ovnsb_idl_txn, false,
|
|
|
5f9769 |
b_ctx_out->tracked_dp_bindings);
|
|
|
5f9769 |
} else if (pb->chassis == b_ctx_in->chassis_rec) {
|
|
|
5f9769 |
return release_lport(pb, !b_ctx_in->ovnsb_idl_txn,
|
|
|
5f9769 |
diff --git a/tests/ovn.at b/tests/ovn.at
|
|
|
5f9769 |
index dfb94d2..1956f5c 100644
|
|
|
5f9769 |
--- a/tests/ovn.at
|
|
|
5f9769 |
+++ b/tests/ovn.at
|
|
|
5f9769 |
@@ -8992,6 +8992,7 @@ AT_CHECK([test -z $bar2_zoneid])
|
|
|
5f9769 |
# Add back bar2
|
|
|
5f9769 |
ovn-nbctl lsp-add bar bar2 vm2 1 \
|
|
|
5f9769 |
-- lsp-set-addresses bar2 "f0:00:00:01:02:08 192.168.2.3"
|
|
|
5f9769 |
+wait_for_ports_up
|
|
|
5f9769 |
ovn-nbctl --wait=hv sync
|
|
|
5f9769 |
|
|
|
5f9769 |
bar2_zoneid=$(as hv2 ovs-vsctl get bridge br-int external_ids:ct-zone-bar2)
|
|
|
5f9769 |
@@ -14671,6 +14672,8 @@ OVS_WAIT_UNTIL(
|
|
|
5f9769 |
logical_port=ls1-lp_ext1`
|
|
|
5f9769 |
test "$chassis" = "$hv1_uuid"])
|
|
|
5f9769 |
|
|
|
5f9769 |
+wait_for_ports_up ls1-lp_ext1
|
|
|
5f9769 |
+
|
|
|
5f9769 |
# There should be DHCPv4/v6 OF flows for the ls1-lp_ext1 port in hv1
|
|
|
5f9769 |
(ovn-sbctl dump-flows lr0; ovn-sbctl dump-flows ls1) > sbflows
|
|
|
5f9769 |
as hv1 ovs-ofctl dump-flows br-int > brintflows
|
|
|
5f9769 |
@@ -14951,6 +14954,7 @@ OVS_WAIT_UNTIL(
|
|
|
5f9769 |
[chassis=`ovn-sbctl --bare --columns chassis find port_binding \
|
|
|
5f9769 |
logical_port=ls1-lp_ext1`
|
|
|
5f9769 |
test "$chassis" = "$hv2_uuid"])
|
|
|
5f9769 |
+wait_for_ports_up ls1-lp_ext1
|
|
|
5f9769 |
|
|
|
5f9769 |
# There should be OF flows for DHCP4/v6 for the ls1-lp_ext1 port in hv2
|
|
|
5f9769 |
AT_CHECK([as hv2 ovs-ofctl dump-flows br-int | \
|
|
|
5f9769 |
@@ -15065,6 +15069,7 @@ OVS_WAIT_UNTIL(
|
|
|
5f9769 |
[chassis=`ovn-sbctl --bare --columns chassis find port_binding \
|
|
|
5f9769 |
logical_port=ls1-lp_ext1`
|
|
|
5f9769 |
test "$chassis" = "$hv1_uuid"])
|
|
|
5f9769 |
+wait_for_ports_up ls1-lp_ext1
|
|
|
5f9769 |
|
|
|
5f9769 |
as hv1
|
|
|
5f9769 |
ovs-vsctl show
|
|
|
5f9769 |
@@ -15145,6 +15150,7 @@ OVS_WAIT_UNTIL(
|
|
|
5f9769 |
[chassis=`ovn-sbctl --bare --columns chassis find port_binding \
|
|
|
5f9769 |
logical_port=ls1-lp_ext1`
|
|
|
5f9769 |
test "$chassis" = "$hv3_uuid"])
|
|
|
5f9769 |
+wait_for_ports_up ls1-lp_ext1
|
|
|
5f9769 |
|
|
|
5f9769 |
as hv1
|
|
|
5f9769 |
ovs-vsctl show
|
|
|
5f9769 |
@@ -15229,6 +15235,7 @@ OVS_WAIT_UNTIL(
|
|
|
5f9769 |
[chassis=`ovn-sbctl --bare --columns chassis find port_binding \
|
|
|
5f9769 |
logical_port=ls1-lp_ext1`
|
|
|
5f9769 |
test "$chassis" = "$hv1_uuid"])
|
|
|
5f9769 |
+wait_for_ports_up ls1-lp_ext1
|
|
|
5f9769 |
|
|
|
5f9769 |
# There should be a flow in hv2 to drop traffic from ls1-lp_ext1 destined
|
|
|
5f9769 |
# to router mac.
|
|
|
5f9769 |
@@ -15246,6 +15253,7 @@ OVS_WAIT_UNTIL(
|
|
|
5f9769 |
[chassis=`ovn-sbctl --bare --columns chassis find port_binding \
|
|
|
5f9769 |
logical_port=ls1-lp_ext1`
|
|
|
5f9769 |
test "$chassis" = "$hv2_uuid"])
|
|
|
5f9769 |
+wait_for_ports_up ls1-lp_ext1
|
|
|
5f9769 |
|
|
|
5f9769 |
as hv1
|
|
|
5f9769 |
OVS_APP_EXIT_AND_WAIT([ovs-vswitchd])
|
|
|
5f9769 |
@@ -16604,12 +16612,10 @@ spa=$(ip_to_hex 10 0 0 10)
|
|
|
5f9769 |
tpa=$(ip_to_hex 10 0 0 10)
|
|
|
5f9769 |
send_garp 1 1 $eth_src $eth_dst $spa $tpa
|
|
|
5f9769 |
|
|
|
5f9769 |
-OVS_WAIT_UNTIL([test x$(ovn-sbctl --bare --columns chassis find port_binding \
|
|
|
5f9769 |
-logical_port=sw0-vir) = x$hv1_ch_uuid], [0], [])
|
|
|
5f9769 |
-
|
|
|
5f9769 |
-AT_CHECK([test x$(ovn-sbctl --bare --columns virtual_parent find port_binding \
|
|
|
5f9769 |
-logical_port=sw0-vir) = xsw0-p1])
|
|
|
5f9769 |
-
|
|
|
5f9769 |
+wait_row_count Port_Binding 1 logical_port=sw0-vir chassis=$hv1_ch_uuid
|
|
|
5f9769 |
+check_row_count Port_Binding 1 logical_port=sw0-vir virtual_parent=sw0-p1
|
|
|
5f9769 |
+wait_for_ports_up sw0-vir
|
|
|
5f9769 |
+check ovn-nbctl --wait=hv sync
|
|
|
5f9769 |
|
|
|
5f9769 |
# There should be an arp resolve flow to resolve the virtual_ip with the
|
|
|
5f9769 |
# sw0-p1's MAC.
|
|
|
5f9769 |
@@ -16627,6 +16633,8 @@ ovn-sbctl clear port_binding $pb_uuid virtual_parent
|
|
|
5f9769 |
OVS_WAIT_UNTIL([test x$(ovn-sbctl --bare --columns chassis find port_binding \
|
|
|
5f9769 |
logical_port=sw0-vir) = x])
|
|
|
5f9769 |
|
|
|
5f9769 |
+wait_row_count nb:Logical_Switch_Port 1 up=false name=sw0-vir
|
|
|
5f9769 |
+
|
|
|
5f9769 |
# From sw0-p0 resend GARP for 10.0.0.10. hv1 should reclaim sw0-vir
|
|
|
5f9769 |
# and sw0-p1 should be its virtual_parent.
|
|
|
5f9769 |
send_garp 1 1 $eth_src $eth_dst $spa $tpa
|
|
|
5f9769 |
@@ -16637,6 +16645,8 @@ logical_port=sw0-vir) = x$hv1_ch_uuid], [0], [])
|
|
|
5f9769 |
AT_CHECK([test x$(ovn-sbctl --bare --columns virtual_parent find port_binding \
|
|
|
5f9769 |
logical_port=sw0-vir) = xsw0-p1])
|
|
|
5f9769 |
|
|
|
5f9769 |
+wait_for_ports_up sw0-vir
|
|
|
5f9769 |
+
|
|
|
5f9769 |
# From sw0-p3 send GARP for 10.0.0.10. hv1 should claim sw0-vir
|
|
|
5f9769 |
# and sw0-p3 should be its virtual_parent.
|
|
|
5f9769 |
eth_src=505400000005
|
|
|
5f9769 |
@@ -16651,6 +16661,7 @@ logical_port=sw0-vir) = x$hv1_ch_uuid], [0], [])
|
|
|
5f9769 |
OVS_WAIT_UNTIL([test x$(ovn-sbctl --bare --columns virtual_parent find port_binding \
|
|
|
5f9769 |
logical_port=sw0-vir) = xsw0-p3])
|
|
|
5f9769 |
|
|
|
5f9769 |
+wait_for_ports_up sw0-vir
|
|
|
5f9769 |
|
|
|
5f9769 |
# There should be an arp resolve flow to resolve the virtual_ip with the
|
|
|
5f9769 |
# sw0-p2's MAC.
|
|
|
5f9769 |
@@ -16676,6 +16687,7 @@ logical_port=sw0-vir) = x$hv2_ch_uuid], [0], [])
|
|
|
5f9769 |
AT_CHECK([test x$(ovn-sbctl --bare --columns virtual_parent find port_binding \
|
|
|
5f9769 |
logical_port=sw0-vir) = xsw0-p2])
|
|
|
5f9769 |
|
|
|
5f9769 |
+wait_for_ports_up sw0-vir
|
|
|
5f9769 |
|
|
|
5f9769 |
# There should be an arp resolve flow to resolve the virtual_ip with the
|
|
|
5f9769 |
# sw0-p3's MAC.
|
|
|
5f9769 |
@@ -16701,6 +16713,8 @@ sleep 1
|
|
|
5f9769 |
AT_CHECK([test x$(ovn-sbctl --bare --columns virtual_parent find port_binding \
|
|
|
5f9769 |
logical_port=sw0-vir) = xsw0-p1])
|
|
|
5f9769 |
|
|
|
5f9769 |
+wait_for_ports_up sw0-vir
|
|
|
5f9769 |
+
|
|
|
5f9769 |
ovn-sbctl dump-flows lr0 > lr0-flows5
|
|
|
5f9769 |
AT_CAPTURE_FILE([lr0-flows5])
|
|
|
5f9769 |
AT_CHECK([grep lr_in_arp_resolve lr0-flows5 | grep "reg0 == 10.0.0.10" | sed 's/table=../table=??/'], [0], [dnl
|
|
|
5f9769 |
@@ -16717,6 +16731,8 @@ sleep 1
|
|
|
5f9769 |
AT_CHECK([test x$(ovn-sbctl --bare --columns virtual_parent find port_binding \
|
|
|
5f9769 |
logical_port=sw0-vir) = x])
|
|
|
5f9769 |
|
|
|
5f9769 |
+wait_row_count nb:Logical_Switch_Port 1 up=false name=sw0-vir
|
|
|
5f9769 |
+
|
|
|
5f9769 |
# Since the sw0-vir is not claimed by any chassis, eth.dst should be set to
|
|
|
5f9769 |
# zero if the ip4.dst is the virtual ip.
|
|
|
5f9769 |
ovn-sbctl dump-flows lr0 > lr0-flows6
|
|
|
5f9769 |
@@ -16740,6 +16756,8 @@ sleep 1
|
|
|
5f9769 |
AT_CHECK([test x$(ovn-sbctl --bare --columns virtual_parent find port_binding \
|
|
|
5f9769 |
logical_port=sw0-vir) = xsw0-p2])
|
|
|
5f9769 |
|
|
|
5f9769 |
+wait_for_ports_up sw0-vir
|
|
|
5f9769 |
+
|
|
|
5f9769 |
ovn-sbctl dump-flows lr0 > lr0-flows7
|
|
|
5f9769 |
AT_CAPTURE_FILE([lr0-flows7])
|
|
|
5f9769 |
AT_CHECK([grep lr_in_arp_resolve lr0-flows7 | grep "reg0 == 10.0.0.10" | sed 's/table=../table=??/'], [0], [dnl
|
|
|
5f9769 |
@@ -16754,6 +16772,8 @@ logical_port=sw0-vir) = x], [0], [])
|
|
|
5f9769 |
AT_CHECK([test x$(ovn-sbctl --bare --columns virtual_parent find port_binding \
|
|
|
5f9769 |
logical_port=sw0-vir) = x])
|
|
|
5f9769 |
|
|
|
5f9769 |
+wait_row_count nb:Logical_Switch_Port 1 up=false name=sw0-vir
|
|
|
5f9769 |
+
|
|
|
5f9769 |
# Clear virtual_ip column of sw0-vir. There should be no bind_vport flows.
|
|
|
5f9769 |
ovn-nbctl --wait=hv remove logical_switch_port sw0-vir options virtual-ip
|
|
|
5f9769 |
|
|
|
5f9769 |
--
|
|
|
5f9769 |
1.8.3.1
|
|
|
5f9769 |
|