git sha: 0877257ab8d19c5ac0e922165728c4bef6b8c294
Author: Eelco Chaudron <[email protected]>
Subject: dpif-offload: Allow configuration of offload provider priority.

This commit adds configuration support for prioritizing offload providers
through the 'hw-offload-priority' option, allowing users to specify the
order providers are tried when multiple exist for the same port type.

> diff --git a/lib/dpif-offload.c b/lib/dpif-offload.c
> index 62bdd31b9..672df8a38 100644
> --- a/lib/dpif-offload.c
> +++ b/lib/dpif-offload.c
> @@ -43,10 +43,14 @@ static const struct dpif_offload_class 
> *base_dpif_offload_classes[] = {
>  #ifdef DPDK_NETDEV
>      &dpif_offload_dpdk_class,
>  #endif
> +    /* If you add an offload class to this structure, make sure you also
> +     * update the dpif_offload_provider_priority_list below. */
>      &dpif_offload_dummy_class,
>      &dpif_offload_dummy_x_class,
>  };
>  
> +static char *dpif_offload_provider_priority_list = "tc,dpdk,dummy,dummy_x";

Does this code leak the original string when dpif_offload_set_global_cfg()
overwrites dpif_offload_provider_priority_list with a new xstrdup'd value?

> @@ -125,6 +129,12 @@ dpif_offload_show_classes(struct unixctl_conn *conn, int 
> argc OVS_UNUSED,
>  void
>  dp_offload_initialize(void)
>  {
> +    static struct ovsthread_once once = OVSTHREAD_ONCE_INITIALIZER;
> +
> +    if (!ovsthread_once_start(&once)) {
> +        return;
> +    }
> +
>      unixctl_command_register("dpif/offload/classes", NULL, 0, 0,
>                               dpif_offload_show_classes, NULL);
>  

[ ... ]

> @@ -391,3 +440,45 @@ dpif_offload_dump_done(struct dpif_offload_dump *dump)
>  {
>      return dump->error == EOF ? 0 : dump->error;
>  }
> +
> +void
> +dpif_offload_set_global_cfg(const struct smap *other_cfg)
> +{
> +    static struct ovsthread_once init_once = OVSTHREAD_ONCE_INITIALIZER;
> +    const char *priority = smap_get(other_cfg, "hw-offload-priority");
> +
> +    /* The 'hw-offload-priority' parameter can only be set at startup,
> +     * any successive change needs a restart. */
> +    if (ovsthread_once_start(&init_once)) {
> +        /* Initialize the dpif-offload layer in case it's not yet initialized
> +         * at the first invocation of setting the configuration. */
> +        dp_offload_initialize();
> +
> +        /* If priority is not set keep the default value. */
> +        if (priority) {
> +            char *tokens = xstrdup(priority);
> +            char *saveptr;
> +
> +            dpif_offload_provider_priority_list = xstrdup(priority);

Does this code leak the original static string "tc,dpdk,dummy,dummy_x"?
The assignment overwrites the pointer without freeing the existing memory.

> diff --git a/vswitchd/vswitch.xml b/vswitchd/vswitch.xml
> index 3dcf74402..1c298b10e 100644
> --- a/vswitchd/vswitch.xml
> +++ b/vswitchd/vswitch.xml
> @@ -254,6 +254,24 @@
>          </p>
>        </column>
>  
> +      <column name="other_config" key="hw-offload-priority"
> +              type='{"type": "string"}'>
> +        <p>
> +          This configuration sets the order of the hardware offload providers
> +          to try when multiple exist for a given datapath implementation.  
> The
> +          The argument provided should be a list of comma-separated hardware
> +          offload provider names.
> +        </p>
> +        <p>
> +          If implementations are missing from the list, they are added at the
> +          end in undefined order.
> +        </p>
> +        <p>
> +          The default value is <code>none</code>. Changing this value 
> requires
> +          restarting the daemon if hardware offload is already enabled.
> +        </p>
> +      </column>

Is the documentation incorrect about the default value? The code shows
the default as "tc,dpdk,dummy,dummy_x" but the documentation says 
"none".
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to