Commit graph

25 commits

Author SHA1 Message Date
cinap_lenrek fce9c3e65a ndb/dns: avoid format strings in procname 2018-10-11 18:29:17 +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 549a6745e3 ndb/dns: fix leak in myaddr(), normalize ip strings
remove myaddr() function and replace with myip() function
that receives binary ip address. and don't use string
comparsion for ip addresses... parse and then ipcmp().

for sanity reasons, normalize ip address strings and
reject unparsable ones. done by calling ipalookup()
with a binary ip address.
2018-01-28 22:36:01 +01:00
cinap_lenrek d801a4f300 ndb/dns: double Maxretries for long cname redirection chains 2017-04-01 03:35:30 +02:00
cinap_lenrek a1fa3d75d8 ndb/dns: removing the buggy /net.alt remount hack 2016-02-16 19:06:54 +01:00
cinap_lenrek 501e69d010 ndb/dns: ignore terminating authoritative flag for no-answer when more nameservers are provided
continue recursing when we get empty but non-negative answer
from a (claimed) authoritative nameserer that provides more
nameservers.

this fixes wordpress dns:

63766.3: sending to 192.0.80.93/ns1.wordpress.com bossypally.files.wordpress.com ip
63766: rcvd OK from 192.0.80.93 (authoritative)
	Q:    bossypally.files.wordpress.com ip
	Auth: files.wordpress.com              5 min           ns   	mdns1.wordpress.com
	      files.wordpress.com              5 min           ns   	mdns2.wordpress.com
	      files.wordpress.com              5 min           ns   	mdns3.wordpress.com
	      files.wordpress.com              5 min           ns   	mdns4.wordpress.com
	      files.wordpress.com              5 min           ns   	mdns5.wordpress.com
	Hint: mdns1.wordpress.com              4 hr            ip   	192.0.75.7
	      mdns2.wordpress.com              4 hr            ip   	198.181.117.7
	      mdns3.wordpress.com              4 hr            ip   	198.181.116.7
	      mdns4.wordpress.com              4 hr            ip   	198.181.118.7
	      mdns5.wordpress.com              4 hr            ip   	192.0.74.7


63766.4: sending to 192.0.75.7/mdns1.wordpress.com bossypally.files.wordpress.com ip
63766: rcvd OK from 192.0.75.7 (authoritative)
	Q:    bossypally.files.wordpress.com ip
	Ans:  bossypally.files.wordpress.com   5 min           ip   	192.0.72.2
	      bossypally.files.wordpress.com   5 min           ip   	192.0.72.3
----------------------------
answer bossypally.files.wordpress.com   5 min           ip   	192.0.72.2
answer bossypally.files.wordpress.com   5 min           ip   	192.0.72.3
----------------------------

note the authoritative flag in the first response from ns1.wordpress.com that
would otherwise terminate the search.
2014-12-08 01:26:07 +01:00
cinap_lenrek a494cc74ad ndb/dns: request recursion only for local dns servers
we used to set RD flag in requests unconditionally, which
is fine by the standard but some dns server administrators
seem to use it as a denial of service indicator (for ther
non recursive authoritative nameservers) and ignore the
request.

so only set the RD flag when talking to local dns servers.
2014-09-28 05:15:25 +02:00
cinap_lenrek da6a10c417 ndb/dns: do dnresolve() loopcheck only on hosts that we havnt already tried
we might get a unreachable nameserver ip from a parent
nameserver. if the remaining set of nameservers does not
loop, we should try to resolve them.

so skip the loopcheck for nameservers already tried.
2013-11-26 22:31:23 +01:00
cinap_lenrek 3720b5ab9c ndb/dns: add support for internationalized domain names 2013-11-24 11:55:26 +01:00
cinap_lenrek c2319f37b4 ndb/dns: ignore refused (5) error replies 2013-11-23 04:46:14 +01:00
cinap_lenrek 2cc152f9e1 ndb/dns: filter dns answers avoiding cache poisoning
only cache what we asked for or need to resolve the
query. filter out everything else.
2013-11-20 22:35:52 +01:00
cinap_lenrek 9155b30f6d ndb/dns: another attempt...
we have to fail the whole query that got no cached
nameservers and nameservers are looping, not just omit
the looping nameserver. issuequery() will refresh
nameserver info for the domain when recursing up.
2013-11-17 06:55:39 +01:00
cinap_lenrek c45386588b ndb/dns: detect query loops
never try to resolve a nameserver address when that nameserver
is in the set of nameservers already being queried.

this situation can happen when the Ta and Taaaa RR's expire, but
the Tns records are still in the cache so there is no usable
nameserver but they still refer to each another.
2013-11-16 04:42:09 +01:00
cinap_lenrek 5f87d8dcc8 ndb/dns: various changes
stop absolute/relative dual use of RR.ttl. now RR.ttl is
*always* the *relative* ttl value. we derive absolute
timeout in RR.expire.

remove unused lookuptime field in DN. replace refs and
keep with mark field in DN. we do not care about the
number of references. only *iff* it is referenced, so
use a single bit for that (bit 0). for keep, we use
bit 1.

remove dolock parameter in dnagenever(), it is not
needed. we always need to lock.

mark local dns servers and domains as never to be aged.

the keeper bit is *just* a cache optimization, preventing
the domain and the domains it points to from being flushed.
it should not be used as a write protect bit in rrattach()
for preventing spoofing as it will prevent updates of say,
cname domains.

remove "removing spam ..." message. these are usualy just
hints, so normal. still, remove the hint as we currently
do no check if the nameserver has authority over the
cname domain.

remove "mydnsquery: trying to send to myself (%s); bzzzt"
message. this can happen when myaddr() fails for other
reasons. myaddr() will print error for us anyway.
2013-11-15 02:00:47 +01:00
cinap_lenrek 7dee88ec33 dns: ignore spam addresses from cname answers 2013-08-04 00:52:39 +02:00
cinap_lenrek 2647aef175 ndb/dns: dont override req->aborttime in udpquery()
overriding aborttime in udpquery() makes no sense. it causes
recursive queries to extend the timeout infinitely. nobody
but the issuer of the request should modify aborttime.
2013-04-11 19:33:07 +02:00
cinap_lenrek 860d938b20 ndb/dns: bug fixes and massive cleanup
removing the querylck from the DN as it was never used or being
effective which saves like a ton on space per domain name.

remove the Query.tcplock and put query on the stack. it is
unneccesary to lock the query as its only used by one process
at a time. put Query's on the stack.

change outsidens() to outsidensip() which now takes the ip
buffer that it fills instead of returning static buffer (which
would race with multiple processes involved).

eleminate mostly all of the lock(&dnlock)/unlock(&dnlock) calls.
we'r not working on shared cache RR's in the resolver procs.
we work on *copies* done by rrlookup() made under the dnlock.

the cache garbage collection only runs when all processes are
locked out and is also taking the dnlock while doing so.

cleanup xmitquery(). for the tcp case, we dont need to get
more nameserver addresses, just take the ip from the udp header
that tcpquery() placed there for us.

fixed baddelegation() to actually check for delegation loop even
if theres no dom info for our host.

remove lots of debug code. remove the dnforceage() as it doenst
make sure other processes are locked out. this could destroy
dn's currenctly refered by running queries.

remove dnageallnever() as its not used. dont attach rr's to
keepers to prevent outside spoofing.

make myaddr() retrive the ip address if not set.
2012-08-29 19:01:05 +02:00
cinap_lenrek 40d5dce459 dns: fix rr->srv memory leak in rrcopy, mark rr->sig->signer, dn aging, cleanup 2012-08-26 21:56:03 +02:00
cinap_lenrek 8f0ec8b725 ndb/dns: fix netmkaddr() race, dnlock consistency, strcpy, cleanups 2012-08-26 01:51:46 +02:00
cinap_lenrek 8e5dd37eba ndb/dns: fix memory corruption and bad serveraddrs() range checks 2012-08-22 19:45:29 +02:00
cinap_lenrek b4d2e39d8c ndb/cs/dns: make sure never to block the 9p loop when we run out of processes, fail the request instead 2012-07-28 19:17:54 +02:00
cinap_lenrek 8562240e8c fix more fd <= 0 bugs 2012-04-24 06:57:02 +02:00
cinap_lenrek 0d926a2512 dns: import changes from sources 2012-03-09 06:02:17 +01:00
Taru Karttunen a9060cc06b Import sources from 2011-03-30 iso image - lib 2011-03-30 19:35:09 +03:00
Taru Karttunen e5888a1ffd Import sources from 2011-03-30 iso image 2011-03-30 15:46:40 +03:00