Use conditional monitor for Service Monitors.
Signed-off-by: Alexandra Rukomoinikova <[email protected]>
---
controller/ovn-controller.c | 11 ++++++++
tests/ovn-controller.at | 55 +++++++++++++++++++++++++++++++++++++
2 files changed, 66 insertions(+)
diff --git a/controller/ovn-controller.c b/controller/ovn-controller.c
index 14b9b9e28..9b7932e04 100644
--- a/controller/ovn-controller.c
+++ b/controller/ovn-controller.c
@@ -268,6 +268,7 @@ update_sb_monitors(struct ovsdb_idl *ovnsb_idl,
struct ovsdb_idl_condition ar = OVSDB_IDL_CONDITION_INIT(&ar);
struct ovsdb_idl_condition lr = OVSDB_IDL_CONDITION_INIT(&lr);
struct ovsdb_idl_condition amb = OVSDB_IDL_CONDITION_INIT(&amb);
+ struct ovsdb_idl_condition sm = OVSDB_IDL_CONDITION_INIT(&sm);
/* Always monitor all logical datapath groups. Otherwise, DPG updates may
* be received *after* the lflows using it are seen by ovn-controller.
@@ -303,6 +304,7 @@ update_sb_monitors(struct ovsdb_idl *ovnsb_idl,
ovsdb_idl_condition_add_clause_true(&nh);
ovsdb_idl_condition_add_clause_true(&ar);
ovsdb_idl_condition_add_clause_true(&amb);
+ ovsdb_idl_condition_add_clause_true(&sm);
goto out;
}
@@ -344,6 +346,10 @@ update_sb_monitors(struct ovsdb_idl *ovnsb_idl,
sbrec_chassis_template_var_add_clause_chassis(&tv, OVSDB_F_EQ,
chassis->name);
+
+ sbrec_service_monitor_add_clause_chassis_name(&sm, OVSDB_F_EQ,
+ chassis->name);
+
} else {
/* During initialization, we monitor all records in Chassis_Private so
* that we don't try to recreate existing ones. */
@@ -373,6 +379,9 @@ update_sb_monitors(struct ovsdb_idl *ovnsb_idl,
name = n->name;
/* Skip the VIFs we bound already, we should have a local datapath
* for those. */
+ /* Always monitor service monitors that relate to local ports. */
+ sbrec_service_monitor_add_clause_logical_port(&sm,
+ OVSDB_F_EQ, name);
const struct sbrec_port_binding *local_pb
= local_binding_get_primary_pb(local_bindings, name);
if (local_pb && get_lport_type(local_pb) == LP_VIF &&
@@ -436,6 +445,7 @@ out:;
sb_table_set_opt_mon_condition(ovnsb_idl, learned_route, &lr),
sb_table_set_opt_mon_condition(ovnsb_idl, advertised_mac_binding,
&amb),
+ sb_table_set_opt_mon_condition(ovnsb_idl, service_monitor, &sm),
};
unsigned int expected_cond_seqno = 0;
@@ -459,6 +469,7 @@ out:;
ovsdb_idl_condition_destroy(&ar);
ovsdb_idl_condition_destroy(&lr);
ovsdb_idl_condition_destroy(&amb);
+ ovsdb_idl_condition_destroy(&sm);
return expected_cond_seqno;
}
diff --git a/tests/ovn-controller.at b/tests/ovn-controller.at
index 6ecf50358..e3717a490 100644
--- a/tests/ovn-controller.at
+++ b/tests/ovn-controller.at
@@ -3851,3 +3851,58 @@ OVN_CLEANUP([hv1], [hv2
/already has encap ip.*cannot duplicate on/d])
AT_CLEANUP
])
+
+OVN_FOR_EACH_NORTHD([
+AT_SETUP([ovn-controller - Service Monitor conditional monitoring])
+AT_KEYWORDS([ovn])
+ovn_start
+
+net_add n1
+sim_add hv1
+ovs-vsctl add-br br-phys
+ovn_attach n1 br-phys 192.168.0.1
+
+check ovn-nbctl ls-add ls1 -- lsp-add ls1 lsp1 -- \
+ lsp-set-addresses lsp1 "50:54:00:00:00:03 10.0.0.1"
+
+as hv1
+check ovs-vsctl \
+ -- add-port br-int vif1 \
+ -- set Interface vif1 external_ids:iface-id=lsp1
+
+sim_add hv2
+as hv2
+check ovs-vsctl add-br br-phys
+ovn_attach n1 br-phys 192.168.0.12
+
+AT_SKIP_IF([ovs-vsctl get Open_vSwitch . external_ids:ovn-monitor-all | grep
-q "true"])
+
+check ovn-nbctl ls-add ls2 -- lsp-add ls1 lsp2 -- \
+ lsp-set-addresses lsp2 "50:54:00:00:00:04 10.0.0.2"
+
+as hv2
+check ovs-vsctl \
+ -- add-port br-int vif2 \
+ -- set Interface vif2 external_ids:iface-id=lsp2
+
+# Enable debug for check the received messages.
+as hv1 ovn-appctl -t ovn-controller vlog/set dbg
+as hv2 ovn-appctl -t ovn-controller vlog/set dbg
+
+check ovn-nbctl lsp-hc-add lsp1 icmp 10.0.0.255
+check ovn-nbctl lsp-hc-add lsp2 icmp 10.0.0.255
+
+check_row_count sb:Service_Monitor 2
+
+AT_CHECK([grep -c 'Service_Monitor' hv1/ovn-controller.log], [0], [dnl
+1
+])
+
+AT_CHECK([grep -c 'Service_Monitor' hv2/ovn-controller.log], [0], [dnl
+1
+])
+
+OVN_CLEANUP([hv1],[hv2])
+AT_CLEANUP
+])
+
--
2.48.1
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev