Commit graph

136 commits

Author SHA1 Message Date
Stephen Hines
fbb7c0e765 Merge "Don't mark __res_params or android_net_context as packed." am: 0c45c7dc5e
am: 6776efa346

Change-Id: I6b83f36d0e344c9174f7fcdd210ceecbafdd3027
2017-01-26 07:24:57 +00:00
Stephen Hines
9935e0fcee Don't mark __res_params or android_net_context as packed.
Bug: http://b/31532493

These internal API structures are never actually used anywhere that
would change behavior because it is "packed", so it is safe to remove.

Test: Builds correctly with the latest toolchain.
Change-Id: I5431992d840777605be75ab91dc21158d6d22c26
2017-01-25 00:42:45 -08:00
Elliott Hughes
8b114bde2d Check for bad packets in getaddrinfo.c's getanswer. am: 87c0dba7b1 am: dc0492ac4f am: f277bb86c6 am: 389e3e92e2 am: 0ffd7a5fb1 am: 0bf10a656b am: 2646bfc213
am: 9eea4e2864

Change-Id: I410415128a6b6f2d1c818d7b639d4cc45dc3ecd0
2016-12-08 21:27:19 +00:00
Elliott Hughes
0ffd7a5fb1 Check for bad packets in getaddrinfo.c's getanswer. am: 87c0dba7b1 am: dc0492ac4f am: f277bb86c6
am: 389e3e92e2

Change-Id: Ie935c8491aa18867a5087ca4cf707eec318b85f6
2016-12-08 21:07:17 +00:00
Erik Kline
40d51f0d28 Remove all system properties references
Test: as follows
    - build
    - flash
    - runtest -x system/netd/tests/netd_integration_test.cpp
Bug: 33308258
Change-Id: I59526cb91e91b35a63ba6b413d444712568463e4
2016-12-05 12:45:10 +09:00
Treehugger Robot
f8b4ff4aa1 Merge "Remove obsolete #include and comment." 2016-12-05 00:01:34 +00:00
Elliott Hughes
6eb8fb5f86 Remove obsolete #include and comment.
Bug: http://b/33308258
Test: builds
Change-Id: Id6bbdae536a12134899fa57ea799f488d018db00
2016-12-02 17:51:56 -08:00
Erik Kline
0e4cdff76b Don't flush the per-netid cache when adding nameservers.
This wasn't really necessary in the >= Lollipop architecture.

Test: netd_integration_test fails (fixing separately)
Bug: 32517984
Change-Id: I8115bfe913ae6609f64b55161a1c8e28ce2619cf
2016-12-02 04:28:43 +09:00
Dan Willemsen
7ec52b12ef Enable libc/libdl/libm/linker for host bionic
Disables debuggerd integration unless building for android.

Bug: 31559095
Test: Diff out/soong/build.ninja before/after, only change is moving
      linker's libdebuggerd_client static lib to the beginning of the
      list.
Test: lunch aosp_arm64-eng; mmma -j bionic
Change-Id: I62e725f7a9b98b7fe31637d0a835fd5846b0aff0
2016-11-29 21:09:05 +00:00
Elliott Hughes
87c0dba7b1 Check for bad packets in getaddrinfo.c's getanswer.
The near duplicate in gethnamaddr.c was already doing so (this fix
is basically copy and pasted from there, but with both copies modified
to avoid skirting undefined behavior).

Bug: http://b/32322088
Test: browser still works
Change-Id: Ied6662be567fb1bddc7ceb138cae1da77fb57976
(cherry picked from commit 27a4459d94)
2016-11-15 20:19:41 +00:00
Elliott Hughes
dfb74c5f59 Minor copyright header unification.
Regenerating the NOTICE file the other day left me scratching my head at
various "how do they differ?" cases, resolved by this patch.

Test: N/A
Change-Id: I4230bfa1d7ec842a4b9fb8c73dd3b39443d74054
2016-10-24 12:57:55 -07:00
Elliott Hughes
a9209d7a0e Fix some easy cases of __ANDROID__ versus __BIONIC__.
We need to make a clearer distinction for bionic on the host. This patch
doesn't fully address things like "should host bionic try to talk to netd?"
for now, but is a step in the right direction.

Bug: http://b/31559095
Test: bionic tests.
Change-Id: I49812f8b75d9d78c4fd8a8ddf5df1201d63771d6
2016-09-16 18:27:07 -07:00
Elliott Hughes
7b737e43f8 Remove #pragma GCC visibility.
We have better control over visibility now.

Bug: http://b/24767418
Change-Id: Ifa9a1e5af4bd4217db08422050908770247b3b69
2016-07-25 15:57:02 -07:00
Elliott Hughes
f47514dd99 Remove __LIBC_ABI_PUBLIC__.
We have much better control over visibility now, so we don't need to
pollute the headers with cruft.

Bug: http://b/24767418
Change-Id: I349f4c3bc30102477375ad9f80926e560c7c1d8b
2016-07-19 13:56:46 -07:00
Pierre Imai
b0cfefac91 Always update search domain paths.
_resolv_set_nameservers_for_net() so far did not update the search
paths, unless the servers changed as well.

BUG: 28437641
Change-Id: Id31f2d97c173e00357fb2ba95908afb4572c0fc1
(cherry picked from commit 06e2202a4c)
2016-05-12 11:56:42 +09:00
Pierre Imai
6db7e5a10d Merge "Always update search domain paths." 2016-05-12 02:51:23 +00:00
Elliott Hughes
bab9d7954a Remove <net/if_types.h>.
Bug: http://b/28519060
Change-Id: I7481df528b281344879b4aac32551d8c40824195
2016-05-11 15:00:19 -07:00
Pierre Imai
06e2202a4c Always update search domain paths.
_resolv_set_nameservers_for_net() so far did not update the search
paths, unless the servers changed as well.

BUG: 28437641
Change-Id: Id31f2d97c173e00357fb2ba95908afb4572c0fc1
2016-05-11 11:06:55 +09:00
Elliott Hughes
21788265da Remove a duplicate declaration, improve check-symbols-glibc.py.
Change-Id: I97a98dfc8acaa93172386b4475487a05a35a9337
2016-05-06 14:43:50 -07:00
Elliott Hughes
eb9b0a1819 Merge "Move nsswitch.h into libc/dns/include." 2016-05-02 21:11:30 +00:00
Elliott Hughes
af5afdba34 Merge "Remove <net/if_ieee1394.h>." 2016-05-02 21:11:10 +00:00
Elliott Hughes
82140bed6a Remove <net/if_ieee1394.h>.
It's 2016.

Bug: http://b/28519060
Change-Id: Idbb2c40f37e57a87933b8b13b20e15035105e918
2016-05-02 12:35:26 -07:00
Elliott Hughes
42d752754e Move nsswitch.h into libc/dns/include.
Not a public header file except in NetBSD, where it came from. Even
OpenBSD doesn't have it.

Bug: http://b/28519060
Change-Id: Id5feec4a4e8010a9f4433e73b1bfa6f935d884b9
2016-05-02 12:24:58 -07:00
Josh Gao
583a4f8d35 Merge changes I25dca710,I85fdf927,I667fe53e,I46bf95ac
* changes:
  Remove nonexported _ns_flagdata from public header.
  Add platform specific version tags.
  Add __INTRODUCED_IN_FUTURE for unreleased APIs.
  Add versioning information to symbols.
2016-05-02 18:33:04 +00:00
Lorenzo Colitti
edfc5d7b74 Merge "Record the resolution start time on errors." 2016-05-02 11:28:42 +00:00
Pierre Imai
0b1a71f9a4 Record the resolution start time on errors.
Also only record samples on the first try for a server.

BUG: 25731675

Change-Id: I10a68813c6636874e63aca1db661e63e1af72a2d
(cherry picked from commit 8b8611a0e6)
2016-05-02 17:46:16 +09:00
Pierre Imai
8b8611a0e6 Record the resolution start time on errors.
Also only record samples on the first try for a server.

BUG: 25731675

Change-Id: I10a68813c6636874e63aca1db661e63e1af72a2d
2016-05-02 17:39:19 +09:00
Josh Gao
b089e468bd Remove nonexported _ns_flagdata from public header.
Bug: http://b/28178111
Change-Id: I25dca710964099c4e07bf694635db75a72b38508
2016-04-29 16:39:50 -07:00
Josh Gao
c194fd30c6 Delete declarations which don't exist.
Bug: http://b/28178111
Change-Id: I72d5d015d7927a8df24b3973bf8a052053a067fb
2016-04-27 16:50:54 -07:00
Pierre Imai
75746069ea DO NOT MERGE Fix DNS search path info.
Fix the resolver information returned by
android_net_res_stats_get_info_for_net,
erroneously included MAXDNSRCH empty results if no search path was set.

BUG: 25731675
Change-Id: I97ef5d2d47dc62ca403a3323c7f14902e47b29b6
(cherry picked from commit 1b069a990a)
2016-04-27 13:41:42 +09:00
Pierre Imai
1b069a990a Fix DNS search path info.
Fix the resolver information returned by
android_net_res_stats_get_info_for_net,
erroneously included MAXDNSRCH empty results if no search path was set.

BUG: 25731675
Change-Id: I97ef5d2d47dc62ca403a3323c7f14902e47b29b6
2016-04-27 12:24:32 +09:00
Pierre Imai
21bf063727 DO NOT MERGE Add new info functions to resolver for use by Netd.
android_net_res_stats_get_info_for_net returns the current name servers, search
domains, parameters and stats for the given network ID.

android_net_res_stats_aggregate provides statistics such as errors counts from
the raw stats data reported by android_net_res_stats_get_info_for_net.

android_net_res_stats_get_usable_servers uses the data returned by
android_net_res_stats_aggregate to determine which of the servers are
considered valid or broken by the resolver.

BUG: 25731675
Change-Id: I6059b68e5e8b809027a4d3135f6081588bee8a7d
2016-04-21 14:25:10 +09:00
Pierre Imai
589afca92c DO NOT MERGE Store DNS server count in resolv_cache.
Instead of keeping a sentinel after nameservers[], nsaddrinfo[] and
nstats[], store the server count in the structure, freeing up memory and
eliminating the need to enumerate the server count every time
_resolv_is_nameservers_equal_locked() is invoked.

Also increase MAXNS from 3 to 4.

BUG: 28153323
Change-Id: I11a7257af695157c9e32019cd00c67b535b63c75
(cherry picked from commit fff356786f)
2016-04-21 14:16:01 +09:00
Pierre Imai
97c9d73a87 Add new info functions to resolver for use by Netd.
android_net_res_stats_get_info_for_net returns the current name servers, search
domains, parameters and stats for the given network ID.

android_net_res_stats_aggregate provides statistics such as errors counts from
the raw stats data reported by android_net_res_stats_get_info_for_net.

android_net_res_stats_get_usable_servers uses the data returned by
android_net_res_stats_aggregate to determine which of the servers are
considered valid or broken by the resolver.

BUG: 25731675

Change-Id: I6059b68e5e8b809027a4d3135f6081588bee8a7d
2016-04-21 10:07:26 +09:00
Pierre Imai
fff356786f Store DNS server count in resolv_cache.
Instead of keeping a sentinel after nameservers[], nsaddrinfo[] and
nstats[], store the server count in the structure, freeing up memory and
eliminating the need to enumerate the server count every time
_resolv_is_nameservers_equal_locked() is invoked.

Also increase MAXNS from 3 to 4.

BUG: 28153323
Change-Id: I11a7257af695157c9e32019cd00c67b535b63c75
2016-04-21 10:07:24 +09:00
Elliott Hughes
26fda778f7 Fix b64_pton.
This was fixed upstream years ago. While we're here, let's switch to the
OpenBSD copy (because that's our majority upstream BSD, not because they
found and fixed this bug first).

Bug: http://b/28035006
Change-Id: I53dd915a8122bfd7a6d58f01f9902d1586a47e23
2016-04-06 12:08:45 -07:00
Pierre Imai
e4e4e9da72 DO NOT MERGE: Reduce the amount of logging in Bionic's resolver.
Change-Id: I3b7b5ef5a5ee6ba3ad8654f792400d42d5ecd4b9
2016-04-06 11:30:02 +09:00
Pierre Imai
360800d829 Reduce the amount of logging in Bionic's resolver.
Change-Id: I250d9a352f1fa0cafef349d0e23f72a9dd8e399d
2016-04-06 11:25:30 +09:00
Pierre Imai
8b50d08e82 DO NOT MERGE: Fix off-by-one error in res_cache.c
(cherry picked from commit 03844d8cdb)

Change-Id: Ib5fff46ac9211716a1577ee25bb22461c489ea9f
2016-04-06 10:44:00 +09:00
Pierre Imai
4d8e740b08 DO NOT MERGE: Ignore unreliable DNS servers.
Collect statistics about DNS query success state and delay. Ignore
servers that have been tried at least five times and have a success rate
of < 0.25. Retry these servers once every 180s.

Bug: 25731675

(cherry picked from commit 6b3f0d65f2)

Change-Id: Id989404b14fd885fb31a5a4de36a4186be1c9ad1
2016-04-06 10:41:07 +09:00
Pierre Imai
03844d8cdb Fix off-by-one error in res_cache.c
Change-Id: I58264902c123b3bc0d392d17837aa537ca0a3ca2
2016-04-05 16:19:57 +09:00
Pierre Imai
6b3f0d65f2 Ignore unreliable DNS servers.
Collect statistics about DNS query success state and delay. Ignore
servers that have been tried at least five times and have a success rate
of < 0.25. Retry these servers once every 180s.

Bug: 25731675
Change-Id: I78e24f43e388dca82fb81835e1796f4c7dce8da3
2016-04-05 11:42:43 +09:00
Pierre Imai
9db1f3efa8 Copy the entire zero-separated DNS seach domain string.
The DNS search string contains zeros as domain separator. The resolver
code erroneously used strlcpy(), which resulted in only the first domain
to be copied. The code uses pointers into this string to access the
individual domains. Since the structure is zero-initialized, this bug only
resulted in zero-length domains instead of accessing unitialized memory.

BUG: 27312811
Change-Id: Ia9d066c405dfcc5e82d6766d93ead2ce574e7b0d
(cherry picked from commit 0967fc7e59)
2016-03-29 12:29:24 +09:00
Erik Kline
7bbb181bf0 Don't leak sockets if setsockopt() or fchown() fail.
Change-Id: Idcf8c08ff50d21c3a04b7ef80c4044f3f9762f2b
2016-03-09 12:11:13 +09:00
Pierre Imai
0967fc7e59 Copy the entire zero-separated DNS seach domain string.
The DNS search string contains zeros as domain separator. The resolver
code erroneously used strlcpy(), which resulted in only the first domain
to be copied. The code uses pointers into this string to access the
individual domains. Since the structure is zero-initialized, this bug only
resulted in zero-length domains instead of accessing unitialized memory.

BUG: 27312811
Change-Id: Ia9d066c405dfcc5e82d6766d93ead2ce574e7b0d
2016-02-29 16:50:38 +09:00
Elliott Hughes
b83d6747fa Improve FORTIFY failure diagnostics.
Our FORTIFY _chk functions' implementations were very repetitive and verbose
but not very helpful. We'd also screwed up and put the SSIZE_MAX checks where
they would never fire unless you actually had a buffer as large as half your
address space, which probably doesn't happen very often.

Factor out the duplication and take the opportunity to actually show details
like how big the overrun buffer was, or by how much it was overrun.

Also remove the obsolete FORTIFY event logging.

Also remove the unused __libc_fatal_no_abort.

This change doesn't improve the diagnostics from the optimized assembler
implementations.

Change-Id: I176a90701395404d50975b547a00bd2c654e1252
2016-02-26 22:06:17 -08:00
Elliott Hughes
506c6deff7 Sync with upstream OpenBSD.
Also some minor build cleanup.

Change-Id: Ibd20602d7ea45685f0c47fceb00ffd6c7ae35954
2016-01-15 16:30:18 -08:00
Elliott Hughes
dbb17b2831 Fix alignment after variable-length data.
In the serialized output from netd, the strings come first. Some code
assumes -- reasonably enough -- that it can do unaligned reads of pointers,
so we need to ensure alignment after all the strings.

(cherrypick of 65dd858239c4e32a5a1afbc14ac30dbcdd2a50a3.)

Bug: http://b/21192318
Change-Id: I456639127db9a2583f7f738e6b8103375d9387fd
2015-07-06 14:43:28 -07:00
Elliott Hughes
65dd858239 Fix alignment after variable-length data.
In the serialized output from netd, the strings come first. Some code
assumes -- reasonably enough -- that it can do unaligned reads of pointers,
so we need to ensure alignment after all the strings.

Bug: http://b/21192318
Change-Id: I456639127db9a2583f7f738e6b8103375d9387fd
2015-07-06 14:37:46 -07:00
Erik Kline
754f669076 Pass around struct android_net_context for better behaviour
Group network context elements in to a single struct and
add a version of android_getaddrinfofornet() that accepts it.

The introduction of UID-based routing means that the UID is an
integral part of the network context when evaluating connectivity,
sorting addresses, etc.

Also, introduce a distinction between DNS netids/marks and those
expected to be used by the application.  This can be important
when the network an application is using is not the same as the
network on which DNS queries will be issued.

Additionally, de-duplicate the UDP connect logic (collapse both
_test_connect() and _find_src_addr() into just the latter).

Bug: 19470192
Bug: 20733156
Bug: 21832279
Change-Id: If16c2f4744695f507993afdac078ca105eb5d3e4
(cherry picked from commit 01e37c9665)
2015-06-30 12:12:08 +09:00