diff options
| author | Ashish Kumar Dhanotiya <adhanoti@codeaurora.org> | 2018-02-21 17:42:55 +0530 |
|---|---|---|
| committer | snandini <snandini@codeaurora.org> | 2018-02-22 13:12:35 -0800 |
| commit | e479f5fbf8559053fd06c6be46ecbefb4fbdacd2 (patch) | |
| tree | 3738b08df56789af9b0d2300c85a30961400700b | |
| parent | 692f42d56da16f3344aa92c46d9c434f45359bc7 (diff) | |
qcacld-3.0: Reject invalid MAC address during dynamic MAC change
Currently when the MAC address is changed dynamically, invalid MAC
(Broadcast, Multicast and 00:00:00:00:00:00) are getting accepted
and interface is getting up on these invalid addresses because
of this device is trying to connect to AP with the configured
invalid address.
To address this issue reject all invalid MAC addresses
when MAC is dynamically getting configured.
Change-Id: If2530b213b5ffc2ddf0bc728138e1f3200f33286
CRs-Fixed: 2190468
| -rw-r--r-- | core/hdd/src/wlan_hdd_hostapd.c | 18 | ||||
| -rw-r--r-- | core/hdd/src/wlan_hdd_main.c | 18 |
2 files changed, 36 insertions, 0 deletions
diff --git a/core/hdd/src/wlan_hdd_hostapd.c b/core/hdd/src/wlan_hdd_hostapd.c index 7b5ff59a66b6..fe91ac938a53 100644 --- a/core/hdd/src/wlan_hdd_hostapd.c +++ b/core/hdd/src/wlan_hdd_hostapd.c @@ -562,6 +562,7 @@ static int __hdd_hostapd_set_mac_address(struct net_device *dev, void *addr) hdd_adapter_t *adapter; hdd_context_t *hdd_ctx; int ret = 0; + struct qdf_mac_addr mac_addr; ENTER_DEV(dev); @@ -571,6 +572,23 @@ static int __hdd_hostapd_set_mac_address(struct net_device *dev, void *addr) if (0 != ret) return ret; + qdf_mem_copy(&mac_addr, psta_mac_addr->sa_data, QDF_MAC_ADDR_SIZE); + + if (qdf_is_macaddr_zero(&mac_addr)) { + hdd_err("MAC is all zero"); + return -EINVAL; + } + + if (qdf_is_macaddr_broadcast(&mac_addr)) { + hdd_err("MAC is Broadcast"); + return -EINVAL; + } + + if (ETHER_IS_MULTICAST(psta_mac_addr->sa_data)) { + hdd_err("MAC is Multicast"); + return -EINVAL; + } + memcpy(dev->dev_addr, psta_mac_addr->sa_data, ETH_ALEN); EXIT(); return 0; diff --git a/core/hdd/src/wlan_hdd_main.c b/core/hdd/src/wlan_hdd_main.c index 2add351cad90..cc85460df2e6 100644 --- a/core/hdd/src/wlan_hdd_main.c +++ b/core/hdd/src/wlan_hdd_main.c @@ -2656,6 +2656,7 @@ static int __hdd_set_mac_address(struct net_device *dev, void *addr) struct sockaddr *psta_mac_addr = addr; QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS; int ret; + struct qdf_mac_addr mac_addr; ENTER_DEV(dev); @@ -2664,6 +2665,23 @@ static int __hdd_set_mac_address(struct net_device *dev, void *addr) if (0 != ret) return ret; + qdf_mem_copy(&mac_addr, psta_mac_addr->sa_data, QDF_MAC_ADDR_SIZE); + + if (qdf_is_macaddr_zero(&mac_addr)) { + hdd_err("MAC is all zero"); + return -EINVAL; + } + + if (qdf_is_macaddr_broadcast(&mac_addr)) { + hdd_err("MAC is Broadcast"); + return -EINVAL; + } + + if (ETHER_IS_MULTICAST(psta_mac_addr->sa_data)) { + hdd_err("MAC is Multicast"); + return -EINVAL; + } + memcpy(&adapter->macAddressCurrent, psta_mac_addr->sa_data, ETH_ALEN); memcpy(dev->dev_addr, psta_mac_addr->sa_data, ETH_ALEN); |
