[ovs-dev] [patch v3 2/2] dpctl: Make opt_dpif_open() more general.
Darrell Ball
dball at vmware.com
Mon Aug 6 21:58:51 UTC 2018
Doh, I’ll fix it up; thanks
On 8/6/18, 2:57 PM, "ovs-dev-bounces at openvswitch.org on behalf of Ben Pfaff" <ovs-dev-bounces at openvswitch.org on behalf of blp at ovn.org> wrote:
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 <dlu998 at 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
dev at openvswitch.org
https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmail.openvswitch.org%2Fmailman%2Flistinfo%2Fovs-dev&data=02%7C01%7Cdball%40vmware.com%7Ca8378565e64b43e1d56e08d5fbe79ba4%7Cb39138ca3cee4b4aa4d6cd83d9dd62f0%7C1%7C0%7C636691894565531945&sdata=zPwmoJfqASbNO53zVq4AW7L%2FggytO1cSDFR%2FzFtA6RM%3D&reserved=0
More information about the dev
mailing list