diff --git a/northd/en-northd.c b/northd/en-northd.c index 4479b4aff..ce4bf5d18 100644 --- a/northd/en-northd.c +++ b/northd/en-northd.c @@ -176,6 +176,23 @@ northd_sb_port_binding_handler(struct engine_node *node, return true; } +bool +northd_sb_datapath_binding_handler(struct engine_node *node, void *data) { + struct northd_data *nd = data; + + struct northd_input input_data; + + northd_get_input_data(node, &input_data); + + if (!northd_handle_sb_datapath_binding_changes( + input_data.sbrec_datapath_binding_table, &nd->ls_datapaths, + &nd->lr_datapaths)) { + return false; + } + + return true; +} + bool northd_nb_logical_router_handler(struct engine_node *node, void *data) diff --git a/northd/en-northd.h b/northd/en-northd.h index 9b7bda32a..1aac4be1b 100644 --- a/northd/en-northd.h +++ b/northd/en-northd.h @@ -18,6 +18,7 @@ bool northd_global_config_handler(struct engine_node *, void *data OVS_UNUSED); bool northd_nb_logical_switch_handler(struct engine_node *, void *data); bool northd_nb_logical_router_handler(struct engine_node *, void *data); bool northd_sb_port_binding_handler(struct engine_node *, void *data); +bool northd_sb_datapath_binding_handler(struct engine_node *, void *data); bool northd_lb_data_handler(struct engine_node *, void *data); #endif /* EN_NORTHD_H */ diff --git a/northd/inc-proc-northd.c b/northd/inc-proc-northd.c index e1073812c..bf094959a 100644 --- a/northd/inc-proc-northd.c +++ b/northd/inc-proc-northd.c @@ -184,7 +184,8 @@ void inc_proc_northd_init(struct ovsdb_idl_loop *nb, engine_add_input(&en_northd, &en_sb_chassis, NULL); engine_add_input(&en_northd, &en_sb_mirror, NULL); engine_add_input(&en_northd, &en_sb_meter, NULL); - engine_add_input(&en_northd, &en_sb_datapath_binding, NULL); + engine_add_input(&en_northd, &en_sb_datapath_binding, + northd_sb_datapath_binding_handler); engine_add_input(&en_northd, &en_sb_dns, NULL); engine_add_input(&en_northd, &en_sb_ha_chassis_group, NULL); engine_add_input(&en_northd, &en_sb_ip_multicast, NULL); diff --git a/northd/northd.c b/northd/northd.c index edddc4bde..80dfd91b2 100644 --- a/northd/northd.c +++ b/northd/northd.c @@ -4877,6 +4877,54 @@ northd_handle_sb_port_binding_changes( return true; } +bool +northd_handle_sb_datapath_binding_changes( + const struct sbrec_datapath_binding_table *sbrec_datapath_binding_table, + struct ovn_datapaths *ls_datapaths, struct ovn_datapaths *lr_datapaths) { + const struct sbrec_datapath_binding *dpb; + static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5); + SBREC_DATAPATH_BINDING_TABLE_FOR_EACH_TRACKED( + dpb, sbrec_datapath_binding_table) { + struct ovn_datapath *odp = ovn_datapath_from_sbrec( + &lr_datapaths->datapaths, &ls_datapaths->datapaths, dpb); + + if (sbrec_datapath_binding_is_new(dpb)) { + if (!odp) { + VLOG_WARN_RL(&rl, + "A datapath-binding for %08x is created but the " + "datapath is not found.", + dpb->header_.uuid.parts[0]); + return false; + } + odp->sb = dpb; + } else if (sbrec_datapath_binding_is_deleted(dpb)) { + if (odp && odp->sb == dpb) { + VLOG_WARN_RL(&rl, + "A datapath-binding for %08x is deleted but the " + "datapath.", + dpb->header_.uuid.parts[0]); + return false; + } + } else { + if (!odp) { + VLOG_WARN_RL(&rl, + "A datapath-binding for %08x is updated but the " + "not found.", + dpb->header_.uuid.parts[0]); + return false; + } + if (odp->sb != dpb) { + VLOG_WARN_RL(&rl, + "A datapath-binding for %08x is updated with a new" + "IDL row, which is unusual.", + dpb->header_.uuid.parts[0]); + return false; + } + } + } + return true; +} + /* Handler for lb_data engine changes. It does the following * For every tracked 'lb' and 'lb_group' * - it creates or deletes the ovn_lb_datapaths/ovn_lb_group_datapaths diff --git a/northd/northd.h b/northd/northd.h index 3f1cd8341..63566f69b 100644 --- a/northd/northd.h +++ b/northd/northd.h @@ -701,6 +701,9 @@ bool lflow_handle_ls_stateful_changes(struct ovsdb_idl_txn *, bool northd_handle_sb_port_binding_changes( const struct sbrec_port_binding_table *, struct hmap *ls_ports, struct hmap *lr_ports); +bool northd_handle_sb_datapath_binding_changes( + const struct sbrec_datapath_binding_table *, + struct ovn_datapaths *ls_datapaths, struct ovn_datapaths *lr_datapaths); struct tracked_lb_data; bool northd_handle_lb_data_changes(struct tracked_lb_data *,