On 5/3/23 22:13, Ihar Hrachyshka wrote:
> This will be used in a later patch to calculate the effective interface
> MTU after considering tunneling overhead.
> 
> Signed-off-by: Ihar Hrachyshka <ihrac...@redhat.com>
> ---
>  controller/binding.c   |  4 ++--
>  controller/if-status.c | 31 +++++++++++++++++++++++++++----
>  controller/if-status.h |  3 +++
>  3 files changed, 32 insertions(+), 6 deletions(-)
> 
> diff --git a/controller/binding.c b/controller/binding.c
> index 5df62baef..561b857fa 100644
> --- a/controller/binding.c
> +++ b/controller/binding.c
> @@ -1228,7 +1228,7 @@ claim_lport(const struct sbrec_port_binding *pb,
>                  }
>                  set_pb_chassis_in_sbrec(pb, chassis_rec, true);
>              } else {
> -                if_status_mgr_claim_iface(if_mgr, pb, chassis_rec,
> +                if_status_mgr_claim_iface(if_mgr, pb, chassis_rec, iface_rec,
>                                            sb_readonly);
>              }
>              register_claim_timestamp(pb->logical_port, now);
> @@ -1241,7 +1241,7 @@ claim_lport(const struct sbrec_port_binding *pb,
>              } else {
>                  if (pb->n_up && !pb->up[0]) {
>                      if_status_mgr_claim_iface(if_mgr, pb, chassis_rec,
> -                                              sb_readonly);
> +                                              iface_rec, sb_readonly);
>                  }
>              }
>          }
> diff --git a/controller/if-status.c b/controller/if-status.c
> index d1c14ac30..f2ea21635 100644
> --- a/controller/if-status.c
> +++ b/controller/if-status.c
> @@ -24,6 +24,7 @@
>  #include "lib/util.h"
>  #include "timeval.h"
>  #include "openvswitch/vlog.h"
> +#include "lib/vswitch-idl.h"
>  #include "lib/ovn-sb-idl.h"
>  
>  VLOG_DEFINE_THIS_MODULE(if_status);
> @@ -146,6 +147,7 @@ struct ovs_iface {
>                               * be fully programmed in OVS.  Only used in 
> state
>                               * OIF_INSTALL_FLOWS.
>                               */
> +    uint16_t mtu;           /* Extracted from OVS interface.mtu field. */
>  };
>  
>  static uint64_t ifaces_usage;
> @@ -167,9 +169,10 @@ struct if_status_mgr {
>      uint32_t iface_seqno;
>  };
>  
> -static struct ovs_iface *ovs_iface_create(struct if_status_mgr *,
> -                                          const char *iface_id,
> -                                          enum if_state );
> +static struct ovs_iface *
> +ovs_iface_create(struct if_status_mgr *, const char *iface_id,
> +                 const struct ovsrec_interface *iface_rec,
> +                 enum if_state);
>  static void ovs_iface_destroy(struct if_status_mgr *, struct ovs_iface *);
>  static void ovs_iface_set_state(struct if_status_mgr *, struct ovs_iface *,
>                                  enum if_state);
> @@ -222,13 +225,14 @@ void
>  if_status_mgr_claim_iface(struct if_status_mgr *mgr,
>                            const struct sbrec_port_binding *pb,
>                            const struct sbrec_chassis *chassis_rec,
> +                          const struct ovsrec_interface *iface_rec,
>                            bool sb_readonly)
>  {
>      const char *iface_id = pb->logical_port;
>      struct ovs_iface *iface = shash_find_data(&mgr->ifaces, iface_id);
>  
>      if (!iface) {
> -        iface = ovs_iface_create(mgr, iface_id, OIF_CLAIMED);
> +        iface = ovs_iface_create(mgr, iface_id, iface_rec, OIF_CLAIMED);
>      }
>  
>      if (!sb_readonly) {
> @@ -492,14 +496,33 @@ ovs_iface_account_mem(const char *iface_id, bool erase)
>      }
>  }
>  
> +static uint16_t
> +get_iface_mtu(const struct ovsrec_interface *iface)
> +{
> +    if (!iface || !iface->n_mtu || iface->mtu[0] <= 0) {
> +        return 0;
> +    }
> +    return (uint16_t) iface->mtu[0];
> +}

We try to not use SB/OVS record fields inside the if-status module.  We
only use those records as "opaque" pointers.  Can we move the mtu
extraction outside if-status and just pass the uint16_t mtu as an
argument to if_status_mgr_claim_iface()?

Thanks,
Dumitru

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

Reply via email to