Re: [ovs-dev] [PATCH ovn v4 2/2] northd: Add support for disabling vxlan mode.

2024-05-02 Thread Ihar Hrachyshka
This patch is the meat of the feature, and I think it could be as well
implemented without patch 1/2 in the series. I agree with this particular
patch, (assuming we adjust documentation to talk about `VXLAN mode`,
capitalized). But I also have some reservations about patch 1/2 in the
series (or at least its stated goal - to simplify the code). I commented
there, and I would like others to vote on patch 1/2.

For this patch (2/2), with capitalized VXLAN mode in docs:

Acked-By: Ihar Hrachyshka 

On Thu, May 2, 2024 at 5:51 AM Vladislav Odintsov  wrote:

> Commit [1] introduced a "vxlan mode" concept.  It brought a limitation
> for available tunnel IDs because of lack of space in VXLAN VNI.
> In vxlan mode OVN is limited by 4095 datapaths (LRs or non-transit LSs)
> and 2047 logical switch ports per datapath.
>
> Prior to this patch vxlan mode was enabled automatically if at least one
> chassis had encap of vxlan type.  In scenarios where one want to use VXLAN
> only for HW VTEP (RAMP) switch, such limitation makes no sence.
>
> This patch adds support for explicit disabling of vxlan mode via
> Northbound database.
>
> 1: https://github.com/ovn-org/ovn/commit/b07f1bc3d068
>
> CC: Ihar Hrachyshka 
> Fixes: b07f1bc3d068 ("Add VXLAN support for non-VTEP datapath bindings")
> Signed-off-by: Vladislav Odintsov 
> ---
>  NEWS  |  3 +++
>  northd/en-global-config.c |  7 ++-
>  northd/northd.c   | 10 --
>  northd/northd.h   |  3 ++-
>  ovn-architecture.7.xml|  6 ++
>  ovn-nb.xml| 10 ++
>  tests/ovn-northd.at   | 29 +
>  7 files changed, 64 insertions(+), 4 deletions(-)
>
> diff --git a/NEWS b/NEWS
> index 3b5e93dc9..43ab05a68 100644
> --- a/NEWS
> +++ b/NEWS
> @@ -17,6 +17,9 @@ Post v24.03.0
>  external-ids, the option is no longer needed as it became effectively
>  "true" for all scenarios.
>- Added DHCPv4 relay support.
> +  - Added new global config option NB_Global:options:disable_vxlan_mode to
> +extend available tunnel IDs space for datapaths from 4095 to 16711680.
> +For more details see man ovn-nb(5) for mentioned option.
>
>  OVN v24.03.0 - 01 Mar 2024
>  --
> diff --git a/northd/en-global-config.c b/northd/en-global-config.c
> index 873649a89..f5e2a8154 100644
> --- a/northd/en-global-config.c
> +++ b/northd/en-global-config.c
> @@ -115,7 +115,7 @@ en_global_config_run(struct engine_node *node , void
> *data)
>   config_data->svc_monitor_mac);
>  }
>
> -init_vxlan_mode(sbrec_chassis_table);
> +init_vxlan_mode(>options, sbrec_chassis_table);
>  char *max_tunid = xasprintf("%d", get_ovn_max_dp_key_local());
>  smap_replace(options, "max_tunid", max_tunid);
>  free(max_tunid);
> @@ -533,6 +533,11 @@ check_nb_options_out_of_sync(const struct
> nbrec_nb_global *nb,
>  return true;
>  }
>
> +if (config_out_of_sync(>options, _data->nb_options,
> +   "disable_vxlan_mode", false)) {
> +return true;
> +}
> +
>  return false;
>  }
>
> diff --git a/northd/northd.c b/northd/northd.c
> index b54219a85..d1535172e 100644
> --- a/northd/northd.c
> +++ b/northd/northd.c
> @@ -886,8 +886,14 @@ join_datapaths(const struct
> nbrec_logical_switch_table *nbrec_ls_table,
>  }
>
>  void
> -init_vxlan_mode(const struct sbrec_chassis_table *sbrec_chassis_table)
> +init_vxlan_mode(const struct smap *nb_options,
> +const struct sbrec_chassis_table *sbrec_chassis_table)
>  {
> +if (smap_get_bool(nb_options, "disable_vxlan_mode", false)) {
> +vxlan_mode = false;
> +return;
> +}
> +
>  const struct sbrec_chassis *chassis;
>  SBREC_CHASSIS_TABLE_FOR_EACH (chassis, sbrec_chassis_table) {
>  for (int i = 0; i < chassis->n_encaps; i++) {
> @@ -17593,7 +17599,7 @@ ovnnb_db_run(struct northd_input *input_data,
>  use_common_zone = smap_get_bool(input_data->nb_options,
> "use_common_zone",
>  false);
>
> -init_vxlan_mode(input_data->sbrec_chassis_table);
> +init_vxlan_mode(input_data->nb_options,
> input_data->sbrec_chassis_table);
>
>  build_datapaths(ovnsb_txn,
>  input_data->nbrec_logical_switch_table,
> diff --git a/northd/northd.h b/northd/northd.h
> index be480003e..d0322e621 100644
> --- a/northd/northd.h
> +++ b/northd/northd.h
> @@ -792,7 +792,8 @@ lr_has_multiple_gw_ports(const struct ovn_datapath *od)
>  }
>
>  void
> -init_vxlan_mode(const struct sbrec_chassis_table *sbrec_chassis_table);
> +init_vxlan_mode(const struct smap *nb_options,
> +const struct sbrec_chassis_table *sbrec_chassis_table);
>
>  uint32_t get_ovn_max_dp_key_local(void);
>
> diff --git a/ovn-architecture.7.xml b/ovn-architecture.7.xml
> index 7abb1fa83..251c9c514 100644
> --- a/ovn-architecture.7.xml
> +++ b/ovn-architecture.7.xml
> @@ -2919,4 +2919,10 @@
>  the 

[ovs-dev] [PATCH ovn v4 2/2] northd: Add support for disabling vxlan mode.

2024-05-02 Thread Vladislav Odintsov
Commit [1] introduced a "vxlan mode" concept.  It brought a limitation
for available tunnel IDs because of lack of space in VXLAN VNI.
In vxlan mode OVN is limited by 4095 datapaths (LRs or non-transit LSs)
and 2047 logical switch ports per datapath.

Prior to this patch vxlan mode was enabled automatically if at least one
chassis had encap of vxlan type.  In scenarios where one want to use VXLAN
only for HW VTEP (RAMP) switch, such limitation makes no sence.

This patch adds support for explicit disabling of vxlan mode via
Northbound database.

1: https://github.com/ovn-org/ovn/commit/b07f1bc3d068

CC: Ihar Hrachyshka 
Fixes: b07f1bc3d068 ("Add VXLAN support for non-VTEP datapath bindings")
Signed-off-by: Vladislav Odintsov 
---
 NEWS  |  3 +++
 northd/en-global-config.c |  7 ++-
 northd/northd.c   | 10 --
 northd/northd.h   |  3 ++-
 ovn-architecture.7.xml|  6 ++
 ovn-nb.xml| 10 ++
 tests/ovn-northd.at   | 29 +
 7 files changed, 64 insertions(+), 4 deletions(-)

diff --git a/NEWS b/NEWS
index 3b5e93dc9..43ab05a68 100644
--- a/NEWS
+++ b/NEWS
@@ -17,6 +17,9 @@ Post v24.03.0
 external-ids, the option is no longer needed as it became effectively
 "true" for all scenarios.
   - Added DHCPv4 relay support.
+  - Added new global config option NB_Global:options:disable_vxlan_mode to
+extend available tunnel IDs space for datapaths from 4095 to 16711680.
+For more details see man ovn-nb(5) for mentioned option.
 
 OVN v24.03.0 - 01 Mar 2024
 --
diff --git a/northd/en-global-config.c b/northd/en-global-config.c
index 873649a89..f5e2a8154 100644
--- a/northd/en-global-config.c
+++ b/northd/en-global-config.c
@@ -115,7 +115,7 @@ en_global_config_run(struct engine_node *node , void *data)
  config_data->svc_monitor_mac);
 }
 
-init_vxlan_mode(sbrec_chassis_table);
+init_vxlan_mode(>options, sbrec_chassis_table);
 char *max_tunid = xasprintf("%d", get_ovn_max_dp_key_local());
 smap_replace(options, "max_tunid", max_tunid);
 free(max_tunid);
@@ -533,6 +533,11 @@ check_nb_options_out_of_sync(const struct nbrec_nb_global 
*nb,
 return true;
 }
 
+if (config_out_of_sync(>options, _data->nb_options,
+   "disable_vxlan_mode", false)) {
+return true;
+}
+
 return false;
 }
 
diff --git a/northd/northd.c b/northd/northd.c
index b54219a85..d1535172e 100644
--- a/northd/northd.c
+++ b/northd/northd.c
@@ -886,8 +886,14 @@ join_datapaths(const struct nbrec_logical_switch_table 
*nbrec_ls_table,
 }
 
 void
-init_vxlan_mode(const struct sbrec_chassis_table *sbrec_chassis_table)
+init_vxlan_mode(const struct smap *nb_options,
+const struct sbrec_chassis_table *sbrec_chassis_table)
 {
+if (smap_get_bool(nb_options, "disable_vxlan_mode", false)) {
+vxlan_mode = false;
+return;
+}
+
 const struct sbrec_chassis *chassis;
 SBREC_CHASSIS_TABLE_FOR_EACH (chassis, sbrec_chassis_table) {
 for (int i = 0; i < chassis->n_encaps; i++) {
@@ -17593,7 +17599,7 @@ ovnnb_db_run(struct northd_input *input_data,
 use_common_zone = smap_get_bool(input_data->nb_options, "use_common_zone",
 false);
 
-init_vxlan_mode(input_data->sbrec_chassis_table);
+init_vxlan_mode(input_data->nb_options, input_data->sbrec_chassis_table);
 
 build_datapaths(ovnsb_txn,
 input_data->nbrec_logical_switch_table,
diff --git a/northd/northd.h b/northd/northd.h
index be480003e..d0322e621 100644
--- a/northd/northd.h
+++ b/northd/northd.h
@@ -792,7 +792,8 @@ lr_has_multiple_gw_ports(const struct ovn_datapath *od)
 }
 
 void
-init_vxlan_mode(const struct sbrec_chassis_table *sbrec_chassis_table);
+init_vxlan_mode(const struct smap *nb_options,
+const struct sbrec_chassis_table *sbrec_chassis_table);
 
 uint32_t get_ovn_max_dp_key_local(void);
 
diff --git a/ovn-architecture.7.xml b/ovn-architecture.7.xml
index 7abb1fa83..251c9c514 100644
--- a/ovn-architecture.7.xml
+++ b/ovn-architecture.7.xml
@@ -2919,4 +2919,10 @@
 the future, gateways that do not support encapsulations with large amounts
 of metadata may continue to have a reduced feature set.
   
+  
+vxlan mode is recommended to be disabled if VXLAN encap at
+hypervisors is needed only to support HW VTEP L2 Gateway functionality.
+See man ovn-nb(5) for table NB_Global column
+options key disable_vxlan_mode for more details.
+  
 
diff --git a/ovn-nb.xml b/ovn-nb.xml
index 5cb6ba640..a99e663e5 100644
--- a/ovn-nb.xml
+++ b/ovn-nb.xml
@@ -381,6 +381,16 @@
 of SB changes would be very noticeable.
   
 
+  
+By default if at least one chassis in OVN cluster has VXLAN encap,
+northd will run in a vxlan mode. See man
+ovn-architecture(7) Tunnel Encapsulations paragraph for
+