mt76: update to the latest version
[oweals/openwrt.git] / package / kernel / mac80211 / patches / 303-v4.15-0002-brcmfmac-disable-packet-filtering-in-promiscuous-mod.patch
1 From 6c219b0088158da839a5be63c5b3d96c145501d2 Mon Sep 17 00:00:00 2001
2 From: Franky Lin <franky.lin@broadcom.com>
3 Date: Wed, 8 Nov 2017 14:36:32 +0100
4 Subject: [PATCH] brcmfmac: disable packet filtering in promiscuous mode
5
6 Disable arp and nd offload to allow all packets sending to host.
7
8 Reported-by: Phil Elwell <phil@raspberrypi.org>
9 Tested-by: Phil Elwell <phil@raspberrypi.org>
10 Reviewed-by: Arend Van Spriel <arend.vanspriel@broadcom.com>
11 Signed-off-by: Franky Lin <franky.lin@broadcom.com>
12 Signed-off-by: Arend van Spriel <arend.vanspriel@broadcom.com>
13 Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
14 ---
15  .../broadcom/brcm80211/brcmfmac/cfg80211.c         | 41 ----------------------
16  .../wireless/broadcom/brcm80211/brcmfmac/core.c    | 38 ++++++++++++++++++++
17  .../wireless/broadcom/brcm80211/brcmfmac/core.h    |  1 +
18  3 files changed, 39 insertions(+), 41 deletions(-)
19
20 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
21 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
22 @@ -472,47 +472,6 @@ send_key_to_dongle(struct brcmf_if *ifp,
23         return err;
24  }
25  
26 -static s32
27 -brcmf_configure_arp_nd_offload(struct brcmf_if *ifp, bool enable)
28 -{
29 -       s32 err;
30 -       u32 mode;
31 -
32 -       if (enable)
33 -               mode = BRCMF_ARP_OL_AGENT | BRCMF_ARP_OL_PEER_AUTO_REPLY;
34 -       else
35 -               mode = 0;
36 -
37 -       /* Try to set and enable ARP offload feature, this may fail, then it  */
38 -       /* is simply not supported and err 0 will be returned                 */
39 -       err = brcmf_fil_iovar_int_set(ifp, "arp_ol", mode);
40 -       if (err) {
41 -               brcmf_dbg(TRACE, "failed to set ARP offload mode to 0x%x, err = %d\n",
42 -                         mode, err);
43 -               err = 0;
44 -       } else {
45 -               err = brcmf_fil_iovar_int_set(ifp, "arpoe", enable);
46 -               if (err) {
47 -                       brcmf_dbg(TRACE, "failed to configure (%d) ARP offload err = %d\n",
48 -                                 enable, err);
49 -                       err = 0;
50 -               } else
51 -                       brcmf_dbg(TRACE, "successfully configured (%d) ARP offload to 0x%x\n",
52 -                                 enable, mode);
53 -       }
54 -
55 -       err = brcmf_fil_iovar_int_set(ifp, "ndoe", enable);
56 -       if (err) {
57 -               brcmf_dbg(TRACE, "failed to configure (%d) ND offload err = %d\n",
58 -                         enable, err);
59 -               err = 0;
60 -       } else
61 -               brcmf_dbg(TRACE, "successfully configured (%d) ND offload to 0x%x\n",
62 -                         enable, mode);
63 -
64 -       return err;
65 -}
66 -
67  static void
68  brcmf_cfg80211_update_proto_addr_mode(struct wireless_dev *wdev)
69  {
70 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
71 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
72 @@ -71,6 +71,43 @@ struct brcmf_if *brcmf_get_ifp(struct br
73         return ifp;
74  }
75  
76 +void brcmf_configure_arp_nd_offload(struct brcmf_if *ifp, bool enable)
77 +{
78 +       s32 err;
79 +       u32 mode;
80 +
81 +       if (enable)
82 +               mode = BRCMF_ARP_OL_AGENT | BRCMF_ARP_OL_PEER_AUTO_REPLY;
83 +       else
84 +               mode = 0;
85 +
86 +       /* Try to set and enable ARP offload feature, this may fail, then it  */
87 +       /* is simply not supported and err 0 will be returned                 */
88 +       err = brcmf_fil_iovar_int_set(ifp, "arp_ol", mode);
89 +       if (err) {
90 +               brcmf_dbg(TRACE, "failed to set ARP offload mode to 0x%x, err = %d\n",
91 +                         mode, err);
92 +       } else {
93 +               err = brcmf_fil_iovar_int_set(ifp, "arpoe", enable);
94 +               if (err) {
95 +                       brcmf_dbg(TRACE, "failed to configure (%d) ARP offload err = %d\n",
96 +                                 enable, err);
97 +               } else {
98 +                       brcmf_dbg(TRACE, "successfully configured (%d) ARP offload to 0x%x\n",
99 +                                 enable, mode);
100 +               }
101 +       }
102 +
103 +       err = brcmf_fil_iovar_int_set(ifp, "ndoe", enable);
104 +       if (err) {
105 +               brcmf_dbg(TRACE, "failed to configure (%d) ND offload err = %d\n",
106 +                         enable, err);
107 +       } else {
108 +               brcmf_dbg(TRACE, "successfully configured (%d) ND offload to 0x%x\n",
109 +                         enable, mode);
110 +       }
111 +}
112 +
113  static void _brcmf_set_multicast_list(struct work_struct *work)
114  {
115         struct brcmf_if *ifp;
116 @@ -134,6 +171,7 @@ static void _brcmf_set_multicast_list(st
117         if (err < 0)
118                 brcmf_err("Setting BRCMF_C_SET_PROMISC failed, %d\n",
119                           err);
120 +       brcmf_configure_arp_nd_offload(ifp, !cmd_value);
121  }
122  
123  #if IS_ENABLED(CONFIG_IPV6)
124 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h
125 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h
126 @@ -203,6 +203,7 @@ int brcmf_netdev_wait_pend8021x(struct b
127  /* Return pointer to interface name */
128  char *brcmf_ifname(struct brcmf_if *ifp);
129  struct brcmf_if *brcmf_get_ifp(struct brcmf_pub *drvr, int ifidx);
130 +void brcmf_configure_arp_nd_offload(struct brcmf_if *ifp, bool enable);
131  int brcmf_net_attach(struct brcmf_if *ifp, bool rtnl_locked);
132  struct brcmf_if *brcmf_add_if(struct brcmf_pub *drvr, s32 bsscfgidx, s32 ifidx,
133                               bool is_p2pdev, const char *name, u8 *mac_addr);