From: Ben Pfaff Date: Wed, 5 Jan 2011 23:33:09 +0000 (-0800) Subject: ovs-dpctl: Use datapath enumeration functions instead of guessing names. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=17dddfc95f133997a81a02cd713fc309dd9c81ee;p=openvswitch ovs-dpctl: Use datapath enumeration functions instead of guessing names. I'm planning to get rid of userspace knowledge of ODP_MAX and this change gets rid of one user of it. Reviewed by Justin Pettit. --- diff --git a/utilities/ovs-dpctl.c b/utilities/ovs-dpctl.c index ff31fb8e..dc93d558 100644 --- a/utilities/ovs-dpctl.c +++ b/utilities/ovs-dpctl.c @@ -402,21 +402,37 @@ do_show(int argc, char *argv[]) } } } else { - unsigned int i; - for (i = 0; i < ODP_MAX; i++) { - char name[128]; - struct dpif *dpif; - int error; - - sprintf(name, "dp%u", i); - error = parsed_dpif_open(name, false, &dpif); - if (!error) { - show_dpif(dpif); - } else if (error != ENODEV) { - ovs_error(error, "opening datapath %s failed", name); + struct svec types; + const char *type; + size_t i; + + svec_init(&types); + dp_enumerate_types(&types); + SVEC_FOR_EACH (i, type, &types) { + struct svec names; + const char *name; + size_t j; + + svec_init(&names); + if (dp_enumerate_names(type, &names)) { failure = true; + continue; + } + SVEC_FOR_EACH (j, name, &names) { + struct dpif *dpif; + int error; + + error = dpif_open(name, type, &dpif); + if (!error) { + show_dpif(dpif); + } else { + ovs_error(error, "opening datapath %s failed", name); + failure = true; + } } + svec_destroy(&names); } + svec_destroy(&types); } if (failure) { exit(EXIT_FAILURE);