From: James Prestwood <prestwoj@gmail.com>
To: iwd@lists.linux.dev
Cc: James Prestwood <prestwoj@gmail.com>
Subject: [PATCH] blacklist: allow configuration to disable the blacklist
Date: Wed, 26 Feb 2025 10:55:48 -0800 [thread overview]
Message-ID: <20250226185548.49127-1-prestwoj@gmail.com> (raw)
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
next reply other threads:[~2025-02-26 18:55 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-26 18:55 James Prestwood [this message]
2025-03-04 14:44 ` [PATCH] blacklist: allow configuration to disable the blacklist 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=20250226185548.49127-1-prestwoj@gmail.com \
--to=prestwoj@gmail.com \
--cc=iwd@lists.linux.dev \
/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.