X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=lib%2Fdpif.c;h=9feb67ba92ec8f01612f07aac535fe6461e57336;hb=07c8ec217b5641b74f20b216ad63fef230649f2c;hp=952a502d60f26cadaacf4d688084d6701fbeb967;hpb=4afba28d559511a5ee03e005b65be8323bf26ad3;p=sliver-openvswitch.git diff --git a/lib/dpif.c b/lib/dpif.c index 952a502d6..9feb67ba9 100644 --- a/lib/dpif.c +++ b/lib/dpif.c @@ -372,6 +372,13 @@ dpif_base_name(const struct dpif *dpif) return dpif->base_name; } +/* Returns the type of datapath 'dpif'. */ +const char * +dpif_type(const struct dpif *dpif) +{ + return dpif->dpif_class->type; +} + /* Returns the fully spelled out name for the given datapath 'type'. * * Normalized type string can be compared with strcmp(). Unnormalized type @@ -410,6 +417,23 @@ dpif_get_dp_stats(const struct dpif *dpif, struct dpif_dp_stats *stats) return error; } +const char * +dpif_port_open_type(const char *datapath_type, const char *port_type) +{ + struct registered_dpif_class *registered_class; + + datapath_type = dpif_normalize_type(datapath_type); + + registered_class = shash_find_data(&dpif_classes, datapath_type); + if (!registered_class + || !registered_class->dpif_class->port_open_type) { + return port_type; + } + + return registered_class->dpif_class->port_open_type( + registered_class->dpif_class, port_type); +} + /* Attempts to add 'netdev' as a port on 'dpif'. If 'port_nop' is * non-null and its value is not UINT32_MAX, then attempts to use the * value as the port number. @@ -492,7 +516,7 @@ bool dpif_port_exists(const struct dpif *dpif, const char *devname) { int error = dpif->dpif_class->port_query_by_name(dpif, devname, NULL); - if (error != 0 && error != ENODEV) { + if (error != 0 && error != ENOENT && error != ENODEV) { VLOG_WARN_RL(&error_rl, "%s: failed to query port %s: %s", dpif_name(dpif), devname, strerror(error)); }