diff mbox

[ovs-dev,4/5] dpif-netdev: use the open_type when creating the local port

Message ID 1469632005-16490-5-git-send-email-cascardo@redhat.com
State Accepted
Delegated to: Daniele Di Proietto
Headers show

Commit Message

Thadeu Lima de Souza Cascardo July 27, 2016, 3:06 p.m. UTC
Instead of using the internal type, use the port_open_type when creating the
local port. That makes sure that whenever dpif_port_query is used, the netdev
open_type is returned instead of the "internal" type.

For other ports, that is already the case, as the netdev type is used when
creating the dp_netdev_port.

That changes the output of dpctl when showing the local port, and also when
trying to change its type. So, corresponding tests are fixed.

Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@redhat.com>
Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com>
---
 lib/dpif-netdev.c | 11 ++++++-----
 tests/dpctl.at    | 13 +++++++------
 2 files changed, 13 insertions(+), 11 deletions(-)
diff mbox

Patch

diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index f05ca4e..1fea0d7 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -941,7 +941,9 @@  create_dp_netdev(const char *name, const struct dpif_class *class,
     ovs_mutex_lock(&dp->port_mutex);
     dp_netdev_set_nonpmd(dp);
 
-    error = do_add_port(dp, name, "internal", ODPP_LOCAL);
+    error = do_add_port(dp, name, dpif_netdev_port_open_type(dp->class,
+                                                             "internal"),
+                        ODPP_LOCAL);
     ovs_mutex_unlock(&dp->port_mutex);
     if (error) {
         dp_netdev_free(dp);
@@ -1129,7 +1131,7 @@  hash_port_no(odp_port_t port_no)
 }
 
 static int
-port_create(const char *devname, const char *open_type, const char *type,
+port_create(const char *devname, const char *type,
             odp_port_t port_no, struct dp_netdev_port **portp)
 {
     struct netdev_saved_flags *sf;
@@ -1142,7 +1144,7 @@  port_create(const char *devname, const char *open_type, const char *type,
     *portp = NULL;
 
     /* Open and validate network device. */
-    error = netdev_open(devname, open_type, &netdev);
+    error = netdev_open(devname, type, &netdev);
     if (error) {
         return error;
     }
@@ -1233,8 +1235,7 @@  do_add_port(struct dp_netdev *dp, const char *devname, const char *type,
         return EEXIST;
     }
 
-    error = port_create(devname, dpif_netdev_port_open_type(dp->class, type),
-                        type, port_no, &port);
+    error = port_create(devname, type, port_no, &port);
     if (error) {
         return error;
     }
diff --git a/tests/dpctl.at b/tests/dpctl.at
index 067f2d2..b6d5dd6 100644
--- a/tests/dpctl.at
+++ b/tests/dpctl.at
@@ -23,14 +23,14 @@  AT_CHECK([ovs-appctl dpctl/show dummy@br0], [0], [dnl
 dummy@br0:
 	lookups: hit:0 missed:0 lost:0
 	flows: 0
-	port 0: br0 (internal)
+	port 0: br0 (dummy)
 ])
 AT_CHECK([ovs-appctl dpctl/add-if dummy@br0 vif1.0,type=dummy,port_no=5])
 AT_CHECK([ovs-appctl dpctl/show dummy@br0], [0], [dnl
 dummy@br0:
 	lookups: hit:0 missed:0 lost:0
 	flows: 0
-	port 0: br0 (internal)
+	port 0: br0 (dummy)
 	port 5: vif1.0 (dummy)
 ])
 AT_CHECK([ovs-appctl dpctl/add-if dummy@br0 vif1.0,type=dummy], [2], [],
@@ -44,8 +44,9 @@  AT_CHECK([ovs-appctl dpctl/set-if dummy@br0 vif1.0,type=system], [2], [],
   [ovs-vswitchd: vif1.0: can't change type from dummy to system
 ovs-appctl: ovs-vswitchd: server returned an error
 ])
-AT_CHECK([ovs-appctl dpctl/set-if dummy@br0 br0,type=dummy], [2], [],
-  [ovs-vswitchd: br0: can't change type from internal to dummy
+AT_CHECK([ovs-appctl dpctl/set-if dummy@br0 br0,type=dummy], [0])
+AT_CHECK([ovs-appctl dpctl/set-if dummy@br0 br0,type=internal], [2], [],
+  [ovs-vswitchd: br0: can't change type from dummy to internal
 ovs-appctl: ovs-vswitchd: server returned an error
 ])
 AT_CHECK([ovs-appctl dpctl/del-if dummy@br0 vif1.0])
@@ -53,7 +54,7 @@  AT_CHECK([ovs-appctl dpctl/show dummy@br0], [0], [dnl
 dummy@br0:
 	lookups: hit:0 missed:0 lost:0
 	flows: 0
-	port 0: br0 (internal)
+	port 0: br0 (dummy)
 ])
 AT_CHECK([ovs-appctl dpctl/del-if dummy@br0 vif1.0], [2], [],
   [ovs-vswitchd: no port named vif1.0
@@ -63,7 +64,7 @@  AT_CHECK([ovs-appctl dpctl/show dummy@br0], [0], [dnl
 dummy@br0:
 	lookups: hit:0 missed:0 lost:0
 	flows: 0
-	port 0: br0 (internal)
+	port 0: br0 (dummy)
 ])
 AT_CHECK([ovs-appctl dpctl/del-if dummy@br0 nonexistent], [2], [],
   [ovs-vswitchd: no port named nonexistent