All of lore.kernel.org
 help / color / mirror / Atom feed
From: Denis Kenzior <denkenz@gmail.com>
To: iwd@lists.01.org
Subject: [PATCH 6/8] rrm: Always create RRM state
Date: Tue, 20 Apr 2021 11:35:17 -0500	[thread overview]
Message-ID: <20210420163519.12375-6-denkenz@gmail.com> (raw)
In-Reply-To: <20210420163519.12375-1-denkenz@gmail.com>

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

Right now, RRM is created when a new netdev is detected and its iftype
is of type station.  That means that any devices that start their life
as any other iftype cannot be changed to a station and have RRM function
properly.  Fix that by always creating the RRM state regardless of the
initial iftype.
---
 src/rrm.c | 31 ++++++++++++++++++++-----------
 1 file changed, 20 insertions(+), 11 deletions(-)

diff --git a/src/rrm.c b/src/rrm.c
index 860691a6f258..71442abb105f 100644
--- a/src/rrm.c
+++ b/src/rrm.c
@@ -770,14 +770,20 @@ static void rrm_state_destroy(void *data)
 	l_free(rrm);
 }
 
-static void rrm_new_state(struct netdev *netdev)
+static void rrm_add_frame_watches(struct rrm_state *rrm)
 {
-	struct rrm_state *rrm;
-	uint16_t frame_type = 0x00d0;
-	uint8_t prefix[] = { 0x05, 0x00 };
+	static const uint16_t frame_type = 0x00d0;
+	static const uint8_t prefix[] = { 0x05, 0x00 };
 
-	if (netdev_get_iftype(netdev) != NETDEV_IFTYPE_STATION)
-		return;
+	l_debug("");
+
+	frame_watch_add(rrm->wdev_id, 0, frame_type, prefix, sizeof(prefix),
+					rrm_frame_watch_cb, rrm, NULL);
+}
+
+static struct rrm_state *rrm_new_state(struct netdev *netdev)
+{
+	struct rrm_state *rrm;
 
 	rrm = l_new(struct rrm_state, 1);
 
@@ -785,10 +791,9 @@ static void rrm_new_state(struct netdev *netdev)
 	rrm->ifindex = netdev_get_ifindex(netdev);
 	rrm->wdev_id = netdev_get_wdev_id(netdev);
 
-	frame_watch_add(rrm->wdev_id, 0, frame_type, prefix, sizeof(prefix),
-					rrm_frame_watch_cb, rrm, NULL);
-
 	l_queue_push_head(states, rrm);
+
+	return rrm;
 }
 
 static bool match_ifindex(const void *a, const void *b)
@@ -807,8 +812,12 @@ static void rrm_netdev_watch(struct netdev *netdev,
 
 	switch (event) {
 	case NETDEV_WATCH_EVENT_NEW:
-		rrm_new_state(netdev);
-		return;
+		rrm = rrm_new_state(netdev);
+
+		if (netdev_get_iftype(netdev) == NETDEV_IFTYPE_STATION)
+			rrm_add_frame_watches(rrm);
+
+		break;
 	case NETDEV_WATCH_EVENT_DEL:
 		/*
 		 * This event is triggered by the netdev being removed, which
-- 
2.26.3

  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 ` [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 ` Denis Kenzior [this message]
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-6-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 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.