All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Zaborowski <andrew.zaborowski@intel.com>
To: iwd@lists.01.org
Subject: [PATCH 4/9] ap: Expire client's leases on disconnect
Date: Mon, 23 Aug 2021 16:14:25 +0200	[thread overview]
Message-ID: <20210823141430.223543-4-andrew.zaborowski@intel.com> (raw)
In-Reply-To: <20210823141430.223543-1-andrew.zaborowski@intel.com>

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

If netconfig is enabled tell the DHCP server to expire any leases owned
by the client that is disconnecting by using l_dhcp_server_expire_by_mac
to return the IPs to the IP pool.  They're added to the expired list
so they'd only be used if there are no other addresses left in the pool
and can be reactivated if the client comes back before the address is
used by somebody else.

This should ensure that we're always able to offer an address to a new
client as long as there are fewer concurrent clients than addresses in
the configured subnet or IP range.
---
 src/ap.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/src/ap.c b/src/ap.c
index c4473c66..e91f8b00 100644
--- a/src/ap.c
+++ b/src/ap.c
@@ -268,6 +268,17 @@ static void ap_del_station(struct sta_state *sta, uint16_t reason,
 
 	ap_stop_handshake(sta);
 
+	/*
+	 * Expire any DHCP leases owned by this client when it disconnects to
+	 * make it harder for somebody to DoS the IP pool.  If the client
+	 * comes back and the lease is still in the expired leases list they
+	 * will get their IP back.
+	 */
+	if (ap->netconfig_dhcp) {
+		sta->ip_alloc_lease = NULL;
+		l_dhcp_server_expire_by_mac(ap->netconfig_dhcp, sta->addr);
+	}
+
 	/*
 	 * If the event handler tears the AP down, we've made sure above that
 	 * a subsequent ap_sta_free(sta) has no need to access sta->ap.
-- 
2.30.2

  parent reply	other threads:[~2021-08-23 14:14 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-23 14:14 [PATCH 1/9] handshake: Add HANDSHAKE_EVENT_P2P_IP_REQUEST Andrew Zaborowski
2021-08-23 14:14 ` [PATCH 2/9] ap: Implement P2P GO-side 4-way handshake IP Allocation Andrew Zaborowski
2021-08-23 14:14 ` [PATCH 3/9] autotests: Test GO-side IP Allocation in testP2P Andrew Zaborowski
2021-08-23 14:14 ` Andrew Zaborowski [this message]
2021-08-23 14:14 ` [PATCH 5/9] ie: Add FILS IP Address Assignment parsers and builders Andrew Zaborowski
2021-08-25 13:47   ` Denis Kenzior
2021-08-25 21:34     ` Andrew Zaborowski
2021-08-23 14:14 ` [PATCH 6/9] ap: Support FILS IP Address Assignment IE Andrew Zaborowski
2021-08-23 14:14 ` [PATCH 7/9] netconfig: Move loading settings to new method, refactor Andrew Zaborowski
2021-08-25 13:50   ` Denis Kenzior
2021-08-25 22:17     ` Andrew Zaborowski
2021-08-25 22:37       ` Denis Kenzior
2021-08-25 22:56         ` Andrew Zaborowski
2021-08-23 14:14 ` [PATCH 8/9] netconfig: FILS IP assigment API Andrew Zaborowski
2021-08-23 14:14 ` [PATCH 9/9] station, netdev: Enable FILS IP Address Assignment Andrew Zaborowski

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=20210823141430.223543-4-andrew.zaborowski@intel.com \
    --to=andrew.zaborowski@intel.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.