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

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

In the case that a netdev is powered down, or an interface type change
occurs, the station object will be removed and any watches will be
freed.

Since rrm is created when the netdev is created and persists across
iftype and power up/down changes, it should provide a destroy callback
to station_add_state_watch so that it can be notified when the watch is
removed.
---
 src/rrm.c | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)

diff --git a/src/rrm.c b/src/rrm.c
index f41bc907703b..860691a6f258 100644
--- a/src/rrm.c
+++ b/src/rrm.c
@@ -117,6 +117,7 @@ struct rrm_beacon_req_info {
 /* Per-netdev state */
 struct rrm_state {
 	struct station *station;
+	uint32_t watch_id;
 	uint32_t ifindex;
 	uint64_t wdev_id;
 	struct rrm_request_info *pending;
@@ -662,6 +663,17 @@ static void rrm_station_watch_cb(enum station_state state, void *userdata)
 	}
 }
 
+static void rrm_station_watch_destroy(void *user_data)
+{
+	struct rrm_state *rrm = user_data;
+
+	l_debug("");
+
+	rrm_cancel_pending(rrm);
+	rrm->watch_id = 0;
+	rrm->station = NULL;
+}
+
 static void rrm_frame_watch_cb(const struct mmpdu_header *mpdu,
 				const void *body, size_t body_len,
 				int rssi, void *user_data)
@@ -684,8 +696,9 @@ static void rrm_frame_watch_cb(const struct mmpdu_header *mpdu,
 			return;
 		}
 
-		station_add_state_watch(rrm->station, rrm_station_watch_cb,
-						rrm, NULL);
+		rrm->watch_id = station_add_state_watch(rrm->station,
+						rrm_station_watch_cb, rrm,
+						rrm_station_watch_destroy);
 	}
 
 	/*
@@ -806,7 +819,10 @@ static void rrm_netdev_watch(struct netdev *netdev,
 		rrm = l_queue_remove_if(states, match_ifindex,
 						L_UINT_TO_PTR(ifindex));
 		if (rrm) {
-			rrm_cancel_pending(rrm);
+			if (rrm->station && rrm->watch_id)
+				station_remove_state_watch(rrm->station,
+								rrm->watch_id);
+
 			l_free(rrm);
 		}
 
-- 
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 ` Denis Kenzior [this message]
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-4-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.