From: Denis Kenzior <denkenz@gmail.com>
To: James Prestwood <prestwoj@gmail.com>, iwd@lists.linux.dev
Subject: Re: [PATCH v2 3/4] ap: support PTK rekeys
Date: Fri, 13 Jan 2023 09:35:09 -0600 [thread overview]
Message-ID: <a67db660-276a-ef41-179e-bb12e7602409@gmail.com> (raw)
In-Reply-To: <20230112193212.568476-3-prestwoj@gmail.com>
Hi James,
On 1/12/23 13:32, James Prestwood wrote:
> This adds support for rekeys to AP mode. A single timer is used and
> reset to the next station needing a rekey. A default rekey timer of
> 600 seconds is used unless the profile sets a timeout.
> ---
> src/ap.c | 114 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 114 insertions(+)
>
<snip>
> @@ -439,6 +452,89 @@ static void ap_del_station(struct sta_state *sta, uint16_t reason,
>
> ap_event_done(ap, prev);
> }
> +
> + ap_reset_rekey_timeout(ap);
Shouldn't you be cleaning up the timeout here?
> +}
> +
> +static void ap_start_rekey(struct ap_state *ap, struct sta_state *sta)
> +{
> + l_debug("Rekey STA "MAC, MAC_STR(sta->addr));
> +
> + eapol_start(sta->sm);
> +}
> +
> +static void ap_rekey_timeout(struct l_timeout *timeout, void *user_data)
> +{
> + struct ap_state *ap = user_data;
> +
> + l_timeout_remove(timeout);
> +
> + ap_reset_rekey_timeout(ap);
> +}
> +
> +/*
> + * Used to initiate any rekeys which are due and reset the rekey timer to the
> + * next soonest station needing a rekey.
> + *
> + * TODO: Could adapt this to also take into account the next GTK rekey and
> + * service that as well. But GTK rekeys are not yet supported in AP mode.
> + */
> +static void ap_reset_rekey_timeout(struct ap_state *ap)
> +{
> + const struct l_queue_entry *e;
> + uint64_t now = l_time_now();
> + uint64_t next = 0;
> +
> + if (!ap->rekey_time)
> + return;
> +
> + /* Find the station(s) that need a rekey and start it */
> + for (e = l_queue_get_entries(ap->sta_states); e; e = e->next) {
> + struct sta_state *sta = e->data;
> +
> + if (!sta->associated || !sta->rsna)
> + continue;
Would checking sta->rekey_time == 0 also be worthwhile? For stas that haven't
authenticated yet?
> +
> + if (l_time_before(now, sta->rekey_time)) {
> + uint64_t diff = l_time_diff(now, sta->rekey_time);
> +
> + /* Finding the next rekey time */
> + if (next < diff)
> + next = diff;
> +
> + continue;
Ok, so you try to find the next soonest (absolute) rekey_time to schedule the
next timeout. Might be easier to just set next to ~0 and loop over the stations
using l_time_before(sta->rekey_time, next), setting next as needed.
> + }
> +
> + ap_start_rekey(ap, sta);
And looks like this starts a rekey for any stations that we somehow missed? How
does this happen?
> + }
> +
> + /*
> + * Set the next rekey to the station needing it the soonest, or NULL
> + * if a single station and wait until the rekey is complete to reset
> + * the timer.
> + */
> + if (next)
> + ap->rekey_timeout = l_timeout_create(l_time_to_secs(next),
> + ap_rekey_timeout, ap, NULL);
> + else
> + ap->rekey_timeout = NULL;
Are you sure the rekey_timeout is destroyed here?
Might be easier to use l_timeout_modify instead of creating/destroying it all
the time?
> +}
> +
Regards,
-Denis
next prev parent reply other threads:[~2023-01-13 15:55 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-12 19:32 [PATCH v2 1/4] eapol: implement rekey support for authenticator James Prestwood
2023-01-12 19:32 ` [PATCH v2 2/4] eapol: detect message 2/4 retransmits James Prestwood
2023-01-13 15:16 ` Denis Kenzior
2023-01-12 19:32 ` [PATCH v2 3/4] ap: support PTK rekeys James Prestwood
2023-01-13 15:35 ` Denis Kenzior [this message]
2023-01-12 19:32 ` [PATCH v2 4/4] doc: Document RekeyTimeout for AP profiles James Prestwood
2023-01-13 15:19 ` Denis Kenzior
2023-01-13 15:13 ` [PATCH v2 1/4] eapol: implement rekey support for authenticator 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=a67db660-276a-ef41-179e-bb12e7602409@gmail.com \
--to=denkenz@gmail.com \
--cc=iwd@lists.linux.dev \
--cc=prestwoj@gmail.com \
/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.