public inbox for iwd@lists.linux.dev
 help / color / mirror / Atom feed
* [PATCH] blacklist: allow configuration to disable the blacklist
@ 2025-02-26 18:55 James Prestwood
  2025-03-04 14:44 ` Denis Kenzior
  0 siblings, 1 reply; 2+ messages in thread
From: James Prestwood @ 2025-02-26 18:55 UTC (permalink / raw)
  To: iwd; +Cc: James Prestwood

Certain use cases may not need or want this feature so allowing it to
be disabled is a much cleaner way than doing something like setting
the timeouts very low.

Now [Blacklist].InitialTimeout can be set to zero which will prevent
any blacklisting.

In addition some other small changes were added:
 - Warn if the multiplier is 0, and set to 1 if so.
 - Warn if the initial timeout exceeds the maximum timeout.
 - Log if the blacklist is disabled
 - Use L_USEC_PER_SEC instead of magic numbers.
---
 src/blacklist.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/src/blacklist.c b/src/blacklist.c
index 04e4b8e3..21f85a75 100644
--- a/src/blacklist.c
+++ b/src/blacklist.c
@@ -91,6 +91,9 @@ void blacklist_add_bss(const uint8_t *addr)
 {
 	struct blacklist_entry *entry;
 
+	if (!blacklist_initial_timeout)
+		return;
+
 	blacklist_prune();
 
 	entry = l_queue_find(blacklist, match_addr, addr);
@@ -162,19 +165,31 @@ static int blacklist_init(void)
 		blacklist_initial_timeout = BLACKLIST_DEFAULT_TIMEOUT;
 
 	/* For easier user configuration the timeout values are in seconds */
-	blacklist_initial_timeout *= 1000000;
+	blacklist_initial_timeout *= L_USEC_PER_SEC;
 
 	if (!l_settings_get_uint64(config, "Blacklist",
 					"Multiplier",
 					&blacklist_multiplier))
 		blacklist_multiplier = BLACKLIST_DEFAULT_MULTIPLIER;
 
+	if (blacklist_multiplier == 0) {
+		l_warn("[Blacklist].Multiplier cannot be zero, setting to 1");
+		blacklist_multiplier = 1;
+	}
+
 	if (!l_settings_get_uint64(config, "Blacklist",
 					"MaximumTimeout",
 					&blacklist_max_timeout))
 		blacklist_max_timeout = BLACKLIST_DEFAULT_MAX_TIMEOUT;
 
-	blacklist_max_timeout *= 1000000;
+	blacklist_max_timeout *= L_USEC_PER_SEC;
+
+	if (blacklist_initial_timeout > blacklist_max_timeout)
+		l_warn("[Blacklist].InitialTimeout exceeded "
+			"[Blacklist].MaximumTimeout!");
+
+	if (!blacklist_initial_timeout)
+		l_debug("initial timeout was zero, blacklist will be disabled");
 
 	blacklist = l_queue_new();
 
-- 
2.34.1


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

* Re: [PATCH] blacklist: allow configuration to disable the blacklist
  2025-02-26 18:55 [PATCH] blacklist: allow configuration to disable the blacklist James Prestwood
@ 2025-03-04 14:44 ` Denis Kenzior
  0 siblings, 0 replies; 2+ messages in thread
From: Denis Kenzior @ 2025-03-04 14:44 UTC (permalink / raw)
  To: James Prestwood, iwd

On 2/26/25 12:55 PM, James Prestwood wrote:
> Certain use cases may not need or want this feature so allowing it to
> be disabled is a much cleaner way than doing something like setting
> the timeouts very low.
> 
> Now [Blacklist].InitialTimeout can be set to zero which will prevent
> any blacklisting.
> 
> In addition some other small changes were added:
>   - Warn if the multiplier is 0, and set to 1 if so.
>   - Warn if the initial timeout exceeds the maximum timeout.
>   - Log if the blacklist is disabled
>   - Use L_USEC_PER_SEC instead of magic numbers.
> ---
>   src/blacklist.c | 19 +++++++++++++++++--
>   1 file changed, 17 insertions(+), 2 deletions(-)
> 

Applied, thanks.

Regards,
-Denis

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

end of thread, other threads:[~2025-03-04 14:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-26 18:55 [PATCH] blacklist: allow configuration to disable the blacklist James Prestwood
2025-03-04 14:44 ` Denis Kenzior

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox