From: Denis Kenzior <denkenz@gmail.com>
To: iwd@lists.01.org
Subject: [PATCH 3/8] netdev: Re-add frame watches on iftype change
Date: Tue, 20 Apr 2021 11:35:14 -0500 [thread overview]
Message-ID: <20210420163519.12375-3-denkenz@gmail.com> (raw)
In-Reply-To: <20210420163519.12375-1-denkenz@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 4902 bytes --]
If the iftype changes, kernel silently wipes out any frame registrations
we may have registered. Right now, frame registrations are only done when
the interface is created. This can result in frame watches not being
added if the interface type is changed between station mode to ap mode
and then back to station mode, e.g.:
device wlan0 set-property Mode ap
device wlan0 set-property Mode station
Make sure to re-add frame registrations according to the mode if the
interface type is changed.
---
src/netdev.c | 80 ++++++++++++++++++++++++++++++----------------------
1 file changed, 47 insertions(+), 33 deletions(-)
diff --git a/src/netdev.c b/src/netdev.c
index f4877bbd6fbb..4208deea35fa 100644
--- a/src/netdev.c
+++ b/src/netdev.c
@@ -4867,6 +4867,51 @@ static int netdev_cqm_rssi_update(struct netdev *netdev)
return 0;
}
+static void netdev_add_station_frame_watches(struct netdev *netdev)
+{
+ static const uint8_t action_neighbor_report_prefix[2] = { 0x05, 0x05 };
+ static const uint8_t action_sa_query_resp_prefix[2] = { 0x08, 0x01 };
+ static const uint8_t action_sa_query_req_prefix[2] = { 0x08, 0x00 };
+ static const uint8_t action_ft_response_prefix[] = { 0x06, 0x02 };
+ static const uint8_t action_qos_map_prefix[] = { 0x01, 0x04 };
+ uint64_t wdev = netdev->wdev_id;
+
+ /* Subscribe to Management -> Action -> RM -> Neighbor Report frames */
+ frame_watch_add(wdev, 0, 0x00d0, action_neighbor_report_prefix,
+ sizeof(action_neighbor_report_prefix),
+ netdev_neighbor_report_frame_event, netdev, NULL);
+
+ frame_watch_add(wdev, 0, 0x00d0, action_sa_query_resp_prefix,
+ sizeof(action_sa_query_resp_prefix),
+ netdev_sa_query_resp_frame_event, netdev, NULL);
+
+ frame_watch_add(wdev, 0, 0x00d0, action_sa_query_req_prefix,
+ sizeof(action_sa_query_req_prefix),
+ netdev_sa_query_req_frame_event, netdev, NULL);
+
+ frame_watch_add(wdev, 0, 0x00d0, action_ft_response_prefix,
+ sizeof(action_ft_response_prefix),
+ netdev_ft_response_frame_event, netdev, NULL);
+
+ if (wiphy_supports_qos_set_map(netdev->wiphy))
+ frame_watch_add(wdev, 0, 0x00d0, action_qos_map_prefix,
+ sizeof(action_qos_map_prefix),
+ netdev_qos_map_frame_event, netdev, NULL);
+}
+
+static void netdev_setup_interface(struct netdev *netdev)
+{
+ switch (netdev->type) {
+ case NL80211_IFTYPE_STATION:
+ /* Set RSSI threshold for CQM notifications */
+ netdev_cqm_rssi_update(netdev);
+ netdev_add_station_frame_watches(netdev);
+ break;
+ default:
+ break;
+ }
+}
+
static void netdev_set_interface_event(struct l_genl_msg *msg,
struct netdev *netdev)
{
@@ -4887,9 +4932,7 @@ static void netdev_set_interface_event(struct l_genl_msg *msg,
netdev->type = iftype;
frame_watch_wdev_remove(wdev_id);
- /* Set RSSI threshold for CQM notifications */
- if (netdev->type == NL80211_IFTYPE_STATION)
- netdev_cqm_rssi_update(netdev);
+ netdev_setup_interface(netdev);
}
static void netdev_config_notify(struct l_genl_msg *msg, void *user_data)
@@ -5447,11 +5490,6 @@ struct netdev *netdev_create_from_genl(struct l_genl_msg *msg,
struct wiphy *wiphy = NULL;
struct ifinfomsg *rtmmsg;
size_t bufsize;
- const uint8_t action_neighbor_report_prefix[2] = { 0x05, 0x05 };
- const uint8_t action_sa_query_resp_prefix[2] = { 0x08, 0x01 };
- const uint8_t action_sa_query_req_prefix[2] = { 0x08, 0x00 };
- const uint8_t action_ft_response_prefix[] = { 0x06, 0x02 };
- const uint8_t action_qos_map_prefix[] = { 0x01, 0x04 };
struct l_io *pae_io = NULL;
if (nl80211_parse_attrs(msg, NL80211_ATTR_IFINDEX, &ifindex,
@@ -5525,31 +5563,7 @@ struct netdev *netdev_create_from_genl(struct l_genl_msg *msg,
l_free(rtmmsg);
- /* Subscribe to Management -> Action -> RM -> Neighbor Report frames */
- frame_watch_add(wdev, 0, 0x00d0, action_neighbor_report_prefix,
- sizeof(action_neighbor_report_prefix),
- netdev_neighbor_report_frame_event, netdev, NULL);
-
- frame_watch_add(wdev, 0, 0x00d0, action_sa_query_resp_prefix,
- sizeof(action_sa_query_resp_prefix),
- netdev_sa_query_resp_frame_event, netdev, NULL);
-
- frame_watch_add(wdev, 0, 0x00d0, action_sa_query_req_prefix,
- sizeof(action_sa_query_req_prefix),
- netdev_sa_query_req_frame_event, netdev, NULL);
-
- frame_watch_add(wdev, 0, 0x00d0, action_ft_response_prefix,
- sizeof(action_ft_response_prefix),
- netdev_ft_response_frame_event, netdev, NULL);
-
- if (wiphy_supports_qos_set_map(netdev->wiphy))
- frame_watch_add(wdev, 0, 0x00d0, action_qos_map_prefix,
- sizeof(action_qos_map_prefix),
- netdev_qos_map_frame_event, netdev, NULL);
-
- /* Set RSSI threshold for CQM notifications */
- if (netdev->type == NL80211_IFTYPE_STATION)
- netdev_cqm_rssi_update(netdev);
+ netdev_setup_interface(netdev);
return netdev;
}
--
2.26.3
next prev parent reply other threads:[~2021-04-20 16:35 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-20 16:35 [PATCH 1/8] netdev: Track SET_INTERFACE events Denis Kenzior
2021-04-20 16:35 ` [PATCH 2/8] frame-xchg: iftype changes to be managed by netdev Denis Kenzior
2021-04-20 16:35 ` Denis Kenzior [this message]
2021-04-20 16:35 ` [PATCH 4/8] rrm: Track that station is removed Denis Kenzior
2021-04-20 16:35 ` [PATCH 5/8] netdev: Add new iftype change event Denis Kenzior
2021-04-20 16:35 ` [PATCH 6/8] rrm: Always create RRM state Denis Kenzior
2021-04-20 16:35 ` [PATCH 7/8] rrm: React to IFTYPE_CHANGE events Denis Kenzior
2021-04-20 16:35 ` [PATCH 8/8] station: Move AP directed roam watch to station Denis Kenzior
2021-04-23 14:52 ` [PATCH 1/8] netdev: Track SET_INTERFACE events Denis Kenzior
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210420163519.12375-3-denkenz@gmail.com \
--to=denkenz@gmail.com \
--cc=iwd@lists.01.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox