From a3f77b259cea16f32d6428cbba03f0409b1dd96e Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sun, 14 Jan 2018 14:08:38 +0100 Subject: [PATCH] wifi: always build nl80211 CRIT_PROTOCOL support netlink's API is stable, and strictly defined by the integer values that make up commands and attributes. There is little reason do disable a netlink feature based on compile time detection of the kernel headers. Either kernel supports it, or it will fail with an appropriate response. Also, support for NL80211_CMD_CRIT_PROTOCOL_START was merge to kernel in 2013. Maybe, we should now just always assume support (in the kernel headers is there). Anyway, don't do that yet, but instead avoid the defines and use the numeric values directly. --- config.h.meson | 3 --- configure.ac | 24 ------------------------ meson.build | 16 ---------------- src/platform/nm-fake-platform.c | 1 - src/platform/wifi/wifi-utils-nl80211.c | 17 +++++++++-------- 5 files changed, 9 insertions(+), 52 deletions(-) diff --git a/config.h.meson b/config.h.meson index 704c0a48d..e07e128a6 100644 --- a/config.h.meson +++ b/config.h.meson @@ -38,9 +38,6 @@ /* Define to 1 if libsystemd is available */ #mesondefine HAVE_LIBSYSTEMD -/* Define if nl80211 has critical protocol support */ -#mesondefine HAVE_NL80211_CRITICAL_PROTOCOL_CMDS - /* Define to 1 if you have the `secure_getenv' function. */ #mesondefine HAVE_SECURE_GETENV diff --git a/configure.ac b/configure.ac index 8afebe4cc..92e158830 100644 --- a/configure.ac +++ b/configure.ac @@ -242,30 +242,6 @@ if test "$ac_have_nl80211" = no; then AC_MSG_ERROR(Linux kernel development header linux/nl80211.h not installed or not functional) fi -if test "$with_wifi" = "yes"; then - AC_MSG_CHECKING([Linux kernel nl80211 Critical Protocol Start/Stop]) - AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM( - [[#ifndef __user - #define __user - #endif - #include - #include - #include - #include ]], - [[unsigned a = NL80211_CMD_CRIT_PROTOCOL_START; a++;]])], - [ac_have_nl80211_critproto=yes], - [ac_have_nl80211_critproto=no]) - AC_MSG_RESULT($ac_have_nl80211_critproto) -else - ac_have_nl80211_critproto='no' -fi -if test "$ac_have_nl80211_critproto" = yes; then - AC_DEFINE(HAVE_NL80211_CRITICAL_PROTOCOL_CMDS, 1, [Define if nl80211 has critical protocol support]) -else - AC_DEFINE(HAVE_NL80211_CRITICAL_PROTOCOL_CMDS, 0, [Define if nl80211 has critical protocol support]) -fi - dnl dnl Default to using wpa_supplicant but allow IWD as wifi backend dnl diff --git a/meson.build b/meson.build index 8418cb105..b3bb97189 100644 --- a/meson.build +++ b/meson.build @@ -285,22 +285,6 @@ if enable_wifi ''' assert(cc.compiles(nl80211_src), 'Linux kernel development header linux/nl80211.h not installed or not functional') - - nl80211_crit_proto_src = ''' - #ifndef __user - #define __user - #endif - #include - #include - #include - #include - int main() { - unsigned a = NL80211_CMD_CRIT_PROTOCOL_START; - a++; - } - ''' - - config_h.set10('HAVE_NL80211_CRITICAL_PROTOCOL_CMDS', cc.compiles(nl80211_crit_proto_src)) endif config_h.set10('WITH_WIFI', enable_wifi) diff --git a/src/platform/nm-fake-platform.c b/src/platform/nm-fake-platform.c index be4301528..06dd7e139 100644 --- a/src/platform/nm-fake-platform.c +++ b/src/platform/nm-fake-platform.c @@ -938,7 +938,6 @@ wifi_find_frequency (NMPlatform *platform, int ifindex, const guint32 *freqs) static void wifi_indicate_addressing_running (NMPlatform *platform, int ifindex, gboolean running) { - ; } static guint32 diff --git a/src/platform/wifi/wifi-utils-nl80211.c b/src/platform/wifi/wifi-utils-nl80211.c index 5b84cfa89..35bd41511 100644 --- a/src/platform/wifi/wifi-utils-nl80211.c +++ b/src/platform/wifi/wifi-utils-nl80211.c @@ -792,7 +792,6 @@ wifi_nl80211_get_qual (WifiData *data) return sta_info.signal; } -#if HAVE_NL80211_CRITICAL_PROTOCOL_CMDS static gboolean wifi_nl80211_indicate_addressing_running (WifiData *data, gboolean running) { @@ -801,16 +800,21 @@ wifi_nl80211_indicate_addressing_running (WifiData *data, gboolean running) int err; msg = nl80211_alloc_msg (nl80211, - running ? NL80211_CMD_CRIT_PROTOCOL_START : - NL80211_CMD_CRIT_PROTOCOL_STOP, + running + ? 98 /* NL80211_CMD_CRIT_PROTOCOL_START */ + : 99 /* NL80211_CMD_CRIT_PROTOCOL_STOP */, 0); /* Despite the DHCP name, we're using this for any type of IP addressing, * DHCPv4, DHCPv6, and IPv6 SLAAC. */ - NLA_PUT_U16 (msg, NL80211_ATTR_CRIT_PROT_ID, NL80211_CRIT_PROTO_DHCP); + NLA_PUT_U16 (msg, + 179 /* NL80211_ATTR_CRIT_PROT_ID */, + 1 /* NL80211_CRIT_PROTO_DHCP */); if (running) { /* Give DHCP 5 seconds to complete */ - NLA_PUT_U16 (msg, NL80211_ATTR_MAX_CRIT_PROT_DURATION, 5000); + NLA_PUT_U16 (msg, + 180 /* NL80211_ATTR_MAX_CRIT_PROT_DURATION */, + 5000); } err = nl80211_send_and_recv (nl80211, msg, NULL, NULL); @@ -820,7 +824,6 @@ nla_put_failure: nlmsg_free (msg); return FALSE; } -#endif struct nl80211_wowlan_info { gboolean enabled; @@ -1077,9 +1080,7 @@ wifi_nl80211_init (int ifindex) .get_rate = wifi_nl80211_get_rate, .get_qual = wifi_nl80211_get_qual, .get_wowlan = wifi_nl80211_get_wowlan, -#if HAVE_NL80211_CRITICAL_PROTOCOL_CMDS .indicate_addressing_running = wifi_nl80211_indicate_addressing_running, -#endif .deinit = wifi_nl80211_deinit, }; WifiDataNl80211 *nl80211;