git sha: d31516178193a4c2e8c96358715c337e7f14d05f
Author: Eelco Chaudron <[email protected]>
Subject: dpif-offload: Validate mandatory port class callbacks on registration.

This patch adds validation for mandatory port class callbacks during
offload provider registration. The port_add and port_del callbacks are
now required and runtime checks for their existence are removed from the
port management functions.

> diff --git a/lib/dpif-offload.c b/lib/dpif-offload.c
> index f48af4e2d..bcb964af8 100644
> --- a/lib/dpif-offload.c
> +++ b/lib/dpif-offload.c
> @@ -144,7 +144,9 @@ dp_offload_initialize(void)
>      for (int i = 0; i < ARRAY_SIZE(base_dpif_offload_classes); i++) {
>          ovs_assert(base_dpif_offload_classes[i]->open
>                     && base_dpif_offload_classes[i]->close
> -                   && base_dpif_offload_classes[i]->can_offload);
> +                   && base_dpif_offload_classes[i]->can_offload
> +                   && base_dpif_offload_classes[i]->port_add
> +                   && base_dpif_offload_classes[i]->port_del);
> 
>          dpif_offload_register_provider(base_dpif_offload_classes[i]);
>      }

[ ... ]

> @@ -428,10 +430,6 @@ dpif_offload_port_add(struct dpif *dpif, struct netdev 
> *netdev,
>      }
> 
>      LIST_FOR_EACH (offload, dpif_list_node, &dp_offload->offload_providers) {
> -        if (!offload->class->port_add) {
> -            continue;
> -        }
> -
>          if (offload->class->can_offload(offload, netdev)) {
>              int err = offload->class->port_add(offload, netdev, port_no);
>              if (!err) {

[ ... ]

> @@ -463,13 +461,7 @@ dpif_offload_port_del(struct dpif *dpif, odp_port_t 
> port_no)
>      }
> 
>      LIST_FOR_EACH (offload, dpif_list_node, &dp_offload->offload_providers) {
> -        int err;
> -
> -        if (!offload->class->port_del) {
> -            continue;
> -        }
> -
> -        err = offload->class->port_del(offload, port_no);
> +        int err = offload->class->port_del(offload, port_no);
>          if (err) {
>              VLOG_ERR("Failed deleting port_no %d from dpif-offload provider "
>                       "%s, error %s", port_no, dpif_offload_name(offload),

The patch looks correct. It moves validation of mandatory callbacks from
runtime to initialization time, which improves safety and performance.
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to