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

2022-04-10 Thread Geert Stappers via Dnsmasq-discuss
On Sun, Apr 10, 2022 at 02:54:38PM +0300, Серж ИвановЪ wrote:
> пт, 8 апр. 2022 г. в 17:55, Серж ИвановЪ :
> > пт, 8 апр. 2022 г. в 17:46, Geert Stappers :
> >> On Fri, Apr 08, 2022 at 04:34:11PM +0300, Серж ИвановЪ wrote:
> >> > I am talking about this part of code in src/dhcp.c
> >> > ```
> >> > 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)/
> >> >((float)PING_WAIT)));
> >> > ```
> >> >
> >> > 0.6 should be configurable via compile-time constants, not hard-coded
> >>
> >> That should be expressed as a patch.
> >>

> From d93e601e5d02221ae8a82770aa8771c8c0700beb Mon Sep 17 00:00:00 2001
> From: s3rj1k 
> Date: Sun, 10 Apr 2022 14:40:27 +0300
> Subject: [PATCH] Add PING_CHECKS_THRESHOLD compile-time variable
> 
> Signed-off-by: s3rj1k 
> ---
>  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

FWIW:  I can't tell if that 60% is very same as the 0.6,
   but this patch does make that connection / relation.

>   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)


Groeten
Geert Stappers
-- 
Silence is hard to parse

___
Dnsmasq-discuss mailing list
Dnsmasq-discuss@lists.thekelleys.org.uk
https://lists.thekelleys.org.uk/cgi-bin/mailman/listinfo/dnsmasq-discuss


[Dnsmasq-discuss] [PATCH] Log upstream port for dnssec-retry

2022-04-10 Thread Dominik Derigs
Dear Simon et al.,

The current version of dnsmasq logs the upstream port like

> Feb 21 22:02:18 dnsmasq[8991]: dnssec-query[DS] microsoft.net
to 127.0.0.1#5053

when sending queries upstream. However, it is missing for dnssec-
retry like

> Feb 21 22:02:18 dnsmasq[8991]: dnssec-retry[DS] microsoft.net
to 127.0.0.1

This is added by this patch implementing it in the same way as
used already when logging "dnssec-query" in the code.

Best,
Dominik
From 00b8789e4119a25da7f286ca1cefd5fe66383b30 Mon Sep 17 00:00:00 2001
From: Dominik Derigs 
Date: Sat, 2 Apr 2022 21:45:47 +0200
Subject: [PATCH] Also log upstream port for dnssec-retry

Signed-off-by: DL6ER 
---
 src/forward.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/forward.c b/src/forward.c
index c17541b..b522c1f 100644
--- a/src/forward.c
+++ b/src/forward.c
@@ -527,8 +527,8 @@ static int forward_query(int udpfd, union mysockaddr *udpaddr,
 		}
 #ifdef HAVE_DNSSEC
 	  else
-		log_query_mysockaddr(F_NOEXTRA | F_DNSSEC, daemon->namebuff, &srv->addr,
- "dnssec-retry", (forward->flags & FREC_DNSKEY_QUERY) ? T_DNSKEY : T_DS);
+		log_query_mysockaddr(F_NOEXTRA | F_DNSSEC | F_SERVER, daemon->namebuff, &srv->addr,
+ (forward->flags & FREC_DNSKEY_QUERY) ? "dnssec-retry[DNSKEY]" : "dnssec-retry[DS]", 0);
 #endif
 
 	  srv->queries++;
-- 
2.25.1

___
Dnsmasq-discuss mailing list
Dnsmasq-discuss@lists.thekelleys.org.uk
https://lists.thekelleys.org.uk/cgi-bin/mailman/listinfo/dnsmasq-discuss