On 7/31/25 4:45 AM, Ales Musil wrote:


On Fri, Jul 18, 2025 at 6:16 PM Mark Michelson via dev <ovs- d...@openvswitch.org <mailto:ovs-dev@openvswitch.org>> wrote:

    The northd and en-lb-data nodes were the only ones that attempted to
    interact with the northbound logical switch and logical router tables.

    This commit changes them to use synced datapaths instead. Any new engine
    nodes that are added should also consume synced datapaths instead of
    northbound logical datapaths. Essentially, synced datapaths are a proxy
    structure for northbound logical routers, northbound logical switches,
    and southbound datapath bindings.

    One side effect of this change is that the load balancer incremental
    processing test is updated. The reason is that when using synced
    datapaths, disabled logical routers essentially do not exist to any
    consumers of synced datapaths. When the test added a disabled logical
    router, it used to cause en-northd to recompute. But now, en-northd is
    not made aware of the existence of the disabled logical router, so
    en-northd does not recompute in this circumstance.

    Signed-off-by: Mark Michelson <mmich...@redhat.com
    <mailto:mmich...@redhat.com>>
    ---


Hi Mark,

thank you for the patch, I have two small nit down below.

      northd/en-lb-data.c      | 265 +++++++++++++++++++++++----------------
      northd/en-lb-data.h      |   4 +-
      northd/en-northd.c       |   4 -
      northd/inc-proc-northd.c |  38 ++----
      northd/northd.c          |  30 +++--
      northd/northd.h          |   2 -
      tests/ovn-northd.at <http://ovn-northd.at>      |   2 +-
      7 files changed, 192 insertions(+), 153 deletions(-)

    diff --git a/northd/en-lb-data.c b/northd/en-lb-data.c
    index 3b19d9ac9..c0042c4df 100644
    --- a/northd/en-lb-data.c
    +++ b/northd/en-lb-data.c
    @@ -32,6 +32,8 @@
      #include "lib/ovn-sb-idl.h"
      #include "lib/ovn-util.h"
      #include "northd.h"
    +#include "en-datapath-logical-switch.h"
    +#include "en-datapath-logical-router.h"

      VLOG_DEFINE_THIS_MODULE(en_lb_data);

    @@ -40,8 +42,8 @@ static void lb_data_destroy(struct ed_type_lb_data *);
      static void build_lbs(const struct nbrec_load_balancer_table *,
                            const struct nbrec_load_balancer_group_table *,
                            struct hmap *lbs, struct hmap *lb_groups);
    -static void build_od_lb_map(const struct nbrec_logical_switch_table *,
    -                            const struct nbrec_logical_router_table *,
    +static void build_od_lb_map(const struct
    ovn_synced_logical_switch_map *,
    +                            const struct
    ovn_synced_logical_router_map *,
                                  struct hmap *ls_lb_map, struct hmap
    *lr_lb_map);
      static struct od_lb_data *find_od_lb_data(struct hmap *od_lb_map,
                                                const struct uuid *od_uuid);
    @@ -73,10 +75,14 @@ static struct crupdated_lbgrp *
                                                 struct tracked_lb_data *);
      static void add_deleted_lbgrp_to_tracked_data(
          struct ovn_lb_group *, struct tracked_lb_data *);
    -static bool is_ls_lbs_changed(const struct nbrec_logical_switch *nbs);
    -static bool is_ls_lbgrps_changed(const struct nbrec_logical_switch
    *nbs);
    -static bool is_lr_lbs_changed(const struct nbrec_logical_router *);
    -static bool is_lr_lbgrps_changed(const struct nbrec_logical_router *);
    +static bool is_ls_lbs_changed(const struct nbrec_logical_switch *nbs,
    +                              bool is_new);
    +static bool is_ls_lbgrps_changed(const struct nbrec_logical_switch
    *nbs,
    +                                 bool is_new);
    +static bool is_lr_lbs_changed(const struct nbrec_logical_router *,
    +                              bool is_new);
    +static bool is_lr_lbgrps_changed(const struct nbrec_logical_router *,
    +                                 bool is_new);

      /* 'lb_data' engine node manages the NB load balancers and load
    balancer
       * groups.  For each NB LB, it creates 'struct ovn_northd_lb' and
    @@ -103,14 +109,14 @@ en_lb_data_run(struct engine_node *node, void
    *data)
              EN_OVSDB_GET(engine_get_input("NB_load_balancer", node));
          const struct nbrec_load_balancer_group_table *nb_lbg_table =
              EN_OVSDB_GET(engine_get_input("NB_load_balancer_group",
    node));
    -    const struct nbrec_logical_switch_table *nb_ls_table =
    -        EN_OVSDB_GET(engine_get_input("NB_logical_switch", node));
    -    const struct nbrec_logical_router_table *nb_lr_table =
    -        EN_OVSDB_GET(engine_get_input("NB_logical_router", node));
    +    const struct ovn_synced_logical_switch_map *synced_lses =
    +        engine_get_input_data("datapath_synced_logical_switch", node);
    +    const struct ovn_synced_logical_router_map *synced_lrs =
    +        engine_get_input_data("datapath_synced_logical_router", node);

          lb_data->tracked = false;
          build_lbs(nb_lb_table, nb_lbg_table, &lb_data->lbs, &lb_data-
     >lbgrps);
    -    build_od_lb_map(nb_ls_table, nb_lr_table, &lb_data->ls_lb_map,
    +    build_od_lb_map(synced_lses, synced_lrs, &lb_data->ls_lb_map,
                          &lb_data->lr_lb_map);

          return EN_UPDATED;
    @@ -320,115 +326,160 @@ lb_data_load_balancer_group_handler(struct
    engine_node *node, void *data)
          return EN_HANDLED_UPDATED;
      }

    +static bool
    +lb_data_handle_updated_logical_switch(const struct
    nbrec_logical_switch *nbs,
    +                                      struct ed_type_lb_data *lb_data,
    +                                      struct tracked_lb_data
    *trk_lb_data,
    +                                      bool is_new)
    +{
    +    bool ls_lbs_changed = is_ls_lbs_changed(nbs, is_new);
    +    bool ls_lbgrps_changed = is_ls_lbgrps_changed(nbs, is_new);
    +    if (!ls_lbs_changed && !ls_lbgrps_changed) {
    +        return false;
    +    }
    +    struct crupdated_od_lb_data *codlb = xzalloc(sizeof *codlb);


This is a nice opportunity to use xmalloc and designated initializers.

    +    codlb->od_uuid = nbs->header_.uuid;
    +    uuidset_init(&codlb->assoc_lbs);
    +    uuidset_init(&codlb->assoc_lbgrps);
    +
    +    struct od_lb_data *od_lb_data =
    +        find_od_lb_data(&lb_data->ls_lb_map, &nbs->header_.uuid);
    +    if (!od_lb_data) {
    +        od_lb_data = create_od_lb_data(&lb_data->ls_lb_map,
    +                                        &nbs->header_.uuid);
    +    }
    +
    +    if (ls_lbs_changed) {
    +        handle_od_lb_changes(nbs->load_balancer, nbs->n_load_balancer,
    +                             od_lb_data, lb_data, codlb);
    +    }
    +
    +    if (ls_lbgrps_changed) {
    +        handle_od_lbgrp_changes(nbs->load_balancer_group,
    +                                nbs->n_load_balancer_group,
    +                                od_lb_data, lb_data, codlb);
    +    }
    +
    +    ovs_list_insert(&trk_lb_data->crupdated_ls_lbs, &codlb->list_node);
    +    return true;
    +}
    +
      enum engine_input_handler_result
    -lb_data_logical_switch_handler(struct engine_node *node, void *data)
    +lb_data_synced_logical_switch_handler(struct engine_node *node,
    void *data)
      {
          struct ed_type_lb_data *lb_data = (struct ed_type_lb_data *) data;
    -    const struct nbrec_logical_switch_table *nb_ls_table =
    -        EN_OVSDB_GET(engine_get_input("NB_logical_switch", node));
    +    const struct ovn_synced_logical_switch_map *synced_lses =
    +        engine_get_input_data("datapath_synced_logical_switch", node);

          struct tracked_lb_data *trk_lb_data = &lb_data->tracked_lb_data;
          lb_data->tracked = true;

          bool changed = false;
          const struct nbrec_logical_switch *nbs;
    -    NBREC_LOGICAL_SWITCH_TABLE_FOR_EACH_TRACKED (nbs, nb_ls_table) {
    -        if (nbrec_logical_switch_is_deleted(nbs)) {
    -            struct od_lb_data *od_lb_data =
    -                find_od_lb_data(&lb_data->ls_lb_map, &nbs-
     >header_.uuid);
    -            if (od_lb_data) {
    -                hmap_remove(&lb_data->ls_lb_map, &od_lb_data-
     >hmap_node);
    -                hmapx_add(&trk_lb_data->deleted_od_lb_data,
    od_lb_data);
    -            }
    -        } else {
    -            bool ls_lbs_changed = is_ls_lbs_changed(nbs);
    -            bool ls_lbgrps_changed = is_ls_lbgrps_changed(nbs);
    -            if (!ls_lbs_changed && !ls_lbgrps_changed) {
    -                continue;
    -            }
    -            changed = true;
    -            struct crupdated_od_lb_data *codlb = xzalloc(sizeof
    *codlb);
    -            codlb->od_uuid = nbs->header_.uuid;
    -            uuidset_init(&codlb->assoc_lbs);
    -            uuidset_init(&codlb->assoc_lbgrps);
    -
    -            struct od_lb_data *od_lb_data =
    -                find_od_lb_data(&lb_data->ls_lb_map, &nbs-
     >header_.uuid);
    -            if (!od_lb_data) {
    -                od_lb_data = create_od_lb_data(&lb_data->ls_lb_map,
    -                                                &nbs->header_.uuid);
    -            }
    -
    -            if (ls_lbs_changed) {
    -                handle_od_lb_changes(nbs->load_balancer, nbs-
     >n_load_balancer,
    -                                     od_lb_data, lb_data, codlb);
    -            }
    +    struct hmapx_node *h_node;
    +    HMAPX_FOR_EACH (h_node, &synced_lses->deleted) {
    +        struct ovn_synced_logical_switch *synced = h_node->data;
    +        nbs = synced->nb;
    +        struct od_lb_data *od_lb_data =
    +            find_od_lb_data(&lb_data->ls_lb_map, &nbs->header_.uuid);
    +        if (od_lb_data) {
    +            hmap_remove(&lb_data->ls_lb_map, &od_lb_data->hmap_node);
    +            hmapx_add(&trk_lb_data->deleted_od_lb_data, od_lb_data);
    +        }
    +    }

    -            if (ls_lbgrps_changed) {
    -                handle_od_lbgrp_changes(nbs->load_balancer_group,
    -                                        nbs->n_load_balancer_group,
    -                                        od_lb_data, lb_data, codlb);
    -            }
    +    HMAPX_FOR_EACH (h_node, &synced_lses->new) {
    +        struct ovn_synced_logical_switch *synced = h_node->data;
    +        nbs = synced->nb;
    +        changed |= lb_data_handle_updated_logical_switch(nbs, lb_data,
+  trk_lb_data, true);
    +    }

    -            ovs_list_insert(&trk_lb_data->crupdated_ls_lbs, &codlb-
     >list_node);
    -        }
    +    HMAPX_FOR_EACH (h_node, &synced_lses->updated) {
    +        struct ovn_synced_logical_switch *synced = h_node->data;
    +        nbs = synced->nb;
    +        changed |= lb_data_handle_updated_logical_switch(nbs, lb_data,
+  trk_lb_data, false);
          }

          return changed ? EN_HANDLED_UPDATED : EN_HANDLED_UNCHANGED;
      }

    +static bool
    +lb_data_handle_updated_logical_router(const struct
    nbrec_logical_router *nbr,
    +                                      struct ed_type_lb_data *lb_data,
    +                                      struct tracked_lb_data
    *trk_lb_data,
    +                                      bool is_new)
    +{
    +    bool lr_lbs_changed = is_lr_lbs_changed(nbr, is_new);
    +    bool lr_lbgrps_changed = is_lr_lbgrps_changed(nbr, is_new);
    +    if (!lr_lbs_changed && !lr_lbgrps_changed) {
    +        return false;
    +    }
    +    struct crupdated_od_lb_data *codlb = xzalloc(sizeof *codlb);
    +    codlb->od_uuid = nbr->header_.uuid;
    +    uuidset_init(&codlb->assoc_lbs);
    +    uuidset_init(&codlb->assoc_lbgrps);
    +
    +    struct od_lb_data *od_lb_data =
    +        find_od_lb_data(&lb_data->lr_lb_map, &nbr->header_.uuid);
    +    if (!od_lb_data) {
    +        od_lb_data = create_od_lb_data(&lb_data->lr_lb_map,
    +                                        &nbr->header_.uuid);
    +    }
    +
    +    if (lr_lbs_changed) {
    +        handle_od_lb_changes(nbr->load_balancer, nbr->n_load_balancer,
    +                             od_lb_data, lb_data, codlb);
    +    }
    +
    +    if (lr_lbgrps_changed) {
    +        handle_od_lbgrp_changes(nbr->load_balancer_group,
    +                                nbr->n_load_balancer_group,
    +                                od_lb_data, lb_data, codlb);
    +    }
    +
    +    ovs_list_insert(&trk_lb_data->crupdated_lr_lbs, &codlb->list_node);
    +    return true;
    +}
    +
      enum engine_input_handler_result
    -lb_data_logical_router_handler(struct engine_node *node, void *data)
    +lb_data_synced_logical_router_handler(struct engine_node *node,
    void *data)
      {
          struct ed_type_lb_data *lb_data = (struct ed_type_lb_data *) data;
    -    const struct nbrec_logical_router_table *nbrec_lr_table =
    -        EN_OVSDB_GET(engine_get_input("NB_logical_router", node));
    +    const struct ovn_synced_logical_router_map *synced_lrs =
    +        engine_get_input_data("datapath_synced_logical_router", node);

          struct tracked_lb_data *trk_lb_data = &lb_data->tracked_lb_data;
          lb_data->tracked = true;

          bool changed = false;
          const struct nbrec_logical_router *nbr;
    -    NBREC_LOGICAL_ROUTER_TABLE_FOR_EACH_TRACKED (nbr, nbrec_lr_table) {
    -        if (nbrec_logical_router_is_deleted(nbr)) {
    -            struct od_lb_data *od_lb_data =
    -                find_od_lb_data(&lb_data->lr_lb_map, &nbr-
     >header_.uuid);
    -            if (od_lb_data) {
    -                hmap_remove(&lb_data->lr_lb_map, &od_lb_data-
     >hmap_node);
    -                hmapx_add(&trk_lb_data->deleted_od_lb_data,
    od_lb_data);
    -            }
    -        } else {
    -            bool lr_lbs_changed = is_lr_lbs_changed(nbr);
    -            bool lr_lbgrps_changed = is_lr_lbgrps_changed(nbr);
    -            if (!lr_lbs_changed && !lr_lbgrps_changed) {
    -                continue;
    -            }
    -            changed = true;
    -            struct crupdated_od_lb_data *codlb = xzalloc(sizeof
    *codlb);
    -            codlb->od_uuid = nbr->header_.uuid;
    -            uuidset_init(&codlb->assoc_lbs);
    -            uuidset_init(&codlb->assoc_lbgrps);
    -
    -            struct od_lb_data *od_lb_data =
    -                find_od_lb_data(&lb_data->lr_lb_map, &nbr-
     >header_.uuid);
    -            if (!od_lb_data) {
    -                od_lb_data = create_od_lb_data(&lb_data->lr_lb_map,
    -                                                &nbr->header_.uuid);
    -            }
    -
    -            if (lr_lbs_changed) {
    -                handle_od_lb_changes(nbr->load_balancer, nbr-
     >n_load_balancer,
    -                                     od_lb_data, lb_data, codlb);
    -            }
    +    struct hmapx_node *h_node;
    +
    +    HMAPX_FOR_EACH (h_node, &synced_lrs->deleted) {
    +        struct ovn_synced_logical_router *synced = h_node->data;
    +        nbr = synced->nb;
    +        struct od_lb_data *od_lb_data =
    +            find_od_lb_data(&lb_data->lr_lb_map, &nbr->header_.uuid);
    +        if (od_lb_data) {
    +            hmap_remove(&lb_data->lr_lb_map, &od_lb_data->hmap_node);
    +            hmapx_add(&trk_lb_data->deleted_od_lb_data, od_lb_data);
    +        }
    +    }

    -            if (lr_lbgrps_changed) {
    -                handle_od_lbgrp_changes(nbr->load_balancer_group,
    -                                        nbr->n_load_balancer_group,
    -                                        od_lb_data, lb_data, codlb);
    -            }
    +    HMAPX_FOR_EACH (h_node, &synced_lrs->new) {
    +        struct ovn_synced_logical_router *synced = h_node->data;
    +        nbr = synced->nb;
    +        changed |= lb_data_handle_updated_logical_router(nbr, lb_data,
+  trk_lb_data, true);
    +    }

    -            ovs_list_insert(&trk_lb_data->crupdated_lr_lbs, &codlb-
     >list_node);
    -        }
    +    HMAPX_FOR_EACH (h_node, &synced_lrs->updated) {
    +        struct ovn_synced_logical_router *synced = h_node->data;
    +        nbr = synced->nb;
    +        changed |= lb_data_handle_updated_logical_router(nbr, lb_data,
+  trk_lb_data, false);
          }

          return changed ? EN_HANDLED_UPDATED : EN_HANDLED_UNCHANGED;
    @@ -523,12 +574,14 @@ create_lb_group(const struct
    nbrec_load_balancer_group *nbrec_lb_group,
      }

      static void
    -build_od_lb_map(const struct nbrec_logical_switch_table
    *nbrec_ls_table,
    -                const struct nbrec_logical_router_table
    *nbrec_lr_table,
    +build_od_lb_map(const struct ovn_synced_logical_switch_map
    *synced_lses,
    +                const struct ovn_synced_logical_router_map *synced_lrs,
                      struct hmap *ls_lb_map, struct hmap *lr_lb_map)
      {
          const struct nbrec_logical_switch *nbrec_ls;
    -    NBREC_LOGICAL_SWITCH_TABLE_FOR_EACH (nbrec_ls, nbrec_ls_table) {
    +    const struct ovn_synced_logical_switch *synced_ls;
    +    HMAP_FOR_EACH (synced_ls, hmap_node, &synced_lses-
     >synced_switches) {
    +        nbrec_ls = synced_ls->nb;
              if (!nbrec_ls->n_load_balancer && !nbrec_ls-
     >n_load_balancer_group) {
                  continue;
              }
    @@ -546,7 +599,9 @@ build_od_lb_map(const struct
    nbrec_logical_switch_table *nbrec_ls_table,
          }

          const struct nbrec_logical_router *nbrec_lr;
    -    NBREC_LOGICAL_ROUTER_TABLE_FOR_EACH (nbrec_lr, nbrec_lr_table) {
    +    const struct ovn_synced_logical_router *synced_lr;
    +    HMAP_FOR_EACH (synced_lr, hmap_node, &synced_lrs->synced_routers) {
    +        nbrec_lr = synced_lr->nb;
              if (!nbrec_lr->n_load_balancer && !nbrec_lr-
     >n_load_balancer_group) {
                  continue;
              }
    @@ -793,29 +848,29 @@ add_deleted_lbgrp_to_tracked_data(struct
    ovn_lb_group *lbg,
      }

      static bool
    -is_ls_lbs_changed(const struct nbrec_logical_switch *nbs) {
    -    return ((nbrec_logical_switch_is_new(nbs) && nbs->n_load_balancer)
    +is_ls_lbs_changed(const struct nbrec_logical_switch *nbs, bool
    is_new) {
    +    return ((is_new && nbs->n_load_balancer)
                  ||  nbrec_logical_switch_is_updated(nbs,
                              NBREC_LOGICAL_SWITCH_COL_LOAD_BALANCER));
      }

      static bool
    -is_ls_lbgrps_changed(const struct nbrec_logical_switch *nbs) {
    -    return ((nbrec_logical_switch_is_new(nbs) && nbs-
     >n_load_balancer_group)
    +is_ls_lbgrps_changed(const struct nbrec_logical_switch *nbs, bool
    is_new) {
    +    return ((is_new && nbs->n_load_balancer_group)
                  ||  nbrec_logical_switch_is_updated(nbs,
 NBREC_LOGICAL_SWITCH_COL_LOAD_BALANCER_GROUP));
      }

      static bool
    -is_lr_lbs_changed(const struct nbrec_logical_router *nbr) {
    -    return ((nbrec_logical_router_is_new(nbr) && nbr->n_load_balancer)
    +is_lr_lbs_changed(const struct nbrec_logical_router *nbr, bool
    is_new) {
    +    return ((is_new && nbr->n_load_balancer)
                  ||  nbrec_logical_router_is_updated(nbr,
                              NBREC_LOGICAL_ROUTER_COL_LOAD_BALANCER));
      }

      static bool
    -is_lr_lbgrps_changed(const struct nbrec_logical_router *nbr) {
    -    return ((nbrec_logical_router_is_new(nbr) && nbr-
     >n_load_balancer_group)
    +is_lr_lbgrps_changed(const struct nbrec_logical_router *nbr, bool
    is_new) {
    +    return ((is_new && nbr->n_load_balancer_group)
                  ||  nbrec_logical_router_is_updated(nbr,
 NBREC_LOGICAL_ROUTER_COL_LOAD_BALANCER_GROUP));
      }
    diff --git a/northd/en-lb-data.h b/northd/en-lb-data.h
    index 583b3e412..1da087656 100644
    --- a/northd/en-lb-data.h
    +++ b/northd/en-lb-data.h
    @@ -119,8 +119,8 @@ lb_data_load_balancer_handler(struct engine_node
    *, void *data);
      enum engine_input_handler_result
      lb_data_load_balancer_group_handler(struct engine_node *, void *data);
      enum engine_input_handler_result
    -lb_data_logical_switch_handler(struct engine_node *, void *data);
    +lb_data_synced_logical_switch_handler(struct engine_node *, void
    *data);
      enum engine_input_handler_result
    -lb_data_logical_router_handler(struct engine_node *, void *data);
    +lb_data_synced_logical_router_handler(struct engine_node *, void
    *data);

      #endif /* end of EN_NORTHD_LB_DATA_H */
    diff --git a/northd/en-northd.c b/northd/en-northd.c
    index 60f3f2ef9..ff89830bd 100644
    --- a/northd/en-northd.c
    +++ b/northd/en-northd.c
    @@ -66,10 +66,6 @@ northd_get_input_data(struct engine_node *node,
                  engine_get_input("NB_mirror", node),
                  "nbrec_mirror_by_type_and_sink");

    -    input_data->nbrec_logical_switch_table =
    -        EN_OVSDB_GET(engine_get_input("NB_logical_switch", node));
    -    input_data->nbrec_logical_router_table =
    -        EN_OVSDB_GET(engine_get_input("NB_logical_router", node));
          input_data->nbrec_static_mac_binding_table =
              EN_OVSDB_GET(engine_get_input("NB_static_mac_binding", node));
          input_data->nbrec_chassis_template_var_table =
    diff --git a/northd/inc-proc-northd.c b/northd/inc-proc-northd.c
    index c126c4fb3..6bf8dde3f 100644
    --- a/northd/inc-proc-northd.c
    +++ b/northd/inc-proc-northd.c
    @@ -193,14 +193,6 @@ void inc_proc_northd_init(struct ovsdb_idl_loop
    *nb,
      {
          /* Define relationships between nodes where first argument is
    dependent
           * on the second argument */
    -    engine_add_input(&en_lb_data, &en_nb_load_balancer,
    -                     lb_data_load_balancer_handler);
    -    engine_add_input(&en_lb_data, &en_nb_load_balancer_group,
    -                     lb_data_load_balancer_group_handler);
    -    engine_add_input(&en_lb_data, &en_nb_logical_switch,
    -                     lb_data_logical_switch_handler);
    -    engine_add_input(&en_lb_data, &en_nb_logical_router,
    -                     lb_data_logical_router_handler);

          engine_add_input(&en_sampling_app, &en_nb_sampling_app, NULL);

    @@ -238,6 +230,15 @@ void inc_proc_northd_init(struct ovsdb_idl_loop
    *nb,
          engine_add_input(&en_datapath_synced_logical_switch,
    &en_datapath_sync,
en_datapath_synced_logical_switch_datapath_sync_handler);

    +    engine_add_input(&en_lb_data, &en_nb_load_balancer,
    +                     lb_data_load_balancer_handler);
    +    engine_add_input(&en_lb_data, &en_nb_load_balancer_group,
    +                     lb_data_load_balancer_group_handler);


The first two didn't have to move.

I thought the code was easier to follow by having all of en_lb_data's inputs defined in one block instead of splitting them up.


    +    engine_add_input(&en_lb_data, &en_datapath_synced_logical_switch,
    +                     lb_data_synced_logical_switch_handler);
    +    engine_add_input(&en_lb_data, &en_datapath_synced_logical_router,
    +                     lb_data_synced_logical_router_handler);
    +
          engine_add_input(&en_northd, &en_nb_mirror, NULL);
          engine_add_input(&en_northd, &en_nb_mirror_rule, NULL);
          engine_add_input(&en_northd, &en_nb_static_mac_binding, NULL);
    @@ -269,31 +270,14 @@ void inc_proc_northd_init(struct
    ovsdb_idl_loop *nb,

          engine_add_input(&en_northd, &en_sb_port_binding,
                           northd_sb_port_binding_handler);
    -    engine_add_input(&en_northd, &en_nb_logical_switch,
    +    engine_add_input(&en_northd, &en_datapath_synced_logical_switch,
                           northd_nb_logical_switch_handler);
    -    engine_add_input(&en_northd, &en_nb_logical_router,
    +    engine_add_input(&en_northd, &en_datapath_synced_logical_router,
                           northd_nb_logical_router_handler);
          engine_add_input(&en_northd, &en_lb_data, northd_lb_data_handler);
          engine_add_input(&en_northd, &en_nb_port_group,
                           northd_nb_port_group_handler);

    -    /* Currently, northd handles logical router and switch changes
    in nodes
    -     * that read directly from the northbound logical tables. Those
    nodes
    -     * will trigger a recompute if conditions on changed logical
    routers
    -     * or logical switches cannot be handled. From en-northd's
    perspective,
    -     * synced logical switch and router changes are always handled.
    -     *
    -     * Once datapath syncing has incremental processing added, then
    -     * en-northd can move its logical router and switch change
    handling to
    -     * handlers defined here, and there will be no need for
    en_northd to
    -     * read directly from the northbound database for incremental
    handling
    -     * of these types.
    -     */
    -    engine_add_input(&en_northd, &en_datapath_synced_logical_router,
    -                     engine_noop_handler);
    -    engine_add_input(&en_northd, &en_datapath_synced_logical_switch,
    -                     engine_noop_handler);
    -
          engine_add_input(&en_lr_nat, &en_northd, lr_nat_northd_handler);

          engine_add_input(&en_lr_stateful, &en_northd,
    lr_stateful_northd_handler);
    diff --git a/northd/northd.c b/northd/northd.c
    index 00d1434cb..9df8f10e0 100644
    --- a/northd/northd.c
    +++ b/northd/northd.c
    @@ -4864,12 +4864,15 @@ northd_handle_ls_changes(struct
    ovsdb_idl_txn *ovnsb_idl_txn,
          const struct nbrec_logical_switch *changed_ls;
          struct northd_tracked_data *trk_data = &nd->trk_data;

    -    NBREC_LOGICAL_SWITCH_TABLE_FOR_EACH_TRACKED (changed_ls,
    -                                             ni-
     >nbrec_logical_switch_table) {
    -        if (nbrec_logical_switch_is_new(changed_ls) ||
    -            nbrec_logical_switch_is_deleted(changed_ls)) {
    -            goto fail;
    -        }
    +    if (!hmapx_is_empty(&ni->synced_lses->new) ||
    +        !hmapx_is_empty(&ni->synced_lses->deleted)) {
    +        goto fail;
    +    }
    +
    +    struct hmapx_node *node;
    +    HMAPX_FOR_EACH (node, &ni->synced_lses->updated) {
    +        const struct ovn_synced_logical_switch *synced = node->data;
    +        changed_ls = synced->nb;
              struct ovn_datapath *od = ovn_datapath_find_(
                                          &nd->ls_datapaths.datapaths,
                                          &changed_ls->header_.uuid);
    @@ -5063,12 +5066,15 @@ northd_handle_lr_changes(const struct
    northd_input *ni,
      {
          const struct nbrec_logical_router *changed_lr;

    -    NBREC_LOGICAL_ROUTER_TABLE_FOR_EACH_TRACKED (changed_lr,
    -                                             ni-
     >nbrec_logical_router_table) {
    -        if (nbrec_logical_router_is_new(changed_lr) ||
    -            nbrec_logical_router_is_deleted(changed_lr)) {
    -            goto fail;
    -        }
    +    if (!hmapx_is_empty(&ni->synced_lrs->new) ||
    +        !hmapx_is_empty(&ni->synced_lrs->deleted)) {
    +        goto fail;
    +    }
    +
    +    struct hmapx_node *node;
    +    HMAPX_FOR_EACH (node, &ni->synced_lrs->updated) {
    +        const struct ovn_synced_logical_router *synced = node->data;
    +        changed_lr = synced->nb;

              /* Presently only able to handle load balancer,
               * load balancer group changes and NAT changes. */
    diff --git a/northd/northd.h b/northd/northd.h
    index 4c142cde0..599a81d79 100644
    --- a/northd/northd.h
    +++ b/northd/northd.h
    @@ -31,8 +31,6 @@

      struct northd_input {
          /* Northbound table references */
    -    const struct nbrec_logical_switch_table
    *nbrec_logical_switch_table;
    -    const struct nbrec_logical_router_table
    *nbrec_logical_router_table;
          const struct nbrec_static_mac_binding_table
              *nbrec_static_mac_binding_table;
          const struct nbrec_chassis_template_var_table
    diff --git a/tests/ovn-northd.at <http://ovn-northd.at> b/tests/ovn-
    northd.at <http://ovn-northd.at>
    index 6b0711c54..d0843582a 100644
    --- a/tests/ovn-northd.at <http://ovn-northd.at>
    +++ b/tests/ovn-northd.at <http://ovn-northd.at>
    @@ -12127,7 +12127,7 @@ check ovn-nbctl --wait=sb lr-add lr2 -- set
    logical_router lr2 enabled=false
      check as northd ovn-appctl -t ovn-northd inc-engine/clear-stats
      check ovn-nbctl --wait=sb lb-add lb4 10.0.0.40:4040
    <http://10.0.0.40:4040> 10.0.40.40:4050 <http://10.0.40.40:4050> \
          -- lr-lb-add lr2 lb4
    -check_engine_stats northd recompute nocompute
    +check_engine_stats northd norecompute compute
      CHECK_NO_CHANGE_AFTER_RECOMPUTE

      AT_CLEANUP
-- 2.49.0

    _______________________________________________
    dev mailing list
    d...@openvswitch.org <mailto:d...@openvswitch.org>
    https://mail.openvswitch.org/mailman/listinfo/ovs-dev <https://
    mail.openvswitch.org/mailman/listinfo/ovs-dev>


Other than that it looks good to me, thanks.

Acked-by: Ales Musil <amu...@redhat.com <mailto:amu...@redhat.com>>

_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to