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.
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ed Maste <emaste@freebsd.org>
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];
}
netdev_register_provider(&dummy_class);
- if (FREE_BSD) {
- netdev_vport_tunnel_register();
- }
+ netdev_vport_tunnel_register();
}
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);
+ }
}
}