There's no particular reason that netdev_dummy_register() has to care about
the particular OS, except that the tests like to use the special Linux-only
tunnel vport types.  But that can be done better, I think, by just always
registering them from netdev_dummy_register() and making that function
idempotent, so that calling it twice under Linux has no additional effect.
This commit implements that solution.

CC: Ed Maste <ema...@freebsd.org>
Signed-off-by: Ben Pfaff <b...@nicira.com>
---
 lib/netdev-dummy.c |   10 +---------
 lib/netdev-vport.c |    8 ++++++--
 2 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/lib/netdev-dummy.c b/lib/netdev-dummy.c
index 908fef2..14b286b 100644
--- a/lib/netdev-dummy.c
+++ b/lib/netdev-dummy.c
@@ -36,12 +36,6 @@
 
 VLOG_DEFINE_THIS_MODULE(netdev_dummy);
 
-#ifdef __FreeBSD__
-#define FREE_BSD 1
-#else
-#define FREE_BSD 0
-#endif
-
 struct netdev_dummy {
     struct netdev up;
     uint8_t hwaddr[ETH_ADDR_LEN];
@@ -553,7 +547,5 @@ netdev_dummy_register(bool override)
     }
     netdev_register_provider(&dummy_class);
 
-    if (FREE_BSD) {
-        netdev_vport_tunnel_register();
-    }
+    netdev_vport_tunnel_register();
 }
diff --git a/lib/netdev-vport.c b/lib/netdev-vport.c
index 38fc996..6eee8a7 100644
--- a/lib/netdev-vport.c
+++ b/lib/netdev-vport.c
@@ -685,11 +685,15 @@ netdev_vport_tunnel_register(void)
         TUNNEL_CLASS("vxlan", "vxlan_system"),
         TUNNEL_CLASS("lisp", "lisp_system")
     };
+    static bool inited;
 
     int i;
 
-    for (i = 0; i < ARRAY_SIZE(vport_classes); i++) {
-        netdev_register_provider(&vport_classes[i].netdev_class);
+    if (!inited) {
+        inited = true;
+        for (i = 0; i < ARRAY_SIZE(vport_classes); i++) {
+            netdev_register_provider(&vport_classes[i].netdev_class);
+        }
     }
 }
 
-- 
1.7.2.5

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to