On Mon, Aug 06, 2018 at 10:55:27AM -0700, Darrell Ball wrote:
> By making opt_dpif_open() more general, it can be used effectively
> by all potential callers. Also, the error handling is improved by
> having more specific errors.
> 
> Signed-off-by: Darrell Ball <dlu...@gmail.com>
> ---
>  lib/dpctl.c             | 69 
> +++++++++++++++++++++++++++++++++++++++++++++----
>  tests/system-traffic.at |  8 +++---
>  2 files changed, 68 insertions(+), 9 deletions(-)
> 
> diff --git a/lib/dpctl.c b/lib/dpctl.c
> index c600eeb..ebb1603 100644
> --- a/lib/dpctl.c
> +++ b/lib/dpctl.c
> @@ -187,18 +187,77 @@ parsed_dpif_open(const char *arg_, bool create, struct 
> dpif **dpifp)
>      return result;
>  }
>  
> +static bool
> +dp_exists(const char *queried_dp)
> +{
> +    struct sset dpif_names = SSET_INITIALIZER(&dpif_names),
> +                dpif_types = SSET_INITIALIZER(&dpif_types);
> +    int error = 0;
> +    bool found = false;
> +    struct ds ds = DS_EMPTY_INITIALIZER;;
> +
> +    dp_enumerate_types(&dpif_types);
> +
> +    const char *type;
> +    SSET_FOR_EACH (type, &dpif_types) {
> +        error = dp_enumerate_names(type, &dpif_names);
> +        if (!error) {
> +            const char *name;
> +            SSET_FOR_EACH (name, &dpif_names) {
> +                struct dpif *dpif;
> +                error = dpif_open(name, type, &dpif);
> +                if (!error) {
> +                    dpif_close(dpif);
> +                    ds_put_cstr(&ds, type);
> +                    ds_put_cstr(&ds, "@");
> +                    ds_put_cstr(&ds, name);
> +                    if (!strcmp(queried_dp, ds_cstr(&ds))) {
> +                        found = true;
> +                        goto out;
> +                    }
> +                }
> +            }
> +        }
> +    }

It looks like this can only succeed on the first try, because after that
it keeps appending more datapath names to ds.

Thanks,

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

Reply via email to