On Wed, May 14, 2025 at 7:50 PM Mark Michelson via dev < ovs-dev@openvswitch.org> wrote:
> On 5/12/25 16:58, Mark Michelson via dev wrote: > > There are going to be additional incremental nodes that wish to know if > > vxlan mode is enabled. Instead of having to traverse the chassis in each > > of those nodes, we can cache the vxlan status in the global config. > > > > We can do the same with the max tunnel key based on the vxlan setting. > > > > Signed-off-by: Mark Michelson <mmich...@redhat.com> > > Acked-by: Dumitru Ceara <dce...@redhat.com> > > --- > > * v4 -> v5: > > * Rebased. > > > > * v3 -> v4: > > * Rebased. > > > > * v2 -> v3: > > * Rebased, but no other changes made. > > > > * v1 -> v2: > > * Fixed compilation error. > > * Fixed indentation of is_vxlan_mode declaration. > > * Added Dumitru's ack. > > --- > > > > northd/en-global-config.c | 50 ++++++++++++++++++++++++++------------- > > northd/en-global-config.h | 3 +++ > > northd/en-northd.c | 1 + > > northd/northd.c | 21 +--------------- > > northd/northd.h | 5 +--- > > 5 files changed, 40 insertions(+), 40 deletions(-) > > > > diff --git a/northd/en-global-config.c b/northd/en-global-config.c > > index 98c2fd0cc..11513e31e 100644 > > --- a/northd/en-global-config.c > > +++ b/northd/en-global-config.c > > @@ -49,6 +49,8 @@ static bool check_nb_options_out_of_sync( > > const struct sampling_app_table *); > > static void update_sb_config_options_to_sbrec(struct > ed_type_global_config *, > > const struct > sbrec_sb_global *); > > +static bool is_vxlan_mode(const struct smap *nb_options, > > + const struct sbrec_chassis_table *); > > > > void * > > en_global_config_init(struct engine_node *node OVS_UNUSED, > > @@ -131,11 +133,11 @@ en_global_config_run(struct engine_node *node , > void *data) > > break; > > } > > } > > - uint32_t max_dp_key = > > - get_ovn_max_dp_key_local(is_vxlan_mode(&nb->options, > > - sbrec_chassis_table), > > - ic_vxlan_mode); > > - char *max_tunid = xasprintf("%d", max_dp_key); > > + config_data->vxlan_mode = is_vxlan_mode(&nb->options, > sbrec_chassis_table); > > + config_data->max_dp_tunnel_id = > > + get_ovn_max_dp_key_local(config_data->vxlan_mode, > ic_vxlan_mode); > > + > > + char *max_tunid = xasprintf("%d", config_data->max_dp_tunnel_id); > > smap_replace(options, "max_tunid", max_tunid); > > free(max_tunid); > > > > @@ -269,6 +271,11 @@ global_config_nb_global_handler(struct engine_node > *node, void *data) > > return EN_UNHANDLED; > > } > > > > + if (config_out_of_sync(&nb->options, &config_data->nb_options, > > + "vxlan_mode", false)) { > > + return false; > > + } > > I made an error when rebasing. This should return EN_UNHANDLED instead > of false. This is causing the "check VXLAN mode disabling" test to fail. > If this patch is acked then this can be fixed when merging. > > > + > > if (check_nb_options_out_of_sync(nb, config_data, sampling_apps)) { > > config_data->tracked_data.nb_options_changed = true; > > } > > @@ -390,8 +397,6 @@ global_config_nb_logical_switch_handler(struct > engine_node *node, > > EN_OVSDB_GET(engine_get_input("NB_logical_switch", node)); > > const struct nbrec_nb_global *nb = nbrec_nb_global_table_first( > > EN_OVSDB_GET(engine_get_input("NB_nb_global", node))); > > - const struct sbrec_chassis_table *sbrec_chassis_table = > > - EN_OVSDB_GET(engine_get_input("SB_chassis", node)); > > enum engine_input_handler_result result; > > > > bool ic_vxlan_mode = false; > > @@ -402,11 +407,10 @@ global_config_nb_logical_switch_handler(struct > engine_node *node, > > break; > > } > > } > > - uint32_t max_dp_key = > > - get_ovn_max_dp_key_local(is_vxlan_mode(&nb->options, > > - sbrec_chassis_table), > > + config_data->max_dp_tunnel_id = > > + get_ovn_max_dp_key_local(config_data->vxlan_mode, > > ic_vxlan_mode); > > - char *max_tunid = xasprintf("%d", max_dp_key); > > + char *max_tunid = xasprintf("%d", config_data->max_dp_tunnel_id); > > struct smap *options = &config_data->nb_options; > > const char *cur_max_tunid = smap_get(options, "max_tunid"); > > > > @@ -629,11 +633,6 @@ check_nb_options_out_of_sync( > > return true; > > } > > > > - if (config_out_of_sync(&nb->options, &config_data->nb_options, > > - "vxlan_mode", false)) { > > - return true; > > - } > > - > > if (config_out_of_sync(&nb->options, &config_data->nb_options, > > "always_tunnel", false)) { > > return true; > > @@ -695,3 +694,22 @@ chassis_features_changed(const struct > chassis_features *present, > > > > return false; > > } > > + > > +static bool > > +is_vxlan_mode(const struct smap *nb_options, > > + const struct sbrec_chassis_table *sbrec_chassis_table) > > +{ > > + if (!smap_get_bool(nb_options, "vxlan_mode", true)) { > > + return false; > > + } > > + > > + const struct sbrec_chassis *chassis; > > + SBREC_CHASSIS_TABLE_FOR_EACH (chassis, sbrec_chassis_table) { > > + for (int i = 0; i < chassis->n_encaps; i++) { > > + if (!strcmp(chassis->encaps[i]->type, "vxlan")) { > > + return true; > > + } > > + } > > + } > > + return false; > > +} > > diff --git a/northd/en-global-config.h b/northd/en-global-config.h > > index 08da8a5ab..55a1e420b 100644 > > --- a/northd/en-global-config.h > > +++ b/northd/en-global-config.h > > @@ -49,6 +49,9 @@ struct ed_type_global_config { > > > > bool ovn_internal_version_changed; > > > > + bool vxlan_mode; > > + uint32_t max_dp_tunnel_id; > > + > > bool tracked; > > struct global_config_tracked_data tracked_data; > > }; > > diff --git a/northd/en-northd.c b/northd/en-northd.c > > index 3359d8d0e..02a27aac2 100644 > > --- a/northd/en-northd.c > > +++ b/northd/en-northd.c > > @@ -116,6 +116,7 @@ northd_get_input_data(struct engine_node *node, > > input_data->svc_monitor_mac = global_config->svc_monitor_mac; > > input_data->svc_monitor_mac_ea = global_config->svc_monitor_mac_ea; > > input_data->features = &global_config->features; > > + input_data->vxlan_mode = global_config->vxlan_mode; > > } > > > > enum engine_node_state > > diff --git a/northd/northd.c b/northd/northd.c > > index 7b05147b4..1a89b5224 100644 > > --- a/northd/northd.c > > +++ b/northd/northd.c > > @@ -984,24 +984,6 @@ join_datapaths(const struct > nbrec_logical_switch_table *nbrec_ls_table, > > } > > } > > > > -bool > > -is_vxlan_mode(const struct smap *nb_options, > > - const struct sbrec_chassis_table *sbrec_chassis_table) > > -{ > > - if (!smap_get_bool(nb_options, "vxlan_mode", true)) { > > - return false; > > - } > > - > > - const struct sbrec_chassis *chassis; > > - SBREC_CHASSIS_TABLE_FOR_EACH (chassis, sbrec_chassis_table) { > > - for (int i = 0; i < chassis->n_encaps; i++) { > > - if (!strcmp(chassis->encaps[i]->type, "vxlan")) { > > - return true; > > - } > > - } > > - } > > - return false; > > -} > > > > uint32_t > > get_ovn_max_dp_key_local(bool _vxlan_mode, bool _vxlan_ic_mode) > > @@ -19326,8 +19308,7 @@ ovnnb_db_run(struct northd_input *input_data, > > use_common_zone = smap_get_bool(input_data->nb_options, > "use_common_zone", > > false); > > > > - vxlan_mode = is_vxlan_mode(input_data->nb_options, > > - input_data->sbrec_chassis_table); > > + vxlan_mode = input_data->vxlan_mode; > > > > build_datapaths(ovnsb_txn, > > input_data->nbrec_logical_switch_table, > > diff --git a/northd/northd.h b/northd/northd.h > > index 5a698458f..d4feff63d 100644 > > --- a/northd/northd.h > > +++ b/northd/northd.h > > @@ -65,6 +65,7 @@ struct northd_input { > > const char *svc_monitor_mac; > > struct eth_addr svc_monitor_mac_ea; > > const struct chassis_features *features; > > + bool vxlan_mode; > > > > /* ACL ID inputs. */ > > const struct acl_id_data *acl_id_data; > > @@ -967,10 +968,6 @@ lr_has_multiple_gw_ports(const struct ovn_datapath > *od) > > return vector_len(&od->l3dgw_ports) > 1 && !od->is_gw_router; > > } > > > > -bool > > -is_vxlan_mode(const struct smap *nb_options, > > - const struct sbrec_chassis_table *sbrec_chassis_table); > > - > > uint32_t get_ovn_max_dp_key_local(bool _vxlan_mode, bool ic_mode); > > > > /* Returns true if the logical router port 'enabled' column is empty or > > _______________________________________________ > dev mailing list > d...@openvswitch.org > https://mail.openvswitch.org/mailman/listinfo/ovs-dev > > With the return above addressed: Acked-by: Ales Musil <amu...@redhat.com> Thanks, Ales _______________________________________________ dev mailing list d...@openvswitch.org https://mail.openvswitch.org/mailman/listinfo/ovs-dev