Replace most uses of assert by ovs_assert.
[sliver-openvswitch.git] / lib / netdev-bsd.c
index 256955d..f46eee8 100644 (file)
@@ -17,7 +17,6 @@
 #include <config.h>
 
 #include <stdlib.h>
-#include <assert.h>
 #include <errno.h>
 #include <fcntl.h>
 #include <sys/types.h>
@@ -50,6 +49,7 @@
 #include "socket-util.h"
 #include "shash.h"
 #include "svec.h"
+#include "util.h"
 #include "vlog.h"
 
 VLOG_DEFINE_THIS_MODULE(netdev_bsd);
@@ -157,14 +157,15 @@ is_netdev_bsd_class(const struct netdev_class *netdev_class)
 static struct netdev_bsd *
 netdev_bsd_cast(const struct netdev *netdev)
 {
-    assert(is_netdev_bsd_class(netdev_dev_get_class(netdev_get_dev(netdev))));
+    ovs_assert(is_netdev_bsd_class(netdev_dev_get_class(
+                                       netdev_get_dev(netdev))));
     return CONTAINER_OF(netdev, struct netdev_bsd, netdev);
 }
 
 static struct netdev_dev_bsd *
 netdev_dev_bsd_cast(const struct netdev_dev *netdev_dev)
 {
-    assert(is_netdev_bsd_class(netdev_dev_get_class(netdev_dev)));
+    ovs_assert(is_netdev_bsd_class(netdev_dev_get_class(netdev_dev)));
     return CONTAINER_OF(netdev_dev, struct netdev_dev_bsd, netdev_dev);
 }
 
@@ -398,7 +399,6 @@ netdev_bsd_destroy(struct netdev_dev *netdev_dev_)
 static int
 netdev_bsd_open_system(struct netdev_dev *netdev_dev_, struct netdev **netdevp)
 {
-    struct netdev_dev_bsd *netdev_dev = netdev_dev_bsd_cast(netdev_dev_);
     struct netdev_bsd *netdev;
     int error;
     enum netdev_flags flags;
@@ -414,15 +414,6 @@ netdev_bsd_open_system(struct netdev_dev *netdev_dev_, struct netdev **netdevp)
         goto error;
     }
 
-    /* The first user that opens a tap port(from dpif_create_and_open()) will
-     * receive the file descriptor associated with the tap device. Instead, the
-     * following users will open the tap device as a normal 'system' device. */
-    if (!strcmp(netdev_dev_get_type(netdev_dev_), "tap") &&
-            !netdev_dev->tap_opened) {
-        netdev_dev->tap_opened = true;
-        netdev->netdev_fd = netdev_dev->tap_fd;
-    }
-
     *netdevp = &netdev->netdev;
     return 0;
 
@@ -450,6 +441,9 @@ static int
 netdev_bsd_listen(struct netdev *netdev_)
 {
     struct netdev_bsd *netdev = netdev_bsd_cast(netdev_);
+    struct netdev_dev_bsd *netdev_dev =
+                              netdev_dev_bsd_cast(netdev_get_dev(netdev_));
+
     char errbuf[PCAP_ERRBUF_SIZE];
     int error;
     int fd = -1;
@@ -459,6 +453,13 @@ netdev_bsd_listen(struct netdev *netdev_)
         return 0;
     }
 
+    if (!strcmp(netdev_get_type(netdev_), "tap") &&
+            !netdev_dev->tap_opened) {
+        netdev->netdev_fd = netdev_dev->tap_fd;
+        netdev_dev->tap_opened = true;
+        return 0;
+    }
+
     /* open the pcap device. The device is opened in non-promiscuous mode
      * because the interface flags are manually set by the caller. */
     errbuf[0] = '\0';
@@ -1255,6 +1256,7 @@ const struct netdev_class netdev_bsd_class = {
     netdev_bsd_destroy,
     NULL, /* get_config */
     NULL, /* set_config */
+    NULL, /* get_tunnel_config */
     netdev_bsd_open_system,
     netdev_bsd_close,
 
@@ -1297,7 +1299,7 @@ const struct netdev_class netdev_bsd_class = {
     netdev_bsd_get_in6,
     NULL, /* add_router */
     NULL, /* get_next_hop */
-    NULL, /* get_drv_info */
+    NULL, /* get_status */
     NULL, /* arp_lookup */
 
     netdev_bsd_update_flags,
@@ -1315,6 +1317,7 @@ const struct netdev_class netdev_tap_class = {
     netdev_bsd_destroy,
     NULL, /* get_config */
     NULL, /* set_config */
+    NULL, /* get_tunnel_config */
     netdev_bsd_open_system,
     netdev_bsd_close,
 
@@ -1357,7 +1360,7 @@ const struct netdev_class netdev_tap_class = {
     netdev_bsd_get_in6,
     NULL, /* add_router */
     NULL, /* get_next_hop */
-    NULL, /* get_drv_info */
+    NULL, /* get_status */
     NULL, /* arp_lookup */
 
     netdev_bsd_update_flags,