Commit graph

113 commits

Author SHA1 Message Date
cinap_lenrek c37de33463 ndb/dns: use decimal encoding for txt rr string escapes
rfc883 suggests to use decimal digits to escape txt rr strings,
and unix dig appears to use the same.
so change from octal to decimal.
2021-11-03 20:38:23 +00:00
cinap_lenrek 5de1f3d9cf ndb/dns: handle txt rr strings as binary, remove nullrr ndb code
txt and caa rr strings might contain binary control characters
such as newlines and double quotes which mess up the output
in ndb(6) format.
so handle them as binary blobs internally and escape special
characters as \DDD where D is a octal digit when printing.

txtrr() will unescape them when reading into internal
binary representation.

remove the undocumented nullrr ndb attribute parsing code.
2021-11-03 20:09:02 +00:00
cinap_lenrek 2899b719ae libndb: move mkptrname() into libndb to avoid duplication 2021-11-03 19:38:36 +00:00
cinap_lenrek 498d86b921 ndb/dnsquery: make ! bang work with reverse lookups, document in ndb(8) 2021-11-01 16:31:39 +00:00
cinap_lenrek 3cd87bc3fb ndb/dns: use correct attribute when serializing caa record in ndb format 2021-11-01 15:12:17 +00:00
cinap_lenrek 5e3ded2242 ndb/dnsdebug: dont duplicate rrfmt()
introduce our own RR* format %P for pretty
printing and call %R format internally,
then use it to print the rest of the line
after the tab, prefixed with the padded
output.
2021-11-01 14:39:18 +00:00
cinap_lenrek 28f67bba84 ndb/dns: fix ndb serialization of RR*
have todo multiple fmtprint() calls for idnname()
as the buffer is shared.

do not idnname() rp->os and rp->cpu, these are symbols.

always quote txt= records.
2021-11-01 14:37:19 +00:00
cinap_lenrek 20cff04fd2 ndb/dns: implement caa record type in ndb
this allows the caa records to be specified
in ndb as:

caa=<value> tag=<tag> flags=<flags>

where tag defaults to "issue" and flags to 0
when omited.
2021-10-24 22:15:26 +00:00
cinap_lenrek df66e62842 ndb/dns: make dblookup() consistent with cachedb operation, bring back txtrr for compatibility
- enforce same behaviour as cachedb server in dblookup():
	- force Taaaa record type on ipv6= attributes, regardless of value
	- return Taaaa records for ip= attributes containing ipv6 values
	- return Ta records only for ip= attributes containing ipv4 values

- for compatibility, bring back support for txtrr= type, but handle consistently
2021-09-08 17:34:04 +00:00
cinap_lenrek 1299ea4d89 ndb/dnsdebug: make usage flags consistent 2021-09-08 17:26:31 +00:00
cinap_lenrek 41369692bf ndb/dns: fix wrong ndb attribute "txtrr" vs. "txt" for caching server 2021-09-08 13:34:23 +00:00
sl 4bbb3b0b21 /sys/src/cmd/ndb/dns.h:
---

To: 9front@9front.org
Date: Sun, 07 Feb 2021 14:56:39 +0100
From: kvik@a-b.xyz
Subject: Re: [9front] transient dns errors cause smtp failure
Reply-To: 9front@9front.org

I think I found a reason for DNS failing on known good domains.

/sys/src/cmd/ndb/dns.h:156,157
	/* tune; was 60*1000; keep it short */
	Maxreqtm=	8*1000,	/* max. ms to process a request */

So, 8 seconds is how much the resolver will bother with a request it
has been handed, before dropping it on the floor with little
explanation.

It seems quite possible that this is too short a timeout on a machine
during a spam queue run, which predictably stresses the compute and
network resources.

In turn, negative response caching might explain why a particular
unlucky domain would basically stop receiveing any mail for a while.

I'm dying to know if bumping this limit would clear up the queue of
such DNS errors.

---

[narrator: it did.]
2021-02-19 21:29:55 -05:00
cinap_lenrek b5690a5ae7 ndb/dns: implement RFC6844 certificate authority authorization record type 2021-02-14 14:25:41 +01:00
cinap_lenrek 41c60689b3 ndb/dns: handle dnskey RR's (thanks moody)
On 12/18/20, Jacob Moody wrote:
> Hello,
>
> I recently ran in to some issues with pointing an unbound server towards a
> 9front dns server as its upstream.
> The parsing seemed to fail when ndb/dns received a DNSKEY RR from it's own
> upstream source on behalf of unbound.
> This patch catches and stores the DNSKEY from the upstream server to prevent
> this.
2020-12-20 23:08:11 +01:00
cinap_lenrek 0b094303f3 ndb/dnsdebug: add -c flag to debug caching dns server behaviour 2020-10-17 21:28:56 +02:00
cinap_lenrek bf18724738 ndb/dns: mark ns record authoritative when in our area for delegation
I have the problem that i need to delegate a subdomain
to another name server that is confused about its own zone
(and its own name) returning unusable ns records.

With this, one can make up a nameserver entry in ndb that
is authoritative and owned by us for that nameserver,
and then put it in the soa=delegated ns entry.

This promotes the ns record in the soa=delegated to
Authoritative, which avoids overriding the ns rr's from
the confused server for the delegated zone.
2020-10-17 21:28:25 +02:00
cinap_lenrek ac4e21f52d ndb/dns: allow multiple txt, nullrr, cert, key and sig records (thanks kvik)
The de-duplication of txt, nullrr, cert, key and sig records
reduced all records to a single one.

Also, dblookup1() missed the txt record case and did not return
a unique list of rr's.

Now we consider these records unique if their value is different.
The new txtequiv() function does that for TXT records, which is
a bit tricky as it needs to take different segmentation into account.
2020-08-08 18:37:10 +02:00
kvik e5894dccea pre-lib9p servers: fix incorrect Tversion handling
version(5) says:

	If the server does not understand the client's version
	string, it should respond with an Rversion message (not
	Rerror) with the version string the 7 characters
	``unknown''.

Pre-lib9p file servers -- all except cwfs(4) -- do return Rerror.

lib9p(2) follows the above spec, although ignoring the next part
concerning comparison after period-stripping.  It assumes an
Fcall.version starting with "9P" is correctly formed and returns
the only supported version of the protocol, which seems alright.

This patch brings pre-lib9p servers in accordance with the spec.
2020-08-01 15:27:28 +02:00
cinap_lenrek ac88ce4f7f make bind(2) error handling consistent
The mount() and bind() syscalls return -1 on error,
and the mountid sequence number on success.

The manpage states that the mountid sequence number
is a positive integer, but the kernels implementation
currently uses a unsigned 32-bit integer and does not
guarantee that the mountid will not become negative.

Most code just cares about the error, so test for
the -1 error value only.
2020-05-02 17:32:01 +02:00
cinap_lenrek e168ea045f ndb/dns: handle empty $DNSSERVER
when $DNSSERVER is empty, query ndb for local dns servers
instead of not using any at all.
2019-10-13 09:02:04 +02:00
cinap_lenrek 4b9ccb2de0 ndb/dnsquery, ndb/csquery: write ">" prompt to stderr (thanks kvik)
kvik writes:

dnsquery(8) prints the interactive prompt on stdout together with
query results, making scripted usage unnecessarily difficult.

A straightforward solution is prompting on stderr instead: as
practiced by rc(1), among many others -- promptly taking care of
the issue:

	; echo 9front.org mx | ndb/dnsquery >[2]/dev/null
2019-08-30 20:17:19 +02:00
cinap_lenrek 45213ee6c7 ip/ipconfig, ndb/dns, libndb: handle parseipmask() errors 2019-02-12 21:44:57 +01:00
cinap_lenrek b1c9ddb3f0 ndb/dns: provide v4 argument to parseipmask(), use snprint() instead of sprint() 2019-02-11 23:42:15 +01:00
cinap_lenrek a66be23396 dnstcp: temporarily switch on resolver mode so we can resolve the dnsslaves for axfr check 2018-11-06 04:31:48 +01:00
BurnZeZ 84e019aba3 fix misleading/wrong fd checks 2018-10-20 18:44:09 +00:00
cinap_lenrek c9e86d6b34 ndb/dnstcp: only lookup the expected address type in findserver()
theres no reason to lookup both A and AAAA records, as we already
know the type of srcip.
2018-10-11 18:57:14 +02:00
cinap_lenrek ed888f3ee9 ndb/dns: use nil for pointers in dnresolve() args 2018-10-11 18:32:31 +02:00
cinap_lenrek 784a959888 ndb/dns: do recursive lookup for dnsslave= 2018-10-11 18:31:35 +02:00
cinap_lenrek fce9c3e65a ndb/dns: avoid format strings in procname 2018-10-11 18:29:17 +02:00
cinap_lenrek e73ce8475e ndb/dnstcp: return a proper non-answer when rejecting zone transfer 2018-10-09 06:34:27 +02:00
cinap_lenrek 08292c8f1f ndb/dns: fix format print warning for procsetname(), cleanup 2018-10-09 06:08:48 +02:00
cinap_lenrek 45e71cb728 ndb/dns: send_notify() to multiple ip addresses in parallel, filter myip() 2018-10-09 06:07:51 +02:00
cinap_lenrek 7ddda493c0 ndb/dnstcp: restrict DNS zone transfers to clients listed as dnsslave=
initial idea from Steve Simon, but doesnt require reverse
lookup of the callers ip address.
2018-10-09 06:02:36 +02:00
cinap_lenrek 19166f2cf3 libc: add procsetname() 2018-09-26 14:56:23 +02:00
cinap_lenrek 311e3b51c6 libc: return number of bytes produced for idn2utf() and utf2idn() 2018-09-26 14:32:17 +02:00
cinap_lenrek 0126f10d05 ndb/inform: handle internationalized domain names 2018-09-25 20:59:08 +02:00
cinap_lenrek 2160da07de ndb/dns: use libc's new idn functions 2018-09-25 20:17:00 +02:00
cinap_lenrek a4e444f430 libndb: make ndbipinfo() walk ipnet for all matching entries, concatenate and dedup result 2018-09-16 12:39:47 +02:00
cinap_lenrek e4d0a76289 ndb/cs: don't do dns lookups when all we got is loopback or link local addresses 2018-09-09 15:38:53 +02:00
cinap_lenrek 00622d4d2b ndb/dns: fix delegation with norecursion (-R flag)
when the question zone is in a delegated area, we still
need to provide the nameservers.
2018-07-16 23:54:23 +02:00
mischief c5559504cd ndb/dnsgetip: report errors when dns resolution fails 2018-07-13 20:44:57 +00:00
cinap_lenrek 24611cf5ed ndb/cs: add -6 flag for v6 only lookups and "ipv4" control message to toggle v4 lookups. 2018-07-10 19:57:55 +02:00
cinap_lenrek 902eceee63 ndb/dns: fix encoding of srv record target
the target has to be encoded as a domain name (the individual
name components as separate labels followed by . (empty) label),
not as a literal string.

to disable compression, pass nil dictionary to pname().
2018-06-26 19:30:52 +02:00
cinap_lenrek 7113f730de ndb/cs: make ipv6 only host practical by checking ip version on local interfaces
avoid returning ip addresses that cannot be reached due
to lack of a compatible ip address. this means when here
is no ipv4 address configured, we wont return ipv4 addresses
and would not query dns for an A record.

likewise, when here is no ipv6 address configured then
we wont query dns for an AAAA record.

ipv6 lookups can still be disabled with the -4 flag just
as before.
2018-06-01 23:53:09 +02:00
cinap_lenrek ad7390dda8 ndb/dnsdebug: handle .ip6.arpa names 2018-05-23 19:44:12 +02:00
cinap_lenrek 03ced8cca1 ndb/dnsquery: handle .ip6.arpa names, don't mount the dns service 2018-05-23 19:43:45 +02:00
cinap_lenrek 6e284eaad5 ndb/cs: prevent deadlock with ndb/cs by mounting /srv/dns *AFTER* /net
the dnsquery() library function should not start mouting /srv/dns on
its own. this problem arrises only for ndb/cs as it is started before
ndb/dns.

the issue with mounting /srv/dns before /net is when ndb/cs attempts
to read the list of interfaces, accessing /net/ipifc, which triggers
a rpc to ndb/dns as it is ontop of the mount. this can yield a deadlock
when ndb/dns blocks its 9p loop waiting for requests to complete on
a refresh and the requests are stuck waiting for ndb/cs to translate
a dial string for announce().
2018-05-16 21:41:42 +02:00
cinap_lenrek 2728e06589 ndb/dns: lookup *all* entries in dblookup(), v4 and v6 queries in parallel, remove weigthed timeouts
dblookup() used to only return the first matching entry. in
case of ipv6, we want all entries returned to get both v4
and v6 addresses... and these might not neccesarily be in
the same entry (see /lib/ndb/common). note also this makes
it behave the same as in cachedb mode which reads in the
whole database.

we do not know if v4 or v6 routing works, so the simplest
is just to query v4 and v6 nameservers in parallel. this is
done by changing serveraddrs() to return one address type,
and we make sure to get at least one v4 and one v6 address
each round.

get rid of the weigthed timeout code... there where too many
assumptions. instead, we give a round 500ms timeout (or 1 second
in patient mode) and honor the maximum query time.
2018-05-11 22:37:28 +02:00
cinap_lenrek 8e53fe132e ndb/cs: fix crash in ndbredorder due to ndbnew() not maintaining the ->line ring
we have to maintain the ->line chain for ndbreorder() to work, so add
a little helper: ndbline() which replicates the ->entry chain and links
the last tuple to the first; makeing the whole list into a single line.
2018-05-01 22:17:27 +02:00
cinap_lenrek bc4469e5d2 ndb/csquery: insert \n between read chunks 2018-04-28 04:40:09 +02:00