dpif-linux: Fix build with certain 64-bit kernel/userspace combinations.
[openvswitch] / lib / netdev-linux.c
index ee3c5f52a5cc931e59caf8444586728768606b4c..c49df8a3456f97be11f6f17b8e6b398d9ddf250e 100644 (file)
@@ -24,6 +24,7 @@
 #include <arpa/inet.h>
 #include <inttypes.h>
 #include <linux/gen_stats.h>
+#include <linux/if_ether.h>
 #include <linux/if_tun.h>
 #include <linux/ip.h>
 #include <linux/types.h>
@@ -37,9 +38,7 @@
 #include <sys/ioctl.h>
 #include <sys/socket.h>
 #include <netpacket/packet.h>
-#include <net/ethernet.h>
 #include <net/if.h>
-#include <linux/if_tunnel.h>
 #include <net/if_arp.h>
 #include <net/if_packet.h>
 #include <net/route.h>
@@ -105,7 +104,7 @@ COVERAGE_DEFINE(netdev_ethtool);
 #define TC_RTAB_SIZE 1024
 #endif
 
-static struct nln_notifier netdev_linux_cache_notifier;
+static struct nln_notifier *netdev_linux_cache_notifier = NULL;
 static int cache_notifier_refcount;
 
 enum {
@@ -469,14 +468,14 @@ netdev_linux_init(void)
 static void
 netdev_linux_run(void)
 {
-    rtnetlink_link_notifier_run();
+    rtnetlink_link_run();
     netdev_linux_miimon_run();
 }
 
 static void
 netdev_linux_wait(void)
 {
-    rtnetlink_link_notifier_wait();
+    rtnetlink_link_wait();
     netdev_linux_miimon_wait();
 }
 
@@ -526,13 +525,15 @@ netdev_linux_create(const struct netdev_class *class, const char *name,
                     struct netdev_dev **netdev_devp)
 {
     struct netdev_dev_linux *netdev_dev;
-    int error;
 
     if (!cache_notifier_refcount) {
-        error = rtnetlink_link_notifier_register(&netdev_linux_cache_notifier,
-                                                 netdev_linux_cache_cb, NULL);
-        if (error) {
-            return error;
+        assert(!netdev_linux_cache_notifier);
+
+        netdev_linux_cache_notifier =
+            rtnetlink_link_notifier_create(netdev_linux_cache_cb, NULL);
+
+        if (!netdev_linux_cache_notifier) {
+            return EINVAL;
         }
     }
     cache_notifier_refcount++;
@@ -622,7 +623,9 @@ netdev_linux_destroy(struct netdev_dev *netdev_dev_)
         cache_notifier_refcount--;
 
         if (!cache_notifier_refcount) {
-            rtnetlink_link_notifier_unregister(&netdev_linux_cache_notifier);
+            assert(netdev_linux_cache_notifier);
+            rtnetlink_link_notifier_destroy(netdev_linux_cache_notifier);
+            netdev_linux_cache_notifier = NULL;
         }
     } else if (class == &netdev_tap_class) {
         destroy_tap(netdev_dev);
@@ -692,28 +695,6 @@ netdev_linux_close(struct netdev *netdev_)
     free(netdev);
 }
 
-/* Initializes 'sset' with a list of the names of all known network devices. */
-static int
-netdev_linux_enumerate(struct sset *sset)
-{
-    struct if_nameindex *names;
-
-    names = if_nameindex();
-    if (names) {
-        size_t i;
-
-        for (i = 0; names[i].if_name != NULL; i++) {
-            sset_add(sset, names[i].if_name);
-        }
-        if_freenameindex(names);
-        return 0;
-    } else {
-        VLOG_WARN("could not obtain list of network device names: %s",
-                  strerror(errno));
-        return errno;
-    }
-}
-
 static int
 netdev_linux_listen(struct netdev *netdev_)
 {
@@ -2338,7 +2319,7 @@ netdev_linux_change_seq(const struct netdev *netdev)
     return netdev_dev_linux_cast(netdev_get_dev(netdev))->change_seq;
 }
 
-#define NETDEV_LINUX_CLASS(NAME, CREATE, ENUMERATE, GET_STATS, SET_STATS)  \
+#define NETDEV_LINUX_CLASS(NAME, CREATE, GET_STATS, SET_STATS)  \
 {                                                               \
     NAME,                                                       \
                                                                 \
@@ -2354,8 +2335,6 @@ netdev_linux_change_seq(const struct netdev *netdev)
     netdev_linux_open,                                          \
     netdev_linux_close,                                         \
                                                                 \
-    ENUMERATE,                                                  \
-                                                                \
     netdev_linux_listen,                                        \
     netdev_linux_recv,                                          \
     netdev_linux_recv_wait,                                     \
@@ -2407,7 +2386,6 @@ const struct netdev_class netdev_linux_class =
     NETDEV_LINUX_CLASS(
         "system",
         netdev_linux_create,
-        netdev_linux_enumerate,
         netdev_linux_get_stats,
         NULL);                  /* set_stats */
 
@@ -2415,7 +2393,6 @@ const struct netdev_class netdev_tap_class =
     NETDEV_LINUX_CLASS(
         "tap",
         netdev_linux_create_tap,
-        NULL,                   /* enumerate */
         netdev_pseudo_get_stats,
         NULL);                  /* set_stats */
 
@@ -2423,7 +2400,6 @@ const struct netdev_class netdev_internal_class =
     NETDEV_LINUX_CLASS(
         "internal",
         netdev_linux_create,
-        NULL,                    /* enumerate */
         netdev_pseudo_get_stats,
         netdev_vport_set_stats);
 \f