dnsmasq.git
2 years agoUse a simpler arrangement for the all_addr union to avoid
Simon Kelley [Sat, 1 Apr 2023 20:35:26 +0000 (21:35 +0100)]
Use a simpler arrangement for the all_addr union to avoid
the compiler padding it with an extra 8 bytes.

Use the F_KEYTAG flag in a a cache record to discriminate between
an arbitrary RR stored entirely in the addr union and one
which has a point to block storage.

2 years agoFix copy-n-paste error in 138e1e2a2d918b37cb0274fe310d53be35acf4cf
Simon Kelley [Fri, 31 Mar 2023 23:50:29 +0000 (00:50 +0100)]
Fix copy-n-paste error in 138e1e2a2d918b37cb0274fe310d53be35acf4cf

2 years ago--domain=# is valid. --synth-domain=# isn't.
Simon Kelley [Fri, 31 Mar 2023 22:28:56 +0000 (23:28 +0100)]
--domain=# is valid. --synth-domain=# isn't.

2 years agoAllow --cache-rr=ANY with the obvious meaning.
Simon Kelley [Fri, 31 Mar 2023 17:49:22 +0000 (18:49 +0100)]
Allow --cache-rr=ANY with the obvious meaning.

2 years agoOptimse memory use for arbitrary-RR caching.
Simon Kelley [Fri, 31 Mar 2023 16:44:02 +0000 (17:44 +0100)]
Optimse memory use for arbitrary-RR caching.

RRs 13 bytes or less don't need to allocate block storage.

2 years agoOptimise no-action case in rrfilter().
Simon Kelley [Thu, 30 Mar 2023 15:00:04 +0000 (16:00 +0100)]
Optimise no-action case in rrfilter().

2 years agoAdd filtering of arbitrary RR-types.
Simon Kelley [Wed, 29 Mar 2023 21:43:21 +0000 (22:43 +0100)]
Add filtering of arbitrary RR-types.

2 years agoRemove code for caching SRV.
Simon Kelley [Tue, 28 Mar 2023 17:24:22 +0000 (18:24 +0100)]
Remove code for caching SRV.

Function replaced by the ability to cache any RR type.

For backwards compatibilty SRV records are always on the
list of cacheable RR-types.

2 years agoAdd --cache-rr to enable caching of arbitrary RR types.
Simon Kelley [Thu, 23 Mar 2023 17:15:35 +0000 (17:15 +0000)]
Add --cache-rr to enable caching of arbitrary RR types.

2 years agoFold F_NOERR and F_DNSSEC to make space for new F_RR.
Simon Kelley [Mon, 20 Mar 2023 23:11:38 +0000 (23:11 +0000)]
Fold F_NOERR and F_DNSSEC to make space for new F_RR.

2 years agoMerge branch 'master' into all-rr-type
Simon Kelley [Mon, 20 Mar 2023 22:30:11 +0000 (22:30 +0000)]
Merge branch 'master' into all-rr-type

2 years agoClose Debian bug.
Simon Kelley [Mon, 20 Mar 2023 22:22:46 +0000 (22:22 +0000)]
Close Debian bug.

2 years agoAdd EDE "filtered" extended error when --filter-A or --filter-AAAA act.
Simon Kelley [Mon, 20 Mar 2023 18:32:14 +0000 (18:32 +0000)]
Add EDE "filtered" extended error when --filter-A or --filter-AAAA act.

If a NODATA answer is returned instead of actual data for A or AAAA
queries because of the existence of --filter-A or --filter-AAAA
config options, then mark the replies with an EDE "filtered" tag.

Basic patch by Petr Menšík, tweaked by Simon Kelley to apply onto
the preceding caching patches.

2 years agoMore --filter-AAAA caching improvements.
Simon Kelley [Mon, 20 Mar 2023 17:14:17 +0000 (17:14 +0000)]
More --filter-AAAA caching improvements.

Cache answers before filtering and filter coming out of the cache.

2 years agoImprove cache use with --filter-A and --filter-AAAA
Simon Kelley [Mon, 20 Mar 2023 15:16:29 +0000 (15:16 +0000)]
Improve cache use with --filter-A and --filter-AAAA

If --filter-AAAA is set and we have cached entry for
the domain in question fpr any RR type that allows us to
return a NODATA reply when --filter-AAAA is set without
going upstream. Similarly for --filter-A.

2 years agoRemove limitation on --dynamic-host.
Simon Kelley [Thu, 16 Mar 2023 15:16:17 +0000 (15:16 +0000)]
Remove limitation on --dynamic-host.

Dynamic-host was implemented to ignore interface addresses with /32
(or /128 for IPv6) prefix lengths, since they are not useful for
synthesising addresses.

Due to a bug before 2.88, this didn't work for IPv4, and some have
used --dynamic-host=example.com,0.0.0.0,eth0 to do the equivalent of
--interface-name for such interfaces. When the bug was fixed in 2.88
these uses broke.

Since this behaviour seems to violate the principle of least surprise,
and since the 2.88 fix is breaking existing imstallations, this
commit removes the check on /32 and /128 prefix lengths to solve both
problems.

2 years agoFix DHCPv6 "use multicast" response which previously failed
Simon Kelley [Wed, 15 Mar 2023 21:12:55 +0000 (21:12 +0000)]
Fix DHCPv6 "use multicast" response which previously failed
to set the message type correctly.

Thanks to Petr Menšík for spotting the problem.

2 years agoAllow configuring filter-A/AAAA via dbus.
Clayton Craft [Wed, 8 Mar 2023 15:35:05 +0000 (15:35 +0000)]
Allow configuring filter-A/AAAA via dbus.

2 years agoGeneralise cached NXDOMAIN replies.
Simon Kelley [Tue, 7 Mar 2023 22:46:44 +0000 (22:46 +0000)]
Generalise cached NXDOMAIN replies.

We can cache an NXDOMAIN reply to a query for any RRTYPE
and reply from a cached NXDOMAIN to any RRTYPE.

2 years agoSet the default maximum DNS UDP packet size to 1232.
Simon Kelley [Tue, 7 Mar 2023 22:07:46 +0000 (22:07 +0000)]
Set the default maximum DNS UDP packet size to 1232.

http://www.dnsflagday.net/2020/ refers.

Thanks to Xiang Li for the prompt.

2 years agoBump version in Debian changelog.
Simon Kelley [Mon, 6 Mar 2023 23:30:36 +0000 (23:30 +0000)]
Bump version in Debian changelog.

2 years agoFix possible SEGV when no servers defined.
Simon Kelley [Mon, 6 Mar 2023 23:00:58 +0000 (23:00 +0000)]
Fix possible SEGV when no servers defined.

If there exists a --address=/<domain>/  or --server=/<domain>/#
configuration but no upstream server config unqualified by
domain then when a query which doesnt match the domain is
recieved it will use the qualfied server config and in the process
possibly make an out-of-bounds memory access.

Thanks to Daniel Danzberger for spotting the bug.

2 years agoFix --rev-server option. It was broken in 1db9943c6879c160a5fbef885d5ceadd3668b74d...
Dominik Derigs [Fri, 3 Mar 2023 17:05:26 +0000 (18:05 +0100)]
Fix --rev-server option. It was broken in 1db9943c6879c160a5fbef885d5ceadd3668b74d when resolving upstream servers by name was extended to --rev-server without accounting for the fact that re-using one and the same upstream server for each of the x.y.z.in-addr.arpa is actually a wanted feature

Signed-off-by: DL6ER <dl6er@dl6er.de>
2 years agoDocument suppressing deafult options in --dhcp-option.
Simon Kelley [Mon, 6 Mar 2023 13:06:03 +0000 (13:06 +0000)]
Document suppressing deafult options in --dhcp-option.

2 years agoAvoid undefined behaviour with the ctype(3) functions.
Taylor R Campbell [Sat, 25 Feb 2023 15:00:30 +0000 (15:00 +0000)]
Avoid undefined behaviour with the ctype(3) functions.

As defined in the C standard:

In all cases the argument is an int, the value of which shall
be representable as an unsigned char or shall equal the value
of the macro EOF.  If the argument has any other value, the
behavior is undefined.

This is because they're designed to work with the int values returned
by getc or fgetc; they need extra work to handle a char value.

If EOF is -1 (as it almost always is), with 8-bit bytes, the allowed
inputs to the ctype(3) functions are:

{-1, 0, 1, 2, 3, ..., 255}.

However, on platforms where char is signed, such as x86 with the
usual ABI, code like

char *arg = ...;
... isspace(*arg) ...

may pass in values in the range:

{-128, -127, -126, ..., -2, -1, 0, 1, ..., 127}.

This has two problems:

1. Inputs in the set {-128, -127, -126, ..., -2} are forbidden.

2. The non-EOF byte 0xff is conflated with the value EOF = -1, so
   even though the input is not forbidden, it may give the wrong
   answer.

Casting char to int first before passing the result to ctype(3)
doesn't help: inputs like -128 are unchanged by this cast.  It is
necessary to cast char inputs to unsigned char first; you can then
cast to int if you like but there's no need because the functions
will always convert the argument to int by definition.  So the above
fragment needs to be:

char *arg = ...;
... isspace((unsigned char)*arg) ...

This patch inserts unsigned char casts where necessary, and changes
int casts to unsigned char casts where the input is char.

I left alone int casts where the input is unsigned char already --
they're not immediately harmful, although they would have the effect
of suppressing some compiler warnings if the input is ever changed to
be char instead of unsigned char, so it might be better to remove
those casts too.

I also left alone calls where the input is int to begin with because
it came from getc; casting to unsigned char here would be wrong, of
course.

2 years agoReplace dead link in dnsmasq.conf.example. v2.89
Simon Kelley [Thu, 2 Feb 2023 20:20:13 +0000 (20:20 +0000)]
Replace dead link in dnsmasq.conf.example.

Thanks to Timo van Roermund for spotting this.

2 years agoReplace dead link in dnsmasq.conf.example.
Simon Kelley [Thu, 2 Feb 2023 20:20:13 +0000 (20:20 +0000)]
Replace dead link in dnsmasq.conf.example.

Thanks to Timo van Roermund for spotting this.

2 years agoAdd --no-ident option. v2.89test1
Dominik Derigs [Mon, 23 Jan 2023 22:48:01 +0000 (22:48 +0000)]
Add --no-ident option.

2 years agoAdd acknowledgements to CHANGELOG for the 2.88 AWS efforts.
Simon Kelley [Sat, 14 Jan 2023 11:12:17 +0000 (11:12 +0000)]
Add acknowledgements to CHANGELOG for the 2.88 AWS efforts.

2 years agoFix Changelog typos.
Simon Kelley [Sat, 14 Jan 2023 11:01:10 +0000 (11:01 +0000)]
Fix Changelog typos.

2 years agoBump version in Debian changelog.
Simon Kelley [Fri, 13 Jan 2023 22:03:33 +0000 (22:03 +0000)]
Bump version in Debian changelog.

2 years agoFix bug which can break the invariants on the order of a hash chain.
Simon Kelley [Wed, 11 Jan 2023 23:23:40 +0000 (23:23 +0000)]
Fix bug which can break the invariants on the order of a hash chain.

If there are multiple cache records with the same name but different
F_REVERSE and/or F_IMMORTAL flags, the code added in fe9a134b could
concievable break the REVERSE-FORWARD-IMMORTAL order invariant.

Reproducing this is damn near impossible, but it is responsible
for rare and otherwise inexplicable reversion between 2.87 and 2.88
which manifests itself as a cache internal error. All observed
cases have depended on DNSSEC being enabled, but the bug could in
theory manifest itself without DNSSEC

Thanks to Timo van Roermund for reporting the bug and huge
efforts to isolate it.

2 years agoFix cosmetic big in dump_cache_entry()
Simon Kelley [Wed, 4 Jan 2023 23:10:07 +0000 (23:10 +0000)]
Fix cosmetic big in dump_cache_entry()

2 years agoLog all cache internal errors.
Simon Kelley [Mon, 2 Jan 2023 22:17:57 +0000 (22:17 +0000)]
Log all cache internal errors.

2 years agoIf we hit a cache internal error, log the entry we failed to remove.
Simon Kelley [Thu, 22 Dec 2022 23:19:05 +0000 (23:19 +0000)]
If we hit a cache internal error, log the entry we failed to remove.

This is code which should never run, but if it does,
we now log information useful for debugging.

2 years agoAdd posix-timezone and tzdb-timezone DHCPv6 options. v2.88
Simon Kelley [Sun, 4 Dec 2022 22:00:54 +0000 (22:00 +0000)]
Add posix-timezone and tzdb-timezone DHCPv6 options.

They are already in place for DHCPv4.

2 years agoHandle malformed DNS replies better. v2.88rc5
Simon Kelley [Sat, 26 Nov 2022 22:19:29 +0000 (22:19 +0000)]
Handle malformed DNS replies better.

If we detect that that reply from usptream is malformed,
transform it into a SERVFAIL reply before sending to the
original requestor.

2 years agoFix warning in cache.c
Brad Smith [Sat, 26 Nov 2022 21:48:17 +0000 (21:48 +0000)]
Fix warning in cache.c

2 years agoMake max staleness of stale cache entries configurable and default to one day.
Dominik Derigs [Sat, 26 Nov 2022 21:18:34 +0000 (21:18 +0000)]
Make max staleness of stale cache entries configurable and default to one day.

2 years agoFix use-after-free in mark_servers()
Petr Menšík [Sat, 26 Nov 2022 18:49:21 +0000 (18:49 +0000)]
Fix use-after-free in mark_servers()

2 years agofixup! Handle DS records for unsupported crypto algorithms.
Petr Menšík [Tue, 22 Nov 2022 22:51:11 +0000 (22:51 +0000)]
fixup! Handle DS records for unsupported crypto algorithms.

2 years agoMerge i18n strings. v2.88rc4
Simon Kelley [Mon, 21 Nov 2022 16:56:51 +0000 (16:56 +0000)]
Merge i18n strings.

2 years agoAdd /etc/hosts gotcha to man page section for --dhcp-hosts.
Simon Kelley [Mon, 21 Nov 2022 16:53:56 +0000 (16:53 +0000)]
Add /etc/hosts gotcha to man page section for --dhcp-hosts.

2 years agoOptimise readng large number --server options at start up.
Simon Kelley [Mon, 21 Nov 2022 16:40:53 +0000 (16:40 +0000)]
Optimise readng large number --server options at start up.

When re-reading upstream servers from /etc/resolv.conf or other
sources that can change dnsmasq tries to avoid memory fragmentation by
re-using existing records that are being re-read unchanged. This
involves seaching all the server records for each new one installed.
During startup this search is pointless, and can cause long start
times with thousands of --server options because the work needed is
O(n^2). Handle this case more intelligently.  Thanks to Ye Zhou for
spotting the problem and an initial patch.

2 years agoFix CHANGELOG typos.
Matthias Andree [Fri, 18 Nov 2022 09:10:32 +0000 (09:10 +0000)]
Fix CHANGELOG typos.

2 years agoUpdate german translation for release 2.88.
Conrad Kostecki [Thu, 17 Nov 2022 20:00:42 +0000 (20:00 +0000)]
Update german translation for release 2.88.

2 years agoFix SEGV on --local= added by immediately previous commit. v2.88rc3
Simon Kelley [Thu, 17 Nov 2022 19:51:15 +0000 (19:51 +0000)]
Fix SEGV on --local= added by immediately previous commit.

2 years agoFix struct hostinfo free code and BSD compile. v2.88rc2
Simon Kelley [Thu, 17 Nov 2022 12:52:53 +0000 (12:52 +0000)]
Fix struct hostinfo free code and BSD compile.

The code added in6 c596f1cc1d92b2b90ef5ce043ace314eefa868b
fails to free the returned datastructures from gethostinfo()
because sdetails.hostinfo is used to loop through the addresses
and ends up NULL. In some libc implementations this results
in a SEGV when freeaddrinfo() is called.

Also fix FTBFS under BSD. Thanks to Johnny S. Lee for the bug report.

2 years agoHandle DS records for unsupported crypto algorithms correctly. v2.88rc1
Simon Kelley [Wed, 16 Nov 2022 16:49:30 +0000 (16:49 +0000)]
Handle DS records for unsupported crypto algorithms correctly.

Such a DS, as long as it is validated, should allow answers
in the domain is attests to be returned as unvalidated, and not
as a validation error.

2 years agoFix GOST signature algorithms for DNSSEC validation.
Simon Kelley [Wed, 16 Nov 2022 15:54:43 +0000 (15:54 +0000)]
Fix GOST signature algorithms for DNSSEC validation.

Use CryptoPro version of the hash function.
Handle the little-endian wire format of key data.
Get the wire order of S and R correct.

Note that Nettle version 3.6 or later is required for GOST support.

2 years agoHandle known DNSSEC signature algorithms which are not supported.
Simon Kelley [Sun, 13 Nov 2022 15:55:09 +0000 (15:55 +0000)]
Handle known DNSSEC signature algorithms which are not supported.

This fixes a confusion if certain algorithms are not supported
because the version is the crypto library is too old.  The validation
should be treated the same as for a completely unknown algorithm,
(ie return unverified answer) and not as a validation failure
(ie return SERVFAIL).

The algorithems affected are GOST and ED448.

2 years agoFix --server=/domain/# v2.88test3
Simon Kelley [Mon, 7 Nov 2022 23:24:31 +0000 (23:24 +0000)]
Fix --server=/domain/#

2 years agoFix --server with multiple domains.
Simon Kelley [Mon, 7 Nov 2022 23:14:30 +0000 (23:14 +0000)]
Fix --server with multiple domains.

2 years agoMake specifying nameservers by name work for DBus API.
Simon Kelley [Mon, 7 Nov 2022 23:00:34 +0000 (23:00 +0000)]
Make specifying nameservers by name work for DBus API.

2 years agoCall freeaddrinfo() in domain_rev[46]()
Simon Kelley [Mon, 7 Nov 2022 22:01:28 +0000 (22:01 +0000)]
Call freeaddrinfo() in domain_rev[46]()

2 years agoExtend specifying DNS servers by domain-name to --rev-server v2.88test2
Simon Kelley [Sun, 6 Nov 2022 20:56:43 +0000 (20:56 +0000)]
Extend specifying DNS servers by domain-name to --rev-server

Also Dbus SetDomainServers method.

Revert getaddrinfo hints.ai_socktype to SOCK_DGRAM to eliminate
duplicating every address three times for DGRAM, STREAM and RAW
in the results.

2 years agoFix breakage of --local=/domain.name/1.2.3.4 in immediately previous commit.
Simon Kelley [Sun, 6 Nov 2022 20:18:27 +0000 (20:18 +0000)]
Fix breakage of --local=/domain.name/1.2.3.4 in immediately previous commit.

2 years agoAllow domain names as well is IP addresses in --server options.
Dominik Derigs [Sat, 5 Nov 2022 11:49:52 +0000 (11:49 +0000)]
Allow domain names as well is IP addresses in --server options.

2 years agoBump Debian version and close bug.
Simon Kelley [Wed, 2 Nov 2022 22:17:20 +0000 (22:17 +0000)]
Bump Debian version and close bug.

2 years agoReconcile "names" and "address" counts when reading hostfiles.
Simon Kelley [Sun, 30 Oct 2022 15:40:20 +0000 (15:40 +0000)]
Reconcile "names" and "address" counts when reading hostfiles.

3 years agoInotify: make "flushed" log message more understandable.
Simon Kelley [Thu, 27 Oct 2022 12:14:45 +0000 (13:14 +0100)]
Inotify: make "flushed" log message more understandable.

Saying we've "flushed x outdated entries" is confusing, since
the count is the total number of entries in the modified file,
most of which are going to get added straight back when the file
is re-read.

The log now looks like

dnsmasq: inotify: /tmp/dir/1 (new or modified)
dnsmasq: inotify: flushed 1 addresses read from /tmp/dir/1
dnsmasq: read /tmp/dir/1 - 2 addresses

which hopefully make it more obvious that /tmp/dir/1 contained one
address before, and now contains two.

3 years agoDo not (try to) re-read deleted files inside a --hostsdir.
Dominik Derigs [Thu, 27 Oct 2022 11:36:38 +0000 (12:36 +0100)]
Do not (try to) re-read deleted files inside a --hostsdir.

3 years agoFix in dhcpv4 rapid-commit code.
Simon Kelley [Thu, 27 Oct 2022 11:04:58 +0000 (12:04 +0100)]
Fix in dhcpv4 rapid-commit code.

1) Cosmetic: don't log the tags twice.

2) Functional. If a host has an old lease for a different address,
   the rapid-commit will appear to work, but the old lease will
   not be removed and the new lease will not be recorded, so
   the client and server will have conflicting state, leading to
   problems later.

3 years agoAdd --no-round-robin option.
Simon Kelley [Tue, 18 Oct 2022 15:06:48 +0000 (16:06 +0100)]
Add --no-round-robin option.

3 years agoFix loss of DNS servers on config reload.
Simon Kelley [Mon, 17 Oct 2022 20:15:43 +0000 (21:15 +0100)]
Fix loss of DNS servers on config reload.

A bug, introduced in 2.87, which could result in DNS
servers being removed from the configuration when reloading
server configuration from DBus, or re-reading /etc/resolv.conf
Only servers from the same source should be replaced, but some
servers from other sources (ie hard coded or another dynamic source)
could mysteriously disappear.

3 years agoHandle multiple addresses when removing duplicates in host files.
Dominik Derigs [Sun, 16 Oct 2022 21:30:08 +0000 (22:30 +0100)]
Handle multiple addresses when removing duplicates in host files.

3 years agoEnhance --hostdir so that records are automatically removed when re-reading.
Dominik Derigs [Sun, 16 Oct 2022 21:08:45 +0000 (22:08 +0100)]
Enhance --hostdir so that records are automatically removed when re-reading.

Initial patch from Dominik Derigs, re-written by Simon Kelley.

3 years agoImprove logging of DNS record source from --hostsdir files.
Dominik Derigs [Sun, 16 Oct 2022 20:08:30 +0000 (21:08 +0100)]
Improve logging of DNS record source from --hostsdir files.

Patch author Dominik Derigs <dl6er@dl6er.de> with subsequent bugfixes
and tweaks from Simon Kelley.

3 years agoMove fast-dns-retry and use-stale-cache writeups in the CHANGELOG. v2.88test1
Simon Kelley [Fri, 14 Oct 2022 10:46:13 +0000 (11:46 +0100)]
Move fast-dns-retry and use-stale-cache writeups in the CHANGELOG.

These are 2.88 changes, but the branch merge put them unde 2.87.

3 years agoMerge branch 'aws'
Simon Kelley [Thu, 13 Oct 2022 14:37:52 +0000 (15:37 +0100)]
Merge branch 'aws'

3 years agoFix bug in --dynamic-host when interface has /16 IPv4 address.
Simon Kelley [Thu, 13 Oct 2022 14:02:54 +0000 (15:02 +0100)]
Fix bug in --dynamic-host when interface has /16 IPv4 address.

3 years agoAdd Georgian translation.
Temuri Doghonadze [Thu, 13 Oct 2022 13:33:01 +0000 (14:33 +0100)]
Add Georgian translation.

3 years agoFix Debian changelog date Fubar.
Simon Kelley [Sun, 25 Sep 2022 22:55:09 +0000 (23:55 +0100)]
Fix Debian changelog date Fubar.

3 years agoAdd ClearMetrics Dbus method. aws holly/aws origin/aws
Simon Kelley [Fri, 16 Sep 2022 11:58:41 +0000 (12:58 +0100)]
Add ClearMetrics Dbus method.

3 years agoOptimise cache code when stale caching in use.
Simon Kelley [Fri, 16 Sep 2022 11:07:01 +0000 (12:07 +0100)]
Optimise cache code when stale caching in use.

Exclude DNSSEC entries from stale caching.

3 years agoDon't exclude stale-cache answers from "local answered" metric.
Simon Kelley [Fri, 16 Sep 2022 08:35:44 +0000 (09:35 +0100)]
Don't exclude stale-cache answers from "local answered" metric.

3 years agoInitialise modified-moving-average latency calc better.
Simon Kelley [Thu, 15 Sep 2022 23:16:18 +0000 (00:16 +0100)]
Initialise modified-moving-average latency calc better.

Use the first value, rather than initialising at zero,
which takes many queries to converge.

3 years agoSplit failed queries in retries in stat counting.
Simon Kelley [Thu, 15 Sep 2022 23:07:36 +0000 (00:07 +0100)]
Split failed queries in retries in stat counting.

3 years agoTweak server-selection logic in the fast-retry case.
Simon Kelley [Thu, 15 Sep 2022 22:54:53 +0000 (23:54 +0100)]
Tweak server-selection logic in the fast-retry case.

3 years agoKeep a per-DNS-server moving average of query latency.
Simon Kelley [Thu, 15 Sep 2022 22:22:02 +0000 (23:22 +0100)]
Keep a per-DNS-server moving average of query latency.

3 years agoCombine server stats from all records for the same server in DBUS method.
Simon Kelley [Thu, 15 Sep 2022 21:43:08 +0000 (22:43 +0100)]
Combine server stats from all records for the same server in DBUS method.

The DBUS per-server stats method should combine the stats from
different records (for different domains) in the same way at the
logging code.

3 years agoCount NXDOMAIN replies from each server.
Simon Kelley [Thu, 15 Sep 2022 21:29:44 +0000 (22:29 +0100)]
Count NXDOMAIN replies from each server.

3 years agoAdd metric for queries which never see an answer.
Simon Kelley [Thu, 15 Sep 2022 21:06:39 +0000 (22:06 +0100)]
Add metric for queries which never see an answer.

3 years agoMake fast-retry more configurable and do exponential backoff.
Simon Kelley [Wed, 14 Sep 2022 15:16:08 +0000 (16:16 +0100)]
Make fast-retry more configurable and do exponential backoff.

3 years agoRemove unused vars.
Simon Kelley [Tue, 13 Sep 2022 08:36:08 +0000 (09:36 +0100)]
Remove unused vars.

3 years agoReturn EDE_STALE extended error when returning stale data from cache.
Simon Kelley [Mon, 12 Sep 2022 14:28:46 +0000 (15:28 +0100)]
Return EDE_STALE extended error when returning stale data from cache.

3 years agoAdd stale cache replies to metrics.
Simon Kelley [Mon, 12 Sep 2022 13:50:17 +0000 (14:50 +0100)]
Add stale cache replies to metrics.

3 years agoAdd GetServerMetrics method to DBus interface.
Simon Kelley [Mon, 12 Sep 2022 13:35:40 +0000 (14:35 +0100)]
Add GetServerMetrics method to DBus interface.

3 years agoFurther optimisation of --port-limit.
Simon Kelley [Fri, 9 Sep 2022 17:18:46 +0000 (18:18 +0100)]
Further optimisation of --port-limit.

No longer try and fail to open every port when the port range
is in complete use; go straight to re-using an existing socket.

Die at startup if port range is smaller than --port-limit, since
the code behaves badly in this case.

3 years agoSecond try at port-limit option.
Simon Kelley [Fri, 9 Sep 2022 16:09:32 +0000 (17:09 +0100)]
Second try at port-limit option.

1) It's expected to fail to bind a new source port when they
   are scarce, suppress warning in log in this case.

2) Optimse bind_local when max_port - min_port is small. There's no
   randomness in this case, so we try all possible source ports
   rather than poking at random ones for an arbitrary number of tries.

3) In allocate_rfd() handle the case that all available source ports
   are already open. In this case we need to pick an existing
   socket/port to use, such that it has a different port from any we
   already hold. This gives the required property that the set of ports
   utilised by any given query is set by --port-limit and we don't
   re-use any until we have port-limit different ones.

3 years agoFix namebuff overwrite leading to wrong log after socket bind warning.
Simon Kelley [Fri, 9 Sep 2022 14:56:54 +0000 (15:56 +0100)]
Fix namebuff overwrite leading to wrong log after socket bind warning.

3 years agoFix a problem in overload handling. v2.87
Simon Kelley [Fri, 9 Sep 2022 11:53:49 +0000 (12:53 +0100)]
Fix a problem in overload handling.

Sending the same query repeatedly to a dnsmasq instance which
doesn't get replies from upstream will eventually hit the
hard limit on frec_src structures and start gettin REFUSED
replies. This is OK, except that since the queries are no longer
being forwarded, an upstream server coming back doesn't reset the
situation. If there is any other traffic, frec allocation will
eventually delete the timed-out frec and get things moving again,
but that's not guaranteed.

To fix this we explicitly delete the frec once timed out in this case.

Thanks to Filip Jenicek for noticing and characterising this problem.

3 years agoRemove fast-retry development logging.
Simon Kelley [Tue, 6 Sep 2022 21:09:21 +0000 (22:09 +0100)]
Remove fast-retry development logging.

3 years agoAdd --use-stale-cache option.
Simon Kelley [Mon, 29 Aug 2022 20:44:05 +0000 (21:44 +0100)]
Add --use-stale-cache option.

3 years agoAdd --fast-dns-retry option.
Simon Kelley [Sun, 21 Aug 2022 17:07:17 +0000 (18:07 +0100)]
Add --fast-dns-retry option.

This gives dnsmasq the ability to originate retries for upstream DNS
queries itself, rather than relying on the downstream client. This is
most useful when doing DNSSEC over unreliable upstream network. It
comes with some cost in memory usage and network bandwidth.

3 years agoAdd --port-limit option.
Simon Kelley [Wed, 17 Aug 2022 14:33:15 +0000 (15:33 +0100)]
Add --port-limit option.

By default, when sending a query via random ports to multiple upstream servers or
retrying a query dnsmasq will use a single random port for all the tries/retries.
This option allows a larger number of ports to be used, which can increase robustness
in certain network configurations. Note that increasing this to more than
two or three can have security and resource implications and should only
be done with understanding of those.

3 years agoAdd DHCPv4 option 108 "ipv6-only" to the options table. v2.87rc1
Simon Kelley [Tue, 6 Sep 2022 21:40:06 +0000 (22:40 +0100)]
Add DHCPv4 option 108 "ipv6-only" to the options table.

3 years agoFix logic when a SERVFAIL reply is received after good replt for DNSSEC.
Simon Kelley [Fri, 19 Aug 2022 12:28:00 +0000 (13:28 +0100)]
Fix logic when a SERVFAIL reply is received after good replt for DNSSEC.

If we get a SERVFAIL or REFUSED answer to a DNSSEC query for which
we already have a good answer, just ignore it.

3 years agoAdd source address to RA packet dumps.
Simon Kelley [Tue, 6 Sep 2022 17:08:39 +0000 (18:08 +0100)]
Add source address to RA packet dumps.

3 years agoFix DHCPv6 relay to use a more sensble source address.
Simon Kelley [Tue, 6 Sep 2022 14:40:42 +0000 (15:40 +0100)]
Fix DHCPv6 relay to use a more sensble source address.

Tweak things so that packets relayed towards a server
have source address on the server-facing network, not the
client-facing network. Thanks to Luis Thomas for spotting this
and initial patch.