Git SHA: 30e72aff626522790d82fa3a6c493b0872432be4
Author: Eelco Chaudron <[email protected]>
Subject: dpif-offload: Add port dump APIs to dpif-offload.

This patch adds a port dumping APIs similar to the dpif_port_dump_...() 
APIs.

> diff --git a/lib/dpif-offload-dpdk.c b/lib/dpif-offload-dpdk.c
> index 6014db38c..211978f16 100644
> --- a/lib/dpif-offload-dpdk.c
> +++ b/lib/dpif-offload-dpdk.c
[ ... ]
> +static int
> +dpif_offload_dpdk_port_dump_start(const struct dpif_offload *offload_,
> +                                  void **statep)
> +{
> +    struct dpif_offload_dpdk *offload = dpif_offload_dpdk_cast(offload_);
> +
> +    return dpif_offload_port_mgr_port_dump_start(offload->port_mgr, statep);
> +}
> +
> +static int
> +dpif_offload_dpdk_port_dump_next(const struct dpif_offload *offload_,
> +                                 void *state,
> +                                 struct dpif_offload_port *port)
> +{
> +    struct dpif_offload_dpdk *offload = dpif_offload_dpdk_cast(offload_);
> +
> +    return dpif_offload_port_mgr_port_dump_next(offload->port_mgr, state,
> +                                                port);
> +}
> +
> +static int
> +dpif_offload_dpdk_port_dump_done(const struct dpif_offload *offload_,
> +                                 void *state)
> +{
> +    struct dpif_offload_dpdk *offload = dpif_offload_dpdk_cast(offload_);
> +
> +    return dpif_offload_port_mgr_port_dump_done(offload->port_mgr, state);
> +}

[ ... ]

> diff --git a/lib/dpif-offload.c b/lib/dpif-offload.c
> index da61a7c0e..7a2ab60e7 100644
> --- a/lib/dpif-offload.c
> +++ b/lib/dpif-offload.c

[ ... ]

> @@ -151,7 +151,9 @@ dp_offload_initialize(void)
>                     && base_dpif_offload_classes[i]->close
>                     && base_dpif_offload_classes[i]->can_offload
>                     && base_dpif_offload_classes[i]->port_add
> -                   && base_dpif_offload_classes[i]->port_del
> +                   && base_dpif_offload_classes[i]->port_dump_start
> +                   && base_dpif_offload_classes[i]->port_dump_next
> +                   && base_dpif_offload_classes[i]->port_dump_done
>                     && base_dpif_offload_classes[i]->get_netdev);

The validation check has dropped the port_del requirement check. Does this 
create a scenario where implementations could register without implementing
the port_del functionality?

> +int dpif_offload_port_mgr_port_dump_next(struct dpif_offload_port_mgr *mgr,
> +                                         void *state_,
> +                                         struct dpif_offload_port *port)
> +{
> +    struct dpif_offload_port_mgr_dump_state *state = state_;
> +    struct dpif_offload_port_mgr_port *mgr_port;
> +
> +    while (state->port_index < state->port_count) {
> +
> +        mgr_port = dpif_offload_port_mgr_find_by_odp_port(
> +            mgr, state->ports[state->port_index++]);
> +
> +        if (mgr_port) {
> +            port->netdev = netdev_ref(mgr_port->netdev);
> +            port->port_no = mgr_port->port_no;
> +
> +            netdev_close(state->last_netdev);
> +            state->last_netdev = port->netdev;
> +            return 0;
> +        }
> +    }
> +
> +    return EOF;
> +}

Could this code encounter a race condition between 
dpif_offload_port_mgr_port_dump_start and 
dpif_offload_port_mgr_port_dump_next? The dump_start function captures
port numbers at a snapshot in time, but the next function searches for 
those ports by port number. If a port is removed between these calls, 
would mgr_port be NULL and cause the while loop to skip that port?
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to