[ovs-dev] [Single DP 14/15] dpif: Add new dpif_port_exists() function.

Justin Pettit jpettit at nicira.com
Wed Oct 31 00:58:02 UTC 2012


On Oct 22, 2012, at 4:35 PM, Ben Pfaff <blp at nicira.com> wrote:

> On Thu, Oct 18, 2012 at 12:51:59PM -0700, Justin Pettit wrote:
>> Provide the ability to determine whether a port exists in a datapath
>> without having to deal with a "dpif_port" structure as with
>> dpif_port_query_by_name().  A future patch will use this function.
>> 
>> Signed-off-by: Justin Pettit <jpettit at nicira.com>
> 
> Seems reasonable.
> 
> Possibly, dpif_port_exists() should log if ->port_query_by_name()
> returns a value other than 0 or ENODEV.


Okay.  I added the following incremental:

-=-=-=-=-=-=-=-=-=-=-
--- a/lib/dpif.c
+++ b/lib/dpif.c
@@ -491,7 +491,13 @@ dpif_port_destroy(struct dpif_port *dpif_port)
 bool
 dpif_port_exists(const struct dpif *dpif, const char *devname)
 {
-    return !dpif->dpif_class->port_query_by_name(dpif, devname, NULL);
+    int error = dpif->dpif_class->port_query_by_name(dpif, devname, NULL);
+    if (error != 0 && error != ENODEV) {
+        VLOG_WARN_RL(&error_rl, "%s: failed to query port %s: %s",
+                     dpif_name(dpif), devname, strerror(error));
+    }
+
+    return !error;
 }
 
 /* Looks up port number 'port_no' in 'dpif'.  On success, returns 0 and
-=-=-=-=-=-=-=-=-=-=-

Thanks,

--Justin





More information about the dev mailing list