20e16ad23f00efc7f1871e93237be24b666b4020
[oweals/openwrt.git] /
1 From 455f3e76cfc0d893585a5f358b9ddbe9c1e1e53b Mon Sep 17 00:00:00 2001
2 From: Arend Van Spriel <arend.vanspriel@broadcom.com>
3 Date: Wed, 28 Feb 2018 21:15:20 +0100
4 Subject: [PATCH] brcmfmac: fix P2P_DEVICE ethernet address generation
5
6 The firmware has a requirement that the P2P_DEVICE address should
7 be different from the address of the primary interface. When not
8 specified by user-space, the driver generates the MAC address for
9 the P2P_DEVICE interface using the MAC address of the primary
10 interface and setting the locally administered bit. However, the MAC
11 address of the primary interface may already have that bit set causing
12 the creation of the P2P_DEVICE interface to fail with -EBUSY. Fix this
13 by using a random address instead to determine the P2P_DEVICE address.
14
15 Cc: stable@vger.kernel.org # 3.10.y
16 Reported-by: Hans de Goede <hdegoede@redhat.com>
17 Reviewed-by: Hante Meuleman <hante.meuleman@broadcom.com>
18 Reviewed-by: Pieter-Paul Giesberts <pieter-paul.giesberts@broadcom.com>
19 Reviewed-by: Franky Lin <franky.lin@broadcom.com>
20 Signed-off-by: Arend van Spriel <arend.vanspriel@broadcom.com>
21 Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
22 ---
23  .../net/wireless/broadcom/brcm80211/brcmfmac/p2p.c | 24 ++++++++++------------
24  1 file changed, 11 insertions(+), 13 deletions(-)
25
26 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
27 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
28 @@ -462,25 +462,23 @@ static int brcmf_p2p_set_firmware(struct
29   * @dev_addr: optional device address.
30   *
31   * P2P needs mac addresses for P2P device and interface. If no device
32 - * address it specified, these are derived from the primary net device, ie.
33 - * the permanent ethernet address of the device.
34 + * address it specified, these are derived from a random ethernet
35 + * address.
36   */
37  static void brcmf_p2p_generate_bss_mac(struct brcmf_p2p_info *p2p, u8 *dev_addr)
38  {
39 -       struct brcmf_if *pri_ifp = p2p->bss_idx[P2PAPI_BSSCFG_PRIMARY].vif->ifp;
40 -       bool local_admin = false;
41 +       bool random_addr = false;
42  
43 -       if (!dev_addr || is_zero_ether_addr(dev_addr)) {
44 -               dev_addr = pri_ifp->mac_addr;
45 -               local_admin = true;
46 -       }
47 +       if (!dev_addr || is_zero_ether_addr(dev_addr))
48 +               random_addr = true;
49  
50 -       /* Generate the P2P Device Address.  This consists of the device's
51 -        * primary MAC address with the locally administered bit set.
52 +       /* Generate the P2P Device Address obtaining a random ethernet
53 +        * address with the locally administered bit set.
54          */
55 -       memcpy(p2p->dev_addr, dev_addr, ETH_ALEN);
56 -       if (local_admin)
57 -               p2p->dev_addr[0] |= 0x02;
58 +       if (random_addr)
59 +               eth_random_addr(p2p->dev_addr);
60 +       else
61 +               memcpy(p2p->dev_addr, dev_addr, ETH_ALEN);
62  
63         /* Generate the P2P Interface Address.  If the discovery and connection
64          * BSSCFGs need to simultaneously co-exist, then this address must be