From patchwork Wed Sep 4 19:11:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 11131263 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5D82615E9 for ; Wed, 4 Sep 2019 19:13:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3EA4921726 for ; Wed, 4 Sep 2019 19:13:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="C7rUjgUr" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732885AbfIDTN4 (ORCPT ); Wed, 4 Sep 2019 15:13:56 -0400 Received: from mail-pg1-f173.google.com ([209.85.215.173]:43451 "EHLO mail-pg1-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732682AbfIDTN4 (ORCPT ); Wed, 4 Sep 2019 15:13:56 -0400 Received: by mail-pg1-f173.google.com with SMTP id u72so7560457pgb.10 for ; Wed, 04 Sep 2019 12:13:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=kF3FzIWsLVS9pUmY8wzedNzcdZsn/YCj7K+cUlJYVus=; b=C7rUjgUrlYDOoA47wlcvCIOTYKdqfyJQGnJ2BbdY+mMO8KyyQLEmrQClpaha/1M1m/ xLlj/Y/0h+EusdCWvFVwN6ipZn1UrTB9KigvE6yxWNZBMVZh0HbuXtiYgLb6nLemJvan ZH4mAIYxo3sFlxBJsdiNcXcmD8oaNK2UEuQtmR5+AooX16v5cL23/w9y/PnrXKeEl5d0 W72aFPmLl8NGSG5m3dhfik3BgFugEvRfQXn3P6OHiIgtwlTP3heZfAVB/7/Py/D6rHqp nmtkxUa7jq9UyNn0ISRb6FO2ftH/B3er/06jLpEVv7wC/TSNCAw9yw8f+0svRONkK2kr KN/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=kF3FzIWsLVS9pUmY8wzedNzcdZsn/YCj7K+cUlJYVus=; b=mBjqru/nu1uIalOAs+Bh3yodCe8bL4SqFvNqUdjIpdJYckN3f5bYPt7aeaVZHdXHb1 X2RB4bocx1n19q4XDx+liXAmLoNQEEt7aWcoq3sbSYKHF4CkKS6nB4v22Mfzhwh6TBSm bLMWbTeWUAyvqmg27ok0B+If0pCkmRUH9XI8QksjBo5MThn8OYZ6QozRVctAoVEWi+YJ 6CfCngbuH4E7LtXtkB59AA7W1aC7NujE2yQR2dXXd27lC8aNuRRDZ4foX5p6Rsp9tMNg nt6cyQT/NpyX4UxcWJ0htQ+glRP5Qz/j2Q5OxbiTtBzZOBdFM9A/xHSYrpQDsKwtznU8 V1HQ== X-Gm-Message-State: APjAAAUF48x3jOv1MmweBYIvxHwyGBcNl5A2XrTwRLDES3Dav2roEx7m azOJJj4H8yGv2EXlBuxMeRUykAHbhYw= X-Google-Smtp-Source: APXvYqwwFx8OGH8FklmqMi892PI3kWfGgcHC76A0j+JiAu28kc5Voxjr3F2le6r98lMTk35rAG9Xmg== X-Received: by 2002:aa7:800c:: with SMTP id j12mr45859606pfi.255.1567624435158; Wed, 04 Sep 2019 12:13:55 -0700 (PDT) Received: from jprestwo-test.jf.intel.com ([134.134.139.76]) by smtp.gmail.com with ESMTPSA id u7sm18849727pgr.94.2019.09.04.12.13.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Sep 2019 12:13:54 -0700 (PDT) From: James Prestwood To: linux-wireless@vger.kernel.org Cc: James Prestwood Subject: [RFC 1/4] nl80211: Add LIVE_ADDR_CHANGE feature Date: Wed, 4 Sep 2019 12:11:52 -0700 Message-Id: <20190904191155.28056-2-prestwoj@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190904191155.28056-1-prestwoj@gmail.com> References: <20190904191155.28056-1-prestwoj@gmail.com> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Add a new feature bit signifying that the wireless hardware supports changing the mac address while the underlying net_device is UP. Note that this is slightly different from IFF_LIVE_ADDR_CHANGE as additional restrictions might be imposed by the hardware. Typical restrictions are: - No connection is active on this interface, e.g. carrier is off - No scan is in progress - No offchannel operation is in progress --- include/uapi/linux/nl80211.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h index bf7c4222f512..0ceb945a08fb 100644 --- a/include/uapi/linux/nl80211.h +++ b/include/uapi/linux/nl80211.h @@ -5481,6 +5481,14 @@ enum nl80211_feature_flags { * @NL80211_EXT_FEATURE_SAE_OFFLOAD: Device wants to do SAE authentication in * station mode (SAE password is passed as part of the connect command). * + * @NL80211_EXT_FEATURE_LIVE_ADDR_CHANGE: Device can perform a MAC address + * change without having to bring the underlying network device down + * first. For example, in station mode this can be used to vary the + * origin MAC address prior to a connection to a new AP for privacy + * or other reasons. Note that certain driver specific restrictions + * might apply, e.g. no scans in progress, no offchannel operations + * in progress, and no active connections. + * * @NUM_NL80211_EXT_FEATURES: number of extended features. * @MAX_NL80211_EXT_FEATURES: highest extended feature index. */ @@ -5526,6 +5534,7 @@ enum nl80211_ext_feature_index { NL80211_EXT_FEATURE_EXT_KEY_ID, NL80211_EXT_FEATURE_STA_TX_PWR, NL80211_EXT_FEATURE_SAE_OFFLOAD, + NL80211_EXT_FEATURE_LIVE_ADDRESS_CHANGE, /* add new features before the definition below */ NUM_NL80211_EXT_FEATURES, From patchwork Wed Sep 4 19:11:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 11131265 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7CA131399 for ; Wed, 4 Sep 2019 19:14:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5E35821726 for ; Wed, 4 Sep 2019 19:14:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="qd8nktnb" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732999AbfIDTN7 (ORCPT ); Wed, 4 Sep 2019 15:13:59 -0400 Received: from mail-pf1-f175.google.com ([209.85.210.175]:34042 "EHLO mail-pf1-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732682AbfIDTN7 (ORCPT ); Wed, 4 Sep 2019 15:13:59 -0400 Received: by mail-pf1-f175.google.com with SMTP id r12so1699445pfh.1 for ; Wed, 04 Sep 2019 12:13:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=r8xWGRQoX1IvCx31D2Ompt6YG2G08KJUqFmqXk84nKM=; b=qd8nktnbaY8doOgOCnD7qX6cJnqEHcO6W9JjS3s0LJbAd84Of8zzp5hv8dN3P95NxE Ix+h+YY/Hiinr83nitFkF1Wk0Y7lPoIAqDgq1DtCkZTcvhwGQJTv1rrYhIDYIlHN7l8V jI2Zk/Lu4xrC4jfT4fp4yntzNud1XiWlhtACQFnMFYLUk5CU1G3c15NM1PGX7o0Gi8HL bWE4+EMBzbCIZtnXRd3k4mEFe6KRXLxbPg+UFqHLboRsCBN6KGEQJsWVNCPGbj+vC22Z Vz2+RvYrwBDMZGstyS9XzQmBQ2tS/vLJLwybhH4SbbQiC6aHoZuj/tPZzOIyT8WRsYvG A52g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=r8xWGRQoX1IvCx31D2Ompt6YG2G08KJUqFmqXk84nKM=; b=UhEo2ATu0/VFSVuXoNnvjXBsy1jXA4dCPcHGOjRLJ8dUG5IESXFH9yjW7B0emUmasP NU9gcl7YzEwKhVcvcfvxmnrfvtXc7FJX0IAE5CxWif5tp+Y3wjeKdGu9WDoyXOYLb3c4 mll6LfflU3OeYAIQ1grJCOsbjIx7+0FGLntMXg2FcpxygI8jSNsR/qeEAOLq2OUq9p8y Px46fzy3rIMltbtmQbTa/1kKUVg/teHCJytxJsmCMtwzPOT+XszrRsubcdDLFda9Yyoz RnfxDBu89fvNhj2Q2DTpF/U6nv/XlxW+pExhhx/Hea2Y3he2kXP6/7msVbwu0L1I+2pr 4UGQ== X-Gm-Message-State: APjAAAUJUWjrTWZgab8klXxio24K3mV417t1nwsQBhNQLHahK8YqNX9C VJQ+BOYgHIW2RuA0XFzubAzV/bZAKbM= X-Google-Smtp-Source: APXvYqzP45pUu3HMoQrH5V9f+pDrQe28A22l32mBz1ea1Xtreo7n60el/u5zgP5z0J6UVTKZzewMCQ== X-Received: by 2002:a62:3046:: with SMTP id w67mr42174598pfw.5.1567624438330; Wed, 04 Sep 2019 12:13:58 -0700 (PDT) Received: from jprestwo-test.jf.intel.com ([134.134.139.76]) by smtp.gmail.com with ESMTPSA id u7sm18849727pgr.94.2019.09.04.12.13.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Sep 2019 12:13:57 -0700 (PDT) From: James Prestwood To: linux-wireless@vger.kernel.org Cc: James Prestwood Subject: [RFC 2/4] {nl|cfg}80211: Support mac change as part of SME Connect Date: Wed, 4 Sep 2019 12:11:53 -0700 Message-Id: <20190904191155.28056-3-prestwoj@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190904191155.28056-1-prestwoj@gmail.com> References: <20190904191155.28056-1-prestwoj@gmail.com> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org --- include/net/cfg80211.h | 1 + include/uapi/linux/nl80211.h | 1 + net/wireless/core.h | 1 + net/wireless/nl80211.c | 11 +++++++++++ net/wireless/sme.c | 7 +++++++ net/wireless/util.c | 11 +++++++++++ 6 files changed, 32 insertions(+) diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 5253e7f667bd..25eacbebfa29 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -2553,6 +2553,7 @@ struct cfg80211_connect_params { size_t fils_erp_rrk_len; bool want_1x; struct ieee80211_edmg edmg; + const u8 *mac_to_use; }; /** diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h index 0ceb945a08fb..1bb4ce58da67 100644 --- a/include/uapi/linux/nl80211.h +++ b/include/uapi/linux/nl80211.h @@ -2834,6 +2834,7 @@ enum nl80211_attrs { NL80211_ATTR_WIPHY_EDMG_CHANNELS, NL80211_ATTR_WIPHY_EDMG_BW_CONFIG, + NL80211_ATTR_MAC_TO_USE, /* add attributes here, update the policy in nl80211.c */ diff --git a/net/wireless/core.h b/net/wireless/core.h index 77556c58d9ac..29e6ab2cf343 100644 --- a/net/wireless/core.h +++ b/net/wireless/core.h @@ -454,6 +454,7 @@ int cfg80211_change_iface(struct cfg80211_registered_device *rdev, struct vif_params *params); void cfg80211_process_rdev_events(struct cfg80211_registered_device *rdev); void cfg80211_process_wdev_events(struct wireless_dev *wdev); +int cfg80211_set_mac_to_use(struct net_device *dev, const u8 *mac); bool cfg80211_does_bw_fit_range(const struct ieee80211_freq_range *freq_range, u32 center_freq_khz, u32 bw_khz); diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 4565d7385884..0202a762b5c8 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -591,6 +591,8 @@ const struct nla_policy nl80211_policy[NUM_NL80211_ATTR] = { .len = SAE_PASSWORD_MAX_LEN }, [NL80211_ATTR_TWT_RESPONDER] = { .type = NLA_FLAG }, [NL80211_ATTR_HE_OBSS_PD] = NLA_POLICY_NESTED(he_obss_pd_policy), + [NL80211_ATTR_MAC_TO_USE] = { .type = NLA_EXACT_LEN_WARN, + .len = ETH_ALEN }, }; /* policy for the key attributes */ @@ -10045,6 +10047,15 @@ static int nl80211_connect(struct sk_buff *skb, struct genl_info *info) connect.flags |= CONNECT_REQ_EXTERNAL_AUTH_SUPPORT; } + if (info->attrs[NL80211_ATTR_MAC_TO_USE]) { + if (!wiphy_ext_feature_isset(wiphy, + NL80211_EXT_FEATURE_LIVE_ADDRESS_CHANGE)) + return -EOPNOTSUPP; + + connect.mac_to_use = + nla_data(info->attrs[NL80211_ATTR_MAC_TO_USE]); + } + wdev_lock(dev->ieee80211_ptr); err = cfg80211_connect(rdev, dev, &connect, connkeys, diff --git a/net/wireless/sme.c b/net/wireless/sme.c index 7a6c38ddc65a..f164af33655f 100644 --- a/net/wireless/sme.c +++ b/net/wireless/sme.c @@ -1242,11 +1242,18 @@ int cfg80211_connect(struct cfg80211_registered_device *rdev, wdev->conn_bss_type = connect->pbss ? IEEE80211_BSS_TYPE_PBSS : IEEE80211_BSS_TYPE_ESS; + if (connect->mac_to_use) { + err = cfg80211_set_mac_to_use(dev, connect->mac_to_use); + if (err) + goto fail; + } + if (!rdev->ops->connect) err = cfg80211_sme_connect(wdev, connect, prev_bssid); else err = rdev_connect(rdev, dev, connect); +fail: if (err) { wdev->connect_keys = NULL; /* diff --git a/net/wireless/util.c b/net/wireless/util.c index 92cb2cbb179b..06700431cba0 100644 --- a/net/wireless/util.c +++ b/net/wireless/util.c @@ -2148,3 +2148,14 @@ bool cfg80211_iftype_allowed(struct wiphy *wiphy, enum nl80211_iftype iftype, return false; } EXPORT_SYMBOL(cfg80211_iftype_allowed); + +int cfg80211_set_mac_to_use(struct net_device *dev, const u8 *mac) +{ + struct sockaddr sa; + + sa.sa_family = dev->type; + memcpy(sa.sa_data, mac, ETH_ALEN); + + return dev_set_mac_address(dev, &sa, NULL); +} +EXPORT_SYMBOL(cfg80211_set_mac_to_use); From patchwork Wed Sep 4 19:11:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 11131267 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E4DA91399 for ; Wed, 4 Sep 2019 19:14:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C6AEF22CEA for ; Wed, 4 Sep 2019 19:14:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ElVcmzuh" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733087AbfIDTOB (ORCPT ); Wed, 4 Sep 2019 15:14:01 -0400 Received: from mail-pg1-f175.google.com ([209.85.215.175]:39544 "EHLO mail-pg1-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732682AbfIDTOA (ORCPT ); Wed, 4 Sep 2019 15:14:00 -0400 Received: by mail-pg1-f175.google.com with SMTP id u17so11749514pgi.6 for ; Wed, 04 Sep 2019 12:14:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=prGeALBfuemlVpYx5ZOLdgfG4/7E0J+83AupSJ5m4b4=; b=ElVcmzuhjLJzxYNO72DLF3U1eb5KVUwv/d+PoQvIXkg5h/4aR9qOU21tjJQ8yrh/9p 2+nqadpGZnXFlYE4Du5e1Cheio4f2kzI7YZfg6Mges1eEJWBD3MDLc9o2TZfiRjbqtg9 0A1x/8Q90q0tTatlPQ8y2okAvyvaIahc5HdLOzg7b0lGrad83wjKR+imwx5147071yBl ElPgHOHcUIKoazhvRvCaws9X2wYdeG7sVAgmOT4H/grvMn9+z4tDc3XaSxrNKQEkvM5N eDPs5ZJuYMnHGrjkq87bKO15wmpzg6pF8PD+h0N85p+H44tvKAnyVS2q6h/6mVDsna0v jKbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=prGeALBfuemlVpYx5ZOLdgfG4/7E0J+83AupSJ5m4b4=; b=Fb6BANDh/WCzst+hAZ7dRg1VvZUQuJgBynHw4fmDkbWzROs4dtal492btHvCzTtN38 S+crVBDXC+oZNnD7UONvJdoV430hKquMnzL0M6COkNLf/6qlDGyO66SN+OGkzrMlgSm3 nLPhksNK9gkkicLj5DSql2hB2BfvKxI3B5azxbQjO4Moq/3uM9Gb6ScDVTXeFsAlvIvt R52WEDgqU4fPqWZl/aE2RJuKGUyEG5Zf9gJFa3JWLm6QSp9CLlhSNKagZ974rfP2XhdR iA5IzB2+HAm9EIgYmhRENdGivGeLV+vcQVXkUsMaocFuSJzAL1u5xTx+YiREs8f5qASF 56kw== X-Gm-Message-State: APjAAAU+8asfmttbGYXnquYapEViIlqDcU9pyK9VON+OQl1kEXD/i/Bi lnSS6Fm8GueeSKoYdLw4Ugk2hl0NeQA= X-Google-Smtp-Source: APXvYqzXzDzrn/6zQEwFlR77bY3s66t9lm0Hs/xMC0MQTmUTt9RfY0odc4vdQgaMG5XRAk8mmiB5sw== X-Received: by 2002:aa7:8c44:: with SMTP id e4mr10089313pfd.80.1567624439782; Wed, 04 Sep 2019 12:13:59 -0700 (PDT) Received: from jprestwo-test.jf.intel.com ([134.134.139.76]) by smtp.gmail.com with ESMTPSA id u7sm18849727pgr.94.2019.09.04.12.13.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Sep 2019 12:13:59 -0700 (PDT) From: James Prestwood To: linux-wireless@vger.kernel.org Cc: James Prestwood Subject: [RFC 3/4] mac80211: Support LIVE_ADDRESS_CHANGE feature Date: Wed, 4 Sep 2019 12:11:54 -0700 Message-Id: <20190904191155.28056-4-prestwoj@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190904191155.28056-1-prestwoj@gmail.com> References: <20190904191155.28056-1-prestwoj@gmail.com> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org --- net/mac80211/iface.c | 51 ++++++++++++++++++++++++++++++++++++++++++-- net/mac80211/main.c | 1 + 2 files changed, 50 insertions(+), 2 deletions(-) diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c index 8dc6580e1787..16ef6b83e7ea 100644 --- a/net/mac80211/iface.c +++ b/net/mac80211/iface.c @@ -198,15 +198,57 @@ static int ieee80211_verify_mac(struct ieee80211_sub_if_data *sdata, u8 *addr, return ret; } +static int ieee80211_can_live_addr_change(struct ieee80211_sub_if_data *sdata) +{ + if (netif_carrier_ok(sdata->dev)) + return -EBUSY; + + switch (sdata->vif.type) { + case NL80211_IFTYPE_AP: + case NL80211_IFTYPE_P2P_GO: + case NL80211_IFTYPE_AP_VLAN: + case NL80211_IFTYPE_WDS: + case NL80211_IFTYPE_MESH_POINT: + case NL80211_IFTYPE_MONITOR: + case NL80211_IFTYPE_OCB: + /* No further checking required, when started or UP these + * interface types set carrier + */ + break; + case NL80211_IFTYPE_ADHOC: + if (sdata->u.ibss.ssid_len != 0) + return -EBUSY; + break; + case NL80211_IFTYPE_STATION: + case NL80211_IFTYPE_P2P_CLIENT: + if (!list_empty(&sdata->local->roc_list) || + !sdata->local->scanning) + return -EBUSY; + break; + default: + return -EOPNOTSUPP; + } + + return 0; +} + + static int ieee80211_change_mac(struct net_device *dev, void *addr) { struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); + struct ieee80211_local *local = sdata->local; struct sockaddr *sa = addr; bool check_dup = true; + bool live = false; int ret; - if (ieee80211_sdata_running(sdata)) - return -EBUSY; + if (ieee80211_sdata_running(sdata)) { + ret = ieee80211_can_live_addr_change(sdata); + if (ret) + return ret; + + live = true; + } if (sdata->vif.type == NL80211_IFTYPE_MONITOR && !(sdata->u.mntr.flags & MONITOR_FLAG_ACTIVE)) @@ -216,7 +258,11 @@ static int ieee80211_change_mac(struct net_device *dev, void *addr) if (ret) return ret; + if (live) + drv_remove_interface(local, sdata); ret = eth_mac_addr(dev, sa); + if (live) + drv_add_interface(local, sdata); if (ret == 0) memcpy(sdata->vif.addr, sa->sa_data, ETH_ALEN); @@ -1871,6 +1917,7 @@ int ieee80211_if_add(struct ieee80211_local *local, const char *name, sdata->u.mgd.use_4addr = params->use_4addr; ndev->features |= local->hw.netdev_features; + ndev->priv_flags |= IFF_LIVE_ADDR_CHANGE; netdev_set_default_ethtool_ops(ndev, &ieee80211_ethtool_ops); diff --git a/net/mac80211/main.c b/net/mac80211/main.c index 29b9d57df1a3..0aea583e5e69 100644 --- a/net/mac80211/main.c +++ b/net/mac80211/main.c @@ -596,6 +596,7 @@ struct ieee80211_hw *ieee80211_alloc_hw_nm(size_t priv_data_len, wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_TXQS); wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_RRM); + wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_LIVE_ADDRESS_CHANGE); wiphy->bss_priv_size = sizeof(struct ieee80211_bss); From patchwork Wed Sep 4 19:11:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 11131269 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A3BF915E9 for ; Wed, 4 Sep 2019 19:14:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 843F02168B for ; Wed, 4 Sep 2019 19:14:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="TTWrLPgx" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733138AbfIDTOD (ORCPT ); Wed, 4 Sep 2019 15:14:03 -0400 Received: from mail-pl1-f181.google.com ([209.85.214.181]:37528 "EHLO mail-pl1-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732934AbfIDTOC (ORCPT ); Wed, 4 Sep 2019 15:14:02 -0400 Received: by mail-pl1-f181.google.com with SMTP id b10so4937075plr.4 for ; Wed, 04 Sep 2019 12:14:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ns59MJnS41pUvrzoJ+EufNvjRLwIyb/C4J/rzg8qRUQ=; b=TTWrLPgx9rMepi2uKSOpdfcFQtRf9rsSOKm4TdLEh0yAXp8BwxW//Z7gwnspFJCnBi 3nre6oOf2agMLKODWQEVFK9OBk8i+5siddSNzn/Cn3RZlHxRYVtDE10cmWSE1xG2MFM2 vnHehha8CRISwMgHuJENYufqwEu3KjrK8oKa5uIyXYo8H+Arge4DdjqlodcQeOVemRGZ NjYnUJjJJgkytUbHcGbq/GQK2IHbOL1nZaAq7Kr34hGTq26A3l2AGwBp1h7jwHFuetYH 0g/Rxy6OwumfYWubJk+4x9PMFV6Ix9ZMNMRxwMsKt+p8yC+vCBnc1AIOCUe8SDl4RBE+ 4CSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ns59MJnS41pUvrzoJ+EufNvjRLwIyb/C4J/rzg8qRUQ=; b=Gb/DMAd70q2qdv89VEqCL+Q2HSFrg4PQ7qzwefZA3SL9j3tEj8FwVdKB+FsDfmokJb a1uk7jTxGM46yh4SP0xztYYs9lyFmZFPz9y2Tt2qTOgypFERhbIb9XQNE5fLio+ZFmjY eJ5I/GW1SUBn+iyGmnce72MmOtyL4KKJyaRvJ0xvBp2jLJP8zvOMrW6nJvRIPs2WZwCo wGmCAvEX1LURtMlHpi5aHvADDANIX0a3OAaWU5sJ4MuXpBLX37tRrKueLK4PqSCxrR5b xQTS4K7WY8Heicb5noqPLfHvmFVtFtnI9EB4P/T8H7uH+EPKY5vS2cAMj++FaPaf/6T1 Tapw== X-Gm-Message-State: APjAAAXpf607+j9uYcHRogJ8Orrljo/7aprdkN550KI1k/MkaQjuO4Ee Hh/7Ngj4RHVTWuz1/16Qkkm6op7KcMA= X-Google-Smtp-Source: APXvYqzEpbviJA/1seqx4GKlhgUN45RrR8UYWRf1+1ASKpMuAa4rf+xs3jxIlIppdLHIwE97+hhQHg== X-Received: by 2002:a17:902:ff09:: with SMTP id f9mr345627plj.55.1567624441357; Wed, 04 Sep 2019 12:14:01 -0700 (PDT) Received: from jprestwo-test.jf.intel.com ([134.134.139.76]) by smtp.gmail.com with ESMTPSA id u7sm18849727pgr.94.2019.09.04.12.14.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Sep 2019 12:14:00 -0700 (PDT) From: James Prestwood To: linux-wireless@vger.kernel.org Cc: James Prestwood Subject: [RFC 4/4] {nl,cfg}nl80211: Support mac change for mlme_authenticate Date: Wed, 4 Sep 2019 12:11:55 -0700 Message-Id: <20190904191155.28056-5-prestwoj@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190904191155.28056-1-prestwoj@gmail.com> References: <20190904191155.28056-1-prestwoj@gmail.com> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org --- net/wireless/core.h | 3 ++- net/wireless/mlme.c | 9 ++++++++- net/wireless/nl80211.c | 7 ++++++- net/wireless/sme.c | 2 +- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/net/wireless/core.h b/net/wireless/core.h index 29e6ab2cf343..869ab983692d 100644 --- a/net/wireless/core.h +++ b/net/wireless/core.h @@ -366,7 +366,8 @@ int cfg80211_mlme_auth(struct cfg80211_registered_device *rdev, const u8 *ssid, int ssid_len, const u8 *ie, int ie_len, const u8 *key, int key_len, int key_idx, - const u8 *auth_data, int auth_data_len); + const u8 *auth_data, int auth_data_len, + const u8 *mac_to_use); int cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev, struct net_device *dev, struct ieee80211_channel *chan, diff --git a/net/wireless/mlme.c b/net/wireless/mlme.c index f9462010575f..adf411905e64 100644 --- a/net/wireless/mlme.c +++ b/net/wireless/mlme.c @@ -226,7 +226,8 @@ int cfg80211_mlme_auth(struct cfg80211_registered_device *rdev, const u8 *ssid, int ssid_len, const u8 *ie, int ie_len, const u8 *key, int key_len, int key_idx, - const u8 *auth_data, int auth_data_len) + const u8 *auth_data, int auth_data_len, + const u8 *mac_to_use) { struct wireless_dev *wdev = dev->ieee80211_ptr; struct cfg80211_auth_request req = { @@ -257,6 +258,12 @@ int cfg80211_mlme_auth(struct cfg80211_registered_device *rdev, if (!req.bss) return -ENOENT; + if (mac_to_use) { + err = cfg80211_set_mac_to_use(dev, mac_to_use); + if (err) + return err; + } + err = rdev_auth(rdev, dev, &req); cfg80211_put_bss(&rdev->wiphy, req.bss); diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 0202a762b5c8..db32eaaaa50e 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -8898,6 +8898,7 @@ static int nl80211_authenticate(struct sk_buff *skb, struct genl_info *info) enum nl80211_auth_type auth_type; struct key_parse key; bool local_state_change; + const u8 *mac_to_change = NULL; if (!info->attrs[NL80211_ATTR_MAC]) return -EINVAL; @@ -8993,6 +8994,10 @@ static int nl80211_authenticate(struct sk_buff *skb, struct genl_info *info) local_state_change = !!info->attrs[NL80211_ATTR_LOCAL_STATE_CHANGE]; + if (info->attrs[NL80211_ATTR_MAC_TO_USE]) + mac_to_change = nla_data( + info->attrs[NL80211_ATTR_MAC_TO_USE]); + /* * Since we no longer track auth state, ignore * requests to only change local state. @@ -9004,7 +9009,7 @@ static int nl80211_authenticate(struct sk_buff *skb, struct genl_info *info) err = cfg80211_mlme_auth(rdev, dev, chan, auth_type, bssid, ssid, ssid_len, ie, ie_len, key.p.key, key.p.key_len, key.idx, - auth_data, auth_data_len); + auth_data, auth_data_len, mac_to_change); wdev_unlock(dev->ieee80211_ptr); return err; } diff --git a/net/wireless/sme.c b/net/wireless/sme.c index f164af33655f..f66ea48b73df 100644 --- a/net/wireless/sme.c +++ b/net/wireless/sme.c @@ -174,7 +174,7 @@ static int cfg80211_conn_do_work(struct wireless_dev *wdev, params->ssid, params->ssid_len, NULL, 0, params->key, params->key_len, - params->key_idx, NULL, 0); + params->key_idx, NULL, 0, NULL); case CFG80211_CONN_AUTH_FAILED_TIMEOUT: *treason = NL80211_TIMEOUT_AUTH; return -ENOTCONN;