Commit graph

102 commits

Author SHA1 Message Date
cinap_lenrek 75a8003a8a ndb/cs: don't lookup AAAA records for IL, make sure translated address is IPv4 for IL, consistent use of nil vs. 0 for pointers 2016-08-14 23:10:19 +02:00
cinap_lenrek a0d4c5e208 make error handling in 9p service loops consistent
when we get eof, stop the loop immidiately and do not
rely on the read to eventually return an error.

when convM2S() fails to decode the message, error out
and stop the loop. there is no point in continuing.
2016-07-24 02:21:32 +02:00
cinap_lenrek 518a40ae95 ndb/dns: remove procname statistics and restart feature, cleanup 9p service loop
given that the memory leaks have been fixed, theres no need
for the obscure restart feature which is not reliable anyway.

remove the code updating procname on each 9p request.

handle convM2S error by exiting the service loop, dont read
9p channel after eof.
2016-07-24 02:12:17 +02:00
cinap_lenrek 2dc97202de ndb/dns: purge db records on refresh for resolvers, remove old debug and testing code
when ndb/dns runs as a resolver only (cfg.cachedb == 0),
we still want to purge the "local#" db records to reread
dns server configuration or react to changed ip addresses.

removing old poolcheck and dncheck code, these bugs have
been fixed a long time ago.
2016-06-27 00:36:04 +02:00
cinap_lenrek 7468752ea2 ndb/cs: fix memory leak (charles forsyth) 2016-05-16 21:58:12 +02:00
cinap_lenrek b31cc134e7 ndb/dns: initialize unknown fids to point to the root qid
the dns file service can be restarted, which causes it to forget
all fid state. given the simple file system structure of the dns
service (just a single dns file), we can assume that rpcs
on a unknown fid refers to the root, so the mountpoint will stay
valid and /net/dns can be reopend avoiding the need for a remount
of the dns service after restart.
2016-02-22 22:44:01 +01:00
cinap_lenrek a1fa3d75d8 ndb/dns: removing the buggy /net.alt remount hack 2016-02-16 19:06:54 +01:00
cinap_lenrek 5243969ba2 ndb/dnstcp: -x specifies the mountmoint 2016-01-12 08:53:06 +01:00
cinap_lenrek 772afbe98c format pointer subtraction results with %zd instead of %ld (for long -> intptr on amd64) 2016-01-07 04:44:13 +01:00
cinap_lenrek 65db705481 ndb/dns: cleanup forwarding code (redistrib())
instead of copying the whole packet, just save the
udp header and restore it aftwards. dont call redistrib()
when there are no forwards (this should be almost always
the case).
2015-06-14 21:31:44 +02:00
cinap_lenrek f92057cc39 ndb/dns: use same buffer size of udp packet in redistrib() as dnudpserver() (fixes assert) 2015-06-13 22:37:26 +02:00
cinap_lenrek 6eba362810 ndb/dns: reduce sencodefmt() to not link in enc32()/enc64() encoders
the special sencodefmt() in ndb/dn.c is only used with %H format for
hexadecimal printing for binary strings. removing the unused
calls to enc32() and enc64() reduces the code size by arround 4K.
(this is usefull for ndb/getip which gets linked into the kernel).
2015-03-11 18:09:48 +01:00
cinap_lenrek 9be64bcb8d ndb/cs: fix spelling (thanks mischief) 2014-12-13 23:16:04 +01:00
cinap_lenrek 1985bebbdd dnsgetip: filter negative answers, remove -f flag, use dnsgetip logfile 2014-12-10 02:30:25 +01:00
mischief 230cee347f ndb: add dnsgetip program to resolve A and AAAA records during bootstrapping 2014-12-09 16:18:08 -08: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 4616c93e8d cs: fix linefeeds in syslog(), cleanup 2014-10-29 03:20:43 +01:00
cinap_lenrek fe23dcefd4 cs: use /net/ether* instead /net/ether[0123], dont remove srv file with -n, dont write dns logfile 2014-10-29 02:43:18 +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 0ceeee4c8b ndb/dns: fix nil dereference crash with convM2DNS() returning reqmsg.qd == nil 2014-08-08 02:06:03 +02:00
cinap_lenrek ad3ba8838d ndb/dns: check bad name length in convM2DNS.c:^gname() 2013-11-28 23:47:49 +01: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 2ce68c5aa1 ndb/dns: case sensitive ndb attributes, Domlen consistency, dblookup() inplace lower case conversion, cleanups
ndb keys are strictly case sensitive, so consitently
use strcmp() when comparing attribute keys.

dblookup() used to lower case convert its name argument
inplace to match domain/sys name in ndb. better to do
the convesion in its own buffer and only read from the
name argument.

always use cistrcmp() when comparing DN.name.

the Domlen constant denotes the size of the buffer including
the null terminator. consistently use it as such.

have to hold dnlock in freearea() before reading list
head pointer.
2013-11-13 18:44:45 +01:00
cinap_lenrek 7dee88ec33 dns: ignore spam addresses from cname answers 2013-08-04 00:52:39 +02:00
cinap_lenrek 41208add72 ndb/dns: avoid duplicate entries for db records
dnauthdb() would relabel expired rr's as rr->db == 0 to make
them get garbage collected by dnage(). but this doesnt work
due to dn->keep and also causes the deduplication to fail on
rrattach() as rrattach1() handles rr->dn/rr->auth as separate
name spaces.

this causes duplicate entries in the rr's when ndb gets
gets changed. to fix, we just delete the expired (removed from
ndb) rr's immidiately in dnauthdb() instead of trying trick
dnage() to garbage collect it.
2013-06-21 02:27:10 +02:00
cinap_lenrek e36d9f5c4e make filesystem handling of read9pmsg() consistent 2013-06-16 06:26:31 +02:00
cinap_lenrek 2e0fac766c ndb/cs, ndb/dns: ignore special commands from users different from the one we run the service owner
this prevents users like "none" from toggling special options in ndb/dns
and ndb/cs.
2013-06-14 19:20:06 +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 5ed845f7e9 ndb/dnsdebug: make sure request is initialized (import from sources) 2013-01-05 17:11:46 +01:00
cinap_lenrek c430bf65d3 ndb/dns: fix mistake 2012-08-29 20:14:15 +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 f466d3894c ndb/dns: cleanup 2012-08-08 19:03:10 +02:00
cinap_lenrek 780d393e4b ndb/cs: limit number of slave procs 2012-07-29 03:05:05 +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 1de9ca2de5 bring back il protocol support 2012-05-03 10:47:40 +02:00
stanley lieber 8ff0cd425a ndb/cs: add lookups for ssh 2012-04-28 13:20:37 -05:00
cinap_lenrek 8562240e8c fix more fd <= 0 bugs 2012-04-24 06:57:02 +02:00
cinap_lenrek 9840c9f18e ndb/cs: fix use after free caused by flush/clunk happening before dns lookup finishes 2012-03-23 04:02:34 +01:00
cinap_lenrek 9b2d3d4266 ndb: avoid double /net/ndb 2012-03-16 22:42:14 +01:00
cinap_lenrek 0d926a2512 dns: import changes from sources 2012-03-09 06:02:17 +01:00
cinap_lenrek bf686ffabc dns: discover my ip address at runtime 2012-03-02 17:47:01 +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