Commit graph

25 commits

Author SHA1 Message Date
Robert Greenwalt
7f84da69f8 Add some logging of dns cache operations
Added info about what entries are getting flushed due to ttl or size limits.

Change-Id: I69fb70ce23b5b820f5f1a5738c0f1aa57b6a1127
2011-09-02 07:44:36 -07:00
Robert Greenwalt
777901424f resolved conflicts for merge of 9363d912 to honeycomb-plus-aosp
Change-Id: I555f5c10da9770feacdbece9fd77729d6151bfba
2011-07-26 16:18:52 -07:00
Robert Greenwalt
9363d91218 Add per-interface dns caches.
import of changes 22100 and 23138 from opensource.

Change-Id: I3ce86394323d269272aeb2bebeed4374f171a8cf
2011-07-26 12:59:50 -07:00
Robert Greenwalt
e4197d41bb am fed31359: am f6fcdb2e: am 28de3e59: Merge "Don\'t reset caches when dns props change."
* commit 'fed3135972f9725a44a7d9b3df728e311ac1a130':
  Don't reset caches when dns props change.
2011-07-20 17:20:03 -07:00
Mattias Falk
bad1686e1f Don't reset caches when dns props change.
This happens too frequently.  We should flush a per-interface cache
when it's dns server addrs changes.

Change-Id: I8a691c96ce9a775160ef55ddb8f755d649041583
2011-07-20 15:09:24 -07:00
Robert Greenwalt
8f88cbedc1 am e0a4b678: am cc32fbc3: Merge "Add support for a dns cache per interface"
* commit 'e0a4b67811981ab4c04c437b23c36ae42c444bce':
  Add support for a dns cache per interface
2011-06-27 14:14:07 -07:00
Mattias Falk
23d3e6b21b Add support for a dns cache per interface
Initial commit for dns cache per interface.
Added a type that holds a reference to a
cache and name of associated interface,
address of interface, name server(s)
associated with an interface etc.

New functions to set default interface,
address of name servers etc.

Change-Id: Ie991bc5592fd998409853d8bf77d7fe69035dac5
2011-06-08 15:39:29 +02:00
David 'Digit' Turner
b6cd6816d2 libc: Fix leak in the DNS thread-specific state.
NOTE: This is a back-port from the internal HC branch.

This patch fixes a leak that occurs when creating a new
thread-specific DNS resolver state object.

Essentially, each thread that calls gethostbyname() or getaddrinfo()
at least once will leak a small memory block. Another leak happens
anytime these functions are called after a change of the network
settings.

The leak is insignificant and hard to notice on typical programs.
However, netd tends to create one new thread for each DNS request
it processes, and quickly grows in size after a > 20 hours.

The same problem is seen in other system processes that tend to
create one thread per request too.

The leak occured becasue res_ninit() was called twice when creating
a new thread-specific DNS resolver state in _res_get_thread().

This function could not properly reset an existing thread and was
leaking a memory block.

The patch does two things:

- First, it fixes res_ninit() to prevent any leakage when resetting
  the state of a given res_state instance.

- Second, it modifies the _res_get_thread() implementation to
  make it more explicit, and avoid calling res_ninit() twice
  in a row on first-time creation.

Fix for Bug 4089945, and Bug 4090857

Change-Id: Icde1d4d1dfb9383efdbf38d0658ba915be77942e
2011-05-18 13:48:20 +02:00
Brad Fitzpatrick
a34694d394 am 09db590d: am 9b6e8af6: am 3ef36b21: Merge "Use system property to set dns cache size"
* commit '09db590d56ff2b568ea1a0ce265810697f0e0e92':
  Use system property to set dns cache size
2011-04-12 13:28:03 -07:00
Brad Fitzpatrick
09db590d56 am 9b6e8af6: am 3ef36b21: Merge "Use system property to set dns cache size"
* commit '9b6e8af6994fd41f468161dec797354bb7778673':
  Use system property to set dns cache size
2011-04-12 13:18:15 -07:00
David 'Digit' Turner
02be15039a am aa8f50b4: am 6d46b099: am 2f169162: Merge "libc: Fix leak in the DNS thread-specific state." into honeycomb-mr1
* commit 'aa8f50b404ab0b2c78833387551800fa8448afcd':
  libc: Fix leak in the DNS thread-specific state.
2011-03-25 01:52:17 -07:00
Carl Shapiro
2cc2b2be69 Add some missing includes.
Change-Id: Ieec623c06bc32ec78334f628af25b00c2bccd2e7
2011-03-21 20:01:03 -07:00
David 'Digit' Turner
4661fda2e5 libc: Fix leak in the DNS thread-specific state.
This patch fixes a leak that occurs when creating a new
thread-specific DNS resolver state object.

Essentially, each thread that calls gethostbyname() or getaddrinfo()
at least once will leak a small memory block. Another leak happens
anytime these functions are called after a change of the network
settings.

The leak is insignificant and hard to notice on typical programs.
However, netd tends to create one new thread for each DNS request
it processes, and quickly grows in size after a > 20 hours.

The same problem is seen in other system processes that tend to
create one thread per request too.

The leak occured becasue res_ninit() was called twice when creating
a new thread-specific DNS resolver state in _res_get_thread().

This function could not properly reset an existing thread and was
leaking a memory block.

The patch does two things:

- First, it fixes res_ninit() to prevent any leakage when resetting
  the state of a given res_state instance.

- Second, it modifies the _res_get_thread() implementation to
  make it more explicit, and avoid calling res_ninit() twice
  in a row on first-time creation.

Fix for Bug 4089945, and Bug 4090857

Change-Id: Ie4831a8dbe82be8f07fce5ddd1d36bf95994f836
2011-03-18 18:08:08 +01:00
Mattias Falk
3a4910c616 Use system property to set dns cache size
Use system property ro.net.dns_cache_size to set
the size of the cache. If the system property
is not set the default cache size is defined by
CONFIG_MAX_ENTRIES.

The number of entries in the hash table will be equal
to the number of max entries allowed in the cache.

Change-Id: I77d69d7c178937fa483d0b40512483ad29232d28
2011-02-14 12:41:11 +01:00
Mattias Falk
3e0c5102e6 Add time-to-live (TTL) support to resolver cache
Use the the TTL of the answer as the time a query
shall remain in the resolver cache.

Added some debugging support as well, i.e.
parse answer and print a la dig.

Change-Id: I724d3392245032592f1912f3ca7a81a8987ebbac
2011-02-02 16:40:01 +01:00
Jim Huang
7cc5666d94 resolv: make internal symbols static/hidden
Change-Id: I988b83613e6252c0cc961555e81c10f856a38b37
2010-10-15 02:10:29 +08:00
David 'Digit' Turner
d378c68d74 Fix spurious DNS lookups in the C library.
The problem was that the 'defdname' field of res_state structure
was not properly initialized in __res_vinit(). This field is used
to store the default domain name, which is normally build from
calling gethostname() (see line 549 of res_init.c).

Unfortunately, in the typical Android case, gethostname() returns
an error (the hostname is configured) and a random stack string is
used later to build the DNS search list (see lines 556+ in res_init.c)

For the sake of illustration, let's say the search list is set to
a random value like 'xWLK'.

The end result is that when trying to result an unknown domain name
(e.g. 'www.ptn'), the query fails then the resolver tries to make a
new query with the DNS search list path(s) appended (e.g. 'www.ptn.xWLK').

The patch simply initializes 'defdname' to an empty string to avoid
this when the net.dns.search system property is not set.

Also contains whitespace/formatting fixes
2010-03-08 15:22:13 -08:00
David 'Digit' Turner
9cfb12e6bc am 3773d35e: Make the DNS resolver accept domain names with an underscore.
Merge commit '3773d35eb98e22b5edab4d82fb72bdf86ff80494'

* commit '3773d35eb98e22b5edab4d82fb72bdf86ff80494':
  Make the DNS resolver accept domain names with an underscore.
2009-07-28 15:27:33 -07:00
David 'Digit' Turner
3773d35eb9 Make the DNS resolver accept domain names with an underscore.
More precisely, this accepts domain labels with an underscore in
the middle (i.e. not at the start or the end of the label). This
is needed to perform complex CNAME chain resolution in certain
VPN networks.
2009-07-27 19:19:29 +02:00
Lorenzo Colitti
c52c174e41 Make IPv6 definitions comply with RFC 3493:
- Add some definitions to netinet/in6.h
 - Include netinet/in6.h from netinet/in.h
2009-06-16 18:55:37 -07:00
Chung-yih Wang
aeae1f5b6c Add the domain search list for VPN connection.
The current solution is to read the net.dns.search property,
and expand the list during the resolve initialization. In the
future, we could implement search list per process.

Update: refine the code accordingly.

Update: remove unnecessary code.

Update: remove the unused variable.
2009-04-13 10:41:17 +08:00
The Android Open Source Project
1dc9e472e1 auto import from //depot/cupcake/@135843 2009-03-03 19:28:35 -08:00
The Android Open Source Project
1767f908af auto import from //depot/cupcake/@135843 2009-03-03 18:28:13 -08:00
The Android Open Source Project
6f04a0f4c7 auto import from //branches/cupcake/...@132276 2009-02-19 10:57:29 -08:00
The Android Open Source Project
a27d2baa0c Initial Contribution 2008-10-21 07:00:00 -07:00