]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Drop support for libnl 1.1
authorJouni Malinen <j@w1.fi>
Thu, 2 Jan 2020 15:27:02 +0000 (17:27 +0200)
committerJouni Malinen <j@w1.fi>
Thu, 2 Jan 2020 16:05:38 +0000 (18:05 +0200)
This simplifies code by not having to maintain and come up with new
backwards compatibility wrappers for a library release from 12 years
ago.

Signed-off-by: Jouni Malinen <j@w1.fi>
src/drivers/driver_macsec_linux.c
src/drivers/driver_nl80211.c
src/drivers/driver_nl80211.h
src/drivers/driver_nl80211_android.c
src/drivers/drivers.mak
src/drivers/drivers.mk

index e922503fccd048344ce597e8e12bef7ef1366cad..9c2aa3c702cd8e9bec63f369b84b8922b656a9e0 100644 (file)
@@ -54,8 +54,6 @@ struct macsec_drv_data {
        struct nl_sock *sk;
        struct macsec_genl_ctx ctx;
 
-       struct netlink_data *netlink;
-       struct nl_handle *nl;
        char ifname[IFNAMSIZ + 1];
        int ifi;
        int parent_ifi;
index 9b3f6047108e4cdaee8a2cf18db79dbbf5723487..793eaae7ceee60c56b704a94858a24d00aa87ca5 100644 (file)
@@ -66,48 +66,6 @@ enum nlmsgerr_attrs {
 #define SOL_NETLINK 270
 #endif
 
-#ifndef CONFIG_LIBNL20
-/*
- * libnl 1.1 has a bug, it tries to allocate socket numbers densely
- * but when you free a socket again it will mess up its bitmap and
- * and use the wrong number the next time it needs a socket ID.
- * Therefore, we wrap the handle alloc/destroy and add our own pid
- * accounting.
- */
-static uint32_t port_bitmap[32] = { 0 };
-
-static struct nl_handle *nl80211_handle_alloc(void *cb)
-{
-       struct nl_handle *handle;
-       uint32_t pid = getpid() & 0x3FFFFF;
-       int i;
-
-       handle = nl_handle_alloc_cb(cb);
-
-       for (i = 0; i < 1024; i++) {
-               if (port_bitmap[i / 32] & (1 << (i % 32)))
-                       continue;
-               port_bitmap[i / 32] |= 1 << (i % 32);
-               pid += i << 22;
-               break;
-       }
-
-       nl_socket_set_local_port(handle, pid);
-
-       return handle;
-}
-
-static void nl80211_handle_destroy(struct nl_handle *handle)
-{
-       uint32_t port = nl_socket_get_local_port(handle);
-
-       port >>= 22;
-       port_bitmap[port / 32] &= ~(1 << (port % 32));
-
-       nl_handle_destroy(handle);
-}
-#endif /* CONFIG_LIBNL20 */
-
 
 #ifdef ANDROID
 /* system/core/libnl_2 does not include nl_socket_set_nonblocking() */
@@ -117,11 +75,11 @@ static void nl80211_handle_destroy(struct nl_handle *handle)
 #endif /* ANDROID */
 
 
-static struct nl_handle * nl_create_handle(struct nl_cb *cb, const char *dbg)
+static struct nl_sock * nl_create_handle(struct nl_cb *cb, const char *dbg)
 {
-       struct nl_handle *handle;
+       struct nl_sock *handle;
 
-       handle = nl80211_handle_alloc(cb);
+       handle = nl_socket_alloc_cb(cb);
        if (handle == NULL) {
                wpa_printf(MSG_ERROR, "nl80211: Failed to allocate netlink "
                           "callbacks (%s)", dbg);
@@ -131,7 +89,7 @@ static struct nl_handle * nl_create_handle(struct nl_cb *cb, const char *dbg)
        if (genl_connect(handle)) {
                wpa_printf(MSG_ERROR, "nl80211: Failed to connect to generic "
                           "netlink (%s)", dbg);
-               nl80211_handle_destroy(handle);
+               nl_socket_free(handle);
                return NULL;
        }
 
@@ -139,11 +97,11 @@ static struct nl_handle * nl_create_handle(struct nl_cb *cb, const char *dbg)
 }
 
 
-static void nl_destroy_handles(struct nl_handle **handle)
+static void nl_destroy_handles(struct nl_sock **handle)
 {
        if (*handle == NULL)
                return;
-       nl80211_handle_destroy(*handle);
+       nl_socket_free(*handle);
        *handle = NULL;
 }
 
@@ -154,11 +112,10 @@ static void nl_destroy_handles(struct nl_handle **handle)
 #define ELOOP_SOCKET_INVALID   (intptr_t) 0x88888889ULL
 #endif
 
-static void nl80211_register_eloop_read(struct nl_handle **handle,
+static void nl80211_register_eloop_read(struct nl_sock **handle,
                                        eloop_sock_handler handler,
                                        void *eloop_data, int persist)
 {
-#ifdef CONFIG_LIBNL20
        /*
         * libnl uses a pretty small buffer (32 kB that gets converted to 64 kB)
         * by default. It is possible to hit that limit in some cases where
@@ -172,7 +129,6 @@ static void nl80211_register_eloop_read(struct nl_handle **handle,
                           strerror(errno));
                /* continue anyway with the default (smaller) buffer */
        }
-#endif /* CONFIG_LIBNL20 */
 
        nl_socket_set_nonblocking(*handle);
        eloop_register_read_sock(nl_socket_get_fd(*handle), handler,
@@ -183,7 +139,7 @@ static void nl80211_register_eloop_read(struct nl_handle **handle,
 }
 
 
-static void nl80211_destroy_eloop_handle(struct nl_handle **handle, int persist)
+static void nl80211_destroy_eloop_handle(struct nl_sock **handle, int persist)
 {
        if (!persist)
                *handle = (void *) (((intptr_t) *handle) ^
@@ -391,7 +347,7 @@ static void nl80211_nlmsg_clear(struct nl_msg *msg)
 
 
 static int send_and_recv(struct nl80211_global *global,
-                        struct nl_handle *nl_handle, struct nl_msg *msg,
+                        struct nl_sock *nl_handle, struct nl_msg *msg,
                         int (*valid_handler)(struct nl_msg *, void *),
                         void *valid_data)
 {
@@ -1789,7 +1745,7 @@ err:
 
 static void nl80211_check_global(struct nl80211_global *global)
 {
-       struct nl_handle *handle;
+       struct nl_sock *handle;
        const char *groups[] = { "scan", "mlme", "regulatory", "vendor", NULL };
        int ret;
        unsigned int i;
@@ -2087,7 +2043,7 @@ static void * wpa_driver_nl80211_init(void *ctx, const char *ifname,
 
 
 static int nl80211_register_frame(struct i802_bss *bss,
-                                 struct nl_handle *nl_handle,
+                                 struct nl_sock *nl_handle,
                                  u16 type, const u8 *match, size_t match_len)
 {
        struct wpa_driver_nl80211_data *drv = bss->drv;
@@ -2757,7 +2713,7 @@ static void wpa_driver_nl80211_deinit(struct i802_bss *bss)
        }
 
        if (drv->rtnl_sk)
-               nl80211_handle_destroy(drv->rtnl_sk);
+               nl_socket_free(drv->rtnl_sk);
 
        if (bss->added_bridge) {
                if (linux_set_iface_flags(drv->global->ioctl_sock, bss->brname,
@@ -3271,7 +3227,7 @@ static int nl80211_set_conn_keys(struct wpa_driver_associate_params *params,
 int wpa_driver_nl80211_mlme(struct wpa_driver_nl80211_data *drv,
                            const u8 *addr, int cmd, u16 reason_code,
                            int local_state_change,
-                           struct nl_handle *nl_connect)
+                           struct nl_sock *nl_connect)
 {
        int ret;
        struct nl_msg *msg;
@@ -3300,7 +3256,7 @@ int wpa_driver_nl80211_mlme(struct wpa_driver_nl80211_data *drv,
 
 static int wpa_driver_nl80211_disconnect(struct wpa_driver_nl80211_data *drv,
                                         u16 reason_code,
-                                        struct nl_handle *nl_connect)
+                                        struct nl_sock *nl_connect)
 {
        int ret;
        int drv_associated = drv->associated;
@@ -3332,7 +3288,7 @@ static int wpa_driver_nl80211_deauthenticate(struct i802_bss *bss,
                return nl80211_leave_ibss(drv, 1);
        }
        if (!(drv->capa.flags & WPA_DRIVER_FLAGS_SME)) {
-               struct nl_handle *nl_connect = NULL;
+               struct nl_sock *nl_connect = NULL;
 
                if (bss->use_nl_connect)
                        nl_connect = bss->nl_connect;
@@ -5775,7 +5731,7 @@ static int nl80211_connect_common(struct wpa_driver_nl80211_data *drv,
 static int wpa_driver_nl80211_try_connect(
        struct wpa_driver_nl80211_data *drv,
        struct wpa_driver_associate_params *params,
-       struct nl_handle *nl_connect)
+       struct nl_sock *nl_connect)
 {
        struct nl_msg *msg;
        enum nl80211_auth_type type;
@@ -5866,7 +5822,7 @@ fail:
 static int wpa_driver_nl80211_connect(
        struct wpa_driver_nl80211_data *drv,
        struct wpa_driver_associate_params *params,
-       struct nl_handle *nl_connect)
+       struct nl_sock *nl_connect)
 {
        int ret;
 
@@ -5914,7 +5870,7 @@ static int wpa_driver_nl80211_associate(
        if (!(drv->capa.flags & WPA_DRIVER_FLAGS_SME)) {
                enum nl80211_iftype nlmode = params->p2p ?
                        NL80211_IFTYPE_P2P_CLIENT : NL80211_IFTYPE_STATION;
-               struct nl_handle *nl_connect = NULL;
+               struct nl_sock *nl_connect = NULL;
 
                if (wpa_driver_nl80211_set_mode(priv, nlmode) < 0)
                        return -1;
index 716504c10f940c144f38b5638e2b4fb3914046b5..cbafc1bb053e8f8c12f76c5566717cccf4d68c38 100644 (file)
 #include "utils/list.h"
 #include "driver.h"
 
-#ifdef CONFIG_LIBNL20
-/* libnl 2.0 compatibility code */
-#define nl_handle nl_sock
-#define nl80211_handle_alloc nl_socket_alloc_cb
-#define nl80211_handle_destroy nl_socket_free
-#endif /* CONFIG_LIBNL20 */
-
 struct nl80211_global {
        void *ctx;
        struct dl_list interfaces;
@@ -32,11 +25,11 @@ struct nl80211_global {
        int if_add_wdevid_set;
        struct netlink_data *netlink;
        struct nl_cb *nl_cb;
-       struct nl_handle *nl;
+       struct nl_sock *nl;
        int nl80211_id;
        int ioctl_sock; /* socket for ioctl() use */
 
-       struct nl_handle *nl_event;
+       struct nl_sock *nl_event;
 };
 
 struct nl80211_wiphy_data {
@@ -44,7 +37,7 @@ struct nl80211_wiphy_data {
        struct dl_list bsss;
        struct dl_list drvs;
 
-       struct nl_handle *nl_beacons;
+       struct nl_sock *nl_beacons;
        struct nl_cb *nl_cb;
 
        int wiphy_idx;
@@ -75,7 +68,7 @@ struct i802_bss {
        int if_dynamic;
 
        void *ctx;
-       struct nl_handle *nl_preq, *nl_mgmt, *nl_connect;
+       struct nl_sock *nl_preq, *nl_mgmt, *nl_connect;
        struct nl_cb *nl_cb;
 
        struct nl80211_wiphy_data *wiphy_data;
@@ -192,7 +185,7 @@ struct wpa_driver_nl80211_data {
 
        int eapol_sock; /* socket for EAPOL frames */
 
-       struct nl_handle *rtnl_sk; /* nl_sock for NETLINK_ROUTE */
+       struct nl_sock *rtnl_sk; /* nl_sock for NETLINK_ROUTE */
 
        struct drv_nl80211_if_info default_if_indices[16];
        struct drv_nl80211_if_info *if_indices;
@@ -256,7 +249,7 @@ int wpa_driver_nl80211_set_mode(struct i802_bss *bss,
 int wpa_driver_nl80211_mlme(struct wpa_driver_nl80211_data *drv,
                            const u8 *addr, int cmd, u16 reason_code,
                            int local_state_change,
-                           struct nl_handle *nl_connect);
+                           struct nl_sock *nl_connect);
 
 int nl80211_create_monitor_interface(struct wpa_driver_nl80211_data *drv);
 void nl80211_remove_monitor_interface(struct wpa_driver_nl80211_data *drv);
@@ -275,7 +268,7 @@ int process_bss_event(struct nl_msg *msg, void *arg);
 const char * nl80211_iftype_str(enum nl80211_iftype mode);
 
 #ifdef ANDROID
-int android_nl_socket_set_nonblocking(struct nl_handle *handle);
+int android_nl_socket_set_nonblocking(struct nl_sock *handle);
 int android_pno_start(struct i802_bss *bss,
                      struct wpa_driver_scan_params *params);
 int android_pno_stop(struct i802_bss *bss);
index ba47888843bbb01873c022a8b9fccbef686bf9d9..9431a12d4dc0c34ee08a14ef7cab8d5b95f5577f 100644 (file)
@@ -182,9 +182,7 @@ int wpa_driver_set_ap_wps_p2p_ie(void *priv, const struct wpabuf *beacon,
 #endif /* ANDROID_P2P */
 
 
-int android_nl_socket_set_nonblocking(struct nl_handle *handle)
+int android_nl_socket_set_nonblocking(struct nl_sock *handle)
 {
        return fcntl(nl_socket_get_fd(handle), F_SETFL, O_NONBLOCK);
 }
-
-
index bc2e87e087851b8f16994907b7b2224c31848cf0..55a98ef86d0df4a306cd1075e31b919fd2c9f9d4 100644 (file)
@@ -176,7 +176,6 @@ endif
 ifdef CONFIG_LIBNL32
   DRV_LIBS += -lnl-3
   DRV_LIBS += -lnl-genl-3
-  DRV_CFLAGS += -DCONFIG_LIBNL20
   ifdef LIBNL_INC
     DRV_CFLAGS += -I$(LIBNL_INC)
   else
@@ -193,14 +192,8 @@ else
   else
     ifndef CONFIG_OSX
       DRV_LIBS += -lnl
-    endif
-  endif
-
-  ifdef CONFIG_LIBNL20
-    ifndef CONFIG_LIBNL_TINY
       DRV_LIBS += -lnl-genl
     endif
-    DRV_CFLAGS += -DCONFIG_LIBNL20
   endif
 endif
 endif
index c3c2c0fe19d99eac708149b6c3a54b2391163a89..5a32a24228ced98c114f161518ad0a0ec54411e1 100644 (file)
@@ -160,7 +160,7 @@ ifdef NEED_LIBNL
 ifdef CONFIG_LIBNL32
   DRV_LIBS += -lnl-3
   DRV_LIBS += -lnl-genl-3
-  DRV_CFLAGS += -DCONFIG_LIBNL20 -I/usr/include/libnl3
+  DRV_CFLAGS += -I/usr/include/libnl3
 ifdef CONFIG_LIBNL3_ROUTE
   DRV_LIBS += -lnl-route-3
   DRV_CFLAGS += -DCONFIG_LIBNL3_ROUTE
@@ -170,13 +170,7 @@ else
     DRV_LIBS += -lnl-tiny
   else
     DRV_LIBS += -lnl
-  endif
-
-  ifdef CONFIG_LIBNL20
-    ifndef CONFIG_LIBNL_TINY
-      DRV_LIBS += -lnl-genl
-    endif
-    DRV_CFLAGS += -DCONFIG_LIBNL20
+    DRV_LIBS += -lnl-genl
   endif
 endif
 endif