d5b08b441044f6f69c422fdafd09155a33cf917f
[openwrt/openwrt.git] /
1 From 33d915d9e8ce811d8958915ccd18d71a66c7c495 Mon Sep 17 00:00:00 2001
2 From: Manikanta Pubbisetty <mpubbise@codeaurora.org>
3 Date: Wed, 8 May 2019 14:55:33 +0530
4 Subject: [PATCH] {nl,mac}80211: allow 4addr AP operation on crypto controlled
5 devices
6
7 As per the current design, in the case of sw crypto controlled devices,
8 it is the device which advertises the support for AP/VLAN iftype based
9 on it's ability to tranmsit packets encrypted in software
10 (In VLAN functionality, group traffic generated for a specific
11 VLAN group is always encrypted in software). Commit db3bdcb9c3ff
12 ("mac80211: allow AP_VLAN operation on crypto controlled devices")
13 has introduced this change.
14
15 Since 4addr AP operation also uses AP/VLAN iftype, this conditional
16 way of advertising AP/VLAN support has broken 4addr AP mode operation on
17 crypto controlled devices which do not support VLAN functionality.
18
19 In the case of ath10k driver, not all firmwares have support for VLAN
20 functionality but all can support 4addr AP operation. Because AP/VLAN
21 support is not advertised for these devices, 4addr AP operations are
22 also blocked.
23
24 Fix this by allowing 4addr operation on devices which do not support
25 AP/VLAN iftype but can support 4addr AP operation (decision is based on
26 the wiphy flag WIPHY_FLAG_4ADDR_AP).
27
28 Cc: stable@vger.kernel.org
29 Fixes: db3bdcb9c3ff ("mac80211: allow AP_VLAN operation on crypto controlled devices")
30 Signed-off-by: Manikanta Pubbisetty <mpubbise@codeaurora.org>
31 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
32 ---
33 include/net/cfg80211.h | 3 ++-
34 net/mac80211/util.c | 4 +++-
35 net/wireless/core.c | 6 +++++-
36 net/wireless/nl80211.c | 8 ++++++--
37 4 files changed, 16 insertions(+), 5 deletions(-)
38
39 --- a/include/net/cfg80211.h
40 +++ b/include/net/cfg80211.h
41 @@ -3457,7 +3457,8 @@ struct cfg80211_ops {
42 * on wiphy_new(), but can be changed by the driver if it has a good
43 * reason to override the default
44 * @WIPHY_FLAG_4ADDR_AP: supports 4addr mode even on AP (with a single station
45 - * on a VLAN interface)
46 + * on a VLAN interface). This flag also serves an extra purpose of
47 + * supporting 4ADDR AP mode on devices which do not support AP/VLAN iftype.
48 * @WIPHY_FLAG_4ADDR_STATION: supports 4addr mode even as a station
49 * @WIPHY_FLAG_CONTROL_PORT_PROTOCOL: This device supports setting the
50 * control port protocol ethertype. The device also honours the
51 --- a/net/mac80211/util.c
52 +++ b/net/mac80211/util.c
53 @@ -3626,7 +3626,9 @@ int ieee80211_check_combinations(struct
54 }
55
56 /* Always allow software iftypes */
57 - if (local->hw.wiphy->software_iftypes & BIT(iftype)) {
58 + if (local->hw.wiphy->software_iftypes & BIT(iftype) ||
59 + (iftype == NL80211_IFTYPE_AP_VLAN &&
60 + local->hw.wiphy->flags & WIPHY_FLAG_4ADDR_AP)) {
61 if (radar_detect)
62 return -EINVAL;
63 return 0;
64 --- a/net/wireless/core.c
65 +++ b/net/wireless/core.c
66 @@ -1351,8 +1351,12 @@ static int cfg80211_netdev_notifier_call
67 }
68 break;
69 case NETDEV_PRE_UP:
70 - if (!(wdev->wiphy->interface_modes & BIT(wdev->iftype)))
71 + if (!(wdev->wiphy->interface_modes & BIT(wdev->iftype)) &&
72 + !(wdev->iftype == NL80211_IFTYPE_AP_VLAN &&
73 + rdev->wiphy.flags & WIPHY_FLAG_4ADDR_AP &&
74 + wdev->use_4addr))
75 return notifier_from_errno(-EOPNOTSUPP);
76 +
77 if (rfkill_blocked(rdev->rfkill))
78 return notifier_from_errno(-ERFKILL);
79 break;
80 --- a/net/wireless/nl80211.c
81 +++ b/net/wireless/nl80211.c
82 @@ -3194,8 +3194,7 @@ static int nl80211_new_interface(struct
83 return -EINVAL;
84 }
85
86 - if (!rdev->ops->add_virtual_intf ||
87 - !(rdev->wiphy.interface_modes & (1 << type)))
88 + if (!rdev->ops->add_virtual_intf)
89 return -EOPNOTSUPP;
90
91 if ((type == NL80211_IFTYPE_P2P_DEVICE || type == NL80211_IFTYPE_NAN ||
92 @@ -3214,6 +3213,11 @@ static int nl80211_new_interface(struct
93 return err;
94 }
95
96 + if (!(rdev->wiphy.interface_modes & (1 << type)) &&
97 + !(type == NL80211_IFTYPE_AP_VLAN && params.use_4addr &&
98 + rdev->wiphy.flags & WIPHY_FLAG_4ADDR_AP))
99 + return -EOPNOTSUPP;
100 +
101 err = nl80211_parse_mon_options(rdev, type, info, &params);
102 if (err < 0)
103 return err;