On 3/4/25 6:19 PM, Mark Michelson 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 <[email protected]>
> ---

Hi Mark,

>  northd/en-global-config.c | 50 ++++++++++++++++++++++++++-------------
>  northd/en-global-config.h |  3 +++
>  northd/en-northd.c        |  1 +
>  northd/northd.c           | 23 +-----------------
>  northd/northd.h           |  5 +---
>  5 files changed, 40 insertions(+), 42 deletions(-)
> 
> diff --git a/northd/en-global-config.c b/northd/en-global-config.c
> index c103b137f..7e84d0da9 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 *sbrec_chassis_table);

Nit: indentation seems off here.  I'd write this as:

static bool is_vxlan_mode(const struct smap *nb_options,
                          const struct sbrec_chassis_table *);

With this and with Lorenzo's comments addressed:

Acked-by: Dumitru Ceara <[email protected]>

Thanks,
Dumitru

>  
>  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 false;
>      }
>  
> +    if (config_out_of_sync(&nb->options, &config_data->nb_options,
> +                           "vxlan_mode", false)) {
> +        return false;
> +    }
> +
>      if (check_nb_options_out_of_sync(nb, config_data, sampling_apps)) {
>          config_data->tracked_data.nb_options_changed = true;
>      }
> @@ -391,8 +398,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));
>  
>      bool ic_vxlan_mode = false;
>      const struct nbrec_logical_switch *nbs;
> @@ -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");
>  
> @@ -619,11 +623,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;
> @@ -685,3 +684,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 de88db18b..8d39a9ad3 100644
> --- a/northd/en-global-config.h
> +++ b/northd/en-global-config.h
> @@ -48,6 +48,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 7cea8863c..ea946696c 100644
> --- a/northd/en-northd.c
> +++ b/northd/en-northd.c
> @@ -110,6 +110,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;
>  }
>  
>  void
> diff --git a/northd/northd.c b/northd/northd.c
> index 488bfdf69..d58c68c26 100644
> --- a/northd/northd.c
> +++ b/northd/northd.c
> @@ -96,8 +96,6 @@ static bool default_acl_drop;
>   * and ports tunnel key allocation (12 bits for each instead of default 16). 
> */
>  static bool vxlan_mode;
>  
> -static bool vxlan_ic_mode;
> -
>  #define MAX_OVN_TAGS 4096
>  
>  
> @@ -974,24 +972,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)
> @@ -18810,8 +18790,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 1a7afe902..c1ea010bf 100644
> --- a/northd/northd.h
> +++ b/northd/northd.h
> @@ -63,6 +63,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;
> @@ -965,10 +966,6 @@ lr_has_multiple_gw_ports(const struct ovn_datapath *od)
>      return od->n_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
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to