[ovs-dev] [next 25/35] dpif: Better log unusual errors in dpif_port_query_by_name().

Ben Pfaff blp at nicira.com
Tue Apr 26 16:24:51 UTC 2011


Logging these unusual errors at a low level means that we can remove a
bit of higher-level code from ofproto.

The ofproto change also changes behavior for these error cases, from doing
nothing to removing the port, but I think that's OK.  I've never noticed
this log message.
---
 lib/dpif.c |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/lib/dpif.c b/lib/dpif.c
index 26d3dc2..3786bb7 100644
--- a/lib/dpif.c
+++ b/lib/dpif.c
@@ -533,11 +533,14 @@ dpif_port_query_by_name(const struct dpif *dpif, const char *devname,
     } else {
         memset(port, 0, sizeof *port);
 
-        /* Log level is DBG here because all the current callers are interested
-         * in whether 'dpif' actually has a port 'devname', so that it's not an
-         * issue worth logging if it doesn't. */
-        VLOG_DBG_RL(&error_rl, "%s: failed to query port %s: %s",
-                    dpif_name(dpif), devname, strerror(error));
+        /* For ENOENT or ENODEV we use DBG level because the caller is probably
+         * interested in whether 'dpif' actually has a port 'devname', so that
+         * it's not an issue worth logging if it doesn't.  Other errors are
+         * uncommon and more likely to indicate a real problem. */
+        VLOG_RL(&error_rl,
+                error == ENOENT || error == ENODEV ? VLL_DBG : VLL_WARN,
+                "%s: failed to query port %s: %s",
+                dpif_name(dpif), devname, strerror(error));
     }
     return error;
 }
-- 
1.7.4.4




More information about the dev mailing list