[Dnsmasq-discuss] Make HighLoad constant value configurable from config.h

Geert Stappers stappers at stappers.nl
Sun Sep 18 15:17:49 UTC 2022


On Sun, Sep 18, 2022 at 05:03:10PM +0300, Серж ИвановЪ wrote:
> Just to bump this one up as a pending patch for next release

URL to the patch http://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/attachments/20220410/61f66c1b/attachment.bin
found in https://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/2022q2/016293.html

However
<screenshot>
$ LANG=C wget -O /dev/null -S http://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/attachments/20220410/61f66c1b/attachment.bin
--2022-09-18 17:16:30--  http://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/attachments/20220410/61f66c1b/attachment.bin
Resolving lists.thekelleys.org.uk (lists.thekelleys.org.uk)... 2001:ba8:1f1:f049::2, 85.119.82.65
Connecting to lists.thekelleys.org.uk (lists.thekelleys.org.uk)|2001:ba8:1f1:f049::2|:80... connected.
HTTP request sent, awaiting response...
  HTTP/1.1 301 Moved Permanently
  Date: Sun, 18 Sep 2022 15:16:30 GMT
  Server: Apache/2.4.38 (Debian)
  Location: https://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/attachments/20220410/61f66c1b/attachment.bin
  Content-Length: 399
  Keep-Alive: timeout=5, max=100
  Connection: Keep-Alive
  Content-Type: text/html; charset=iso-8859-1
Location: https://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/attachments/20220410/61f66c1b/attachment.bin [following]
--2022-09-18 17:16:30--  https://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/attachments/20220410/61f66c1b/attachment.bin
Connecting to lists.thekelleys.org.uk (lists.thekelleys.org.uk)|2001:ba8:1f1:f049::2|:443... connected.
ERROR: The certificate of 'lists.thekelleys.org.uk' is not trusted.
ERROR: The certificate of 'lists.thekelleys.org.uk' has expired.
$
</screenshot>


So in the retry:

$ wget -O - --no-check-certificate --quiet https://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/attachments/20220410/61f66c1b/attachment.bin
>From d93e601e5d02221ae8a82770aa8771c8c0700beb Mon Sep 17 00:00:00 2001
From: s3rj1k <evasive.gyron at gmail.com>
Date: Sun, 10 Apr 2022 14:40:27 +0300
Subject: [PATCH] Add PING_CHECKS_THRESHOLD compile-time variable

Signed-off-by: s3rj1k <evasive.gyron at gmail.com>
---
 src/config.h | 1 +
 src/dhcp.c   | 4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/config.h b/src/config.h
index cd37900..75c5d05 100644
--- a/src/config.h
+++ b/src/config.h
@@ -35,6 +35,7 @@
 #define MAXLEASES 1000 /* maximum number of DHCP leases */
 #define PING_WAIT 3 /* wait for ping address-in-use test */
 #define PING_CACHE_TIME 30 /* Ping test assumed to be valid this long. */
+#define PING_CHECKS_THRESHOLD 60 /* threshold percent of possible ping checks in the last PING_CACHE_TIME */
 #define DECLINE_BACKOFF 600 /* disable DECLINEd static addresses for this long */
 #define DHCP_PACKET_MAX 16384 /* hard limit on DHCP packet size */
 #define SMALLDNAME 50 /* most domain names are smaller than this */
diff --git a/src/dhcp.c b/src/dhcp.c
index 6104c87..3187e3f 100644
--- a/src/dhcp.c
+++ b/src/dhcp.c
@@ -723,14 +723,14 @@ struct ping_result *do_icmp_ping(time_t now, struct in_addr addr, unsigned int h
 {
   static struct ping_result dummy;
   struct ping_result *r, *victim = NULL;
-  int count, max = (int)(0.6 * (((float)PING_CACHE_TIME)/
+  int count, max = (int)(((float)PING_CHECKS_THRESHOLD / 100) * (((float)PING_CACHE_TIME)/
 				((float)PING_WAIT)));
 
   /* check if we failed to ping addr sometime in the last
      PING_CACHE_TIME seconds. If so, assume the same situation still exists.
      This avoids problems when a stupid client bangs
      on us repeatedly. As a final check, if we did more
-     than 60% of the possible ping checks in the last 
+     than PING_CHECKS_THRESHOLD% of the possible ping checks in the last
      PING_CACHE_TIME, we are in high-load mode, so don't do any more. */
   for (count = 0, r = daemon->ping_results; r; r = r->next)
     if (difftime(now, r->time) >  (float)PING_CACHE_TIME)
-- 
2.35.1
$



More information about the Dnsmasq-discuss mailing list