summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniele Di Proietto <diproiettod@vmware.com>2015-05-06 19:00:26 +0100
committerBen Pfaff <blp@nicira.com>2015-05-07 12:56:41 -0700
commit88c98bf5635c732d4c77e5314ec7440a08a09dec (patch)
tree0375478c1b29501cb85764bece110bcd46deb386
parent1f70f3f01aad5ba34931d9a745c3dae15f6a29a6 (diff)
downloadopenvswitch-88c98bf5635c732d4c77e5314ec7440a08a09dec.tar.gz
dpctl: Ignore enumeration errors if there is at least one datapath.
When dpctl commands are used to inspect a userspace datapath, but OVS has also built-in support for the kernel datapath, an error message is reported if the kernel module is not loaded. This commit suppresses the message. Suggested-by: Ethan Jackson <ethan@nicira.com> Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
-rw-r--r--lib/dpctl.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/lib/dpctl.c b/lib/dpctl.c
index 711b18dc4..05c28d177 100644
--- a/lib/dpctl.c
+++ b/lib/dpctl.c
@@ -621,26 +621,28 @@ dps_for_each(struct dpctl_params *dpctl_p, dps_for_each_cb cb)
{
struct sset dpif_names = SSET_INITIALIZER(&dpif_names),
dpif_types = SSET_INITIALIZER(&dpif_types);
- int error, lasterror = 0;
+ int error, openerror = 0, enumerror = 0;
const char *type, *name;
+ bool at_least_one = false;
dp_enumerate_types(&dpif_types);
SSET_FOR_EACH (type, &dpif_types) {
error = dp_enumerate_names(type, &dpif_names);
if (error) {
- lasterror = error;
+ enumerror = error;
}
SSET_FOR_EACH (name, &dpif_names) {
struct dpif *dpif;
+ at_least_one = true;
error = dpif_open(name, type, &dpif);
if (!error) {
cb(dpif, dpctl_p);
dpif_close(dpif);
} else {
- lasterror = error;
+ openerror = error;
dpctl_error(dpctl_p, error, "opening datapath %s failed",
name);
}
@@ -650,7 +652,17 @@ dps_for_each(struct dpctl_params *dpctl_p, dps_for_each_cb cb)
sset_destroy(&dpif_names);
sset_destroy(&dpif_types);
- return lasterror;
+ /* If there has been an error while opening a datapath it should be
+ * reported. Otherwise, we want to ignore the errors generated by
+ * dp_enumerate_names() if at least one datapath has been discovered,
+ * because they're not interesting for the user. This happens, for
+ * example, if OVS is using a userspace datapath and the kernel module
+ * is not loaded. */
+ if (openerror) {
+ return openerror;
+ } else {
+ return at_least_one ? 0 : enumerror;
+ }
}
static int