All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/8] netdev: Track SET_INTERFACE events
@ 2021-04-20 16:35 Denis Kenzior
  2021-04-20 16:35 ` [PATCH 2/8] frame-xchg: iftype changes to be managed by netdev Denis Kenzior
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: Denis Kenzior @ 2021-04-20 16:35 UTC (permalink / raw)
  To: iwd

[-- Attachment #1: Type: text/plain, Size: 2304 bytes --]

And set the interface type based on the event rather than the command
callback.  This allows us to track interface type changes even if they
come from outside iwd (which shouldn't happen.)
---
 src/netdev.c | 47 +++++++++++++++++++++++++++++++++++++++++------
 1 file changed, 41 insertions(+), 6 deletions(-)

diff --git a/src/netdev.c b/src/netdev.c
index a63c6b12a5d1..05e22148e495 100644
--- a/src/netdev.c
+++ b/src/netdev.c
@@ -4867,6 +4867,43 @@ static int netdev_cqm_rssi_update(struct netdev *netdev)
 	return 0;
 }
 
+static void netdev_set_interface_event(struct l_genl_msg *msg,
+							struct netdev *netdev)
+{
+	uint32_t iftype;
+
+	if (nl80211_parse_attrs(msg, NL80211_ATTR_IFTYPE, &iftype,
+					NL80211_ATTR_UNSPEC) < 0)
+		return;
+
+	if (iftype == netdev->type)
+		return;
+
+	l_debug("Interface type changed from %s to %s",
+			netdev_iftype_to_string(netdev->type),
+			netdev_iftype_to_string(iftype));
+	netdev->type = iftype;
+
+	/* Set RSSI threshold for CQM notifications */
+	if (netdev->type == NL80211_IFTYPE_STATION)
+		netdev_cqm_rssi_update(netdev);
+}
+
+static void netdev_config_notify(struct l_genl_msg *msg, void *user_data)
+{
+	struct netdev *netdev;
+
+	netdev = netdev_from_message(msg);
+	if (!netdev)
+		return;
+
+	switch (l_genl_msg_get_command(msg)) {
+	case NL80211_CMD_SET_INTERFACE:
+		netdev_set_interface_event(msg, netdev);
+		break;
+	}
+}
+
 static struct l_genl_msg *netdev_build_cmd_set_interface(struct netdev *netdev,
 							uint32_t iftype)
 {
@@ -4927,12 +4964,6 @@ static void netdev_set_iftype_cb(struct l_genl_msg *msg, void *user_data)
 	if (error != 0)
 		goto done;
 
-	netdev->type = req->pending_type;
-
-	/* Set RSSI threshold for CQM notifications */
-	if (netdev->type == NL80211_IFTYPE_STATION)
-		netdev_cqm_rssi_update(netdev);
-
 	/* If the netdev was down originally, we're done */
 	if (!req->bring_up)
 		goto done;
@@ -5635,6 +5666,10 @@ static int netdev_init(void)
 								NULL, NULL))
 		l_error("Registering for scan notifications failed");
 
+	if (!l_genl_family_register(nl80211, "config", netdev_config_notify,
+								NULL, NULL))
+		l_error("Registering for config notifications failed");
+
 	return 0;
 
 fail_netlink:
-- 
2.26.3

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2021-04-23 14:52 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH 3/8] netdev: Re-add frame watches on iftype change Denis Kenzior
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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.