Skip to content

Commit

Permalink
Cherry pick PR #3972: Prioritize IPv4 addresses over IPv6 (#3976)
Browse files Browse the repository at this point in the history
Refer to the original PR: #3972

Changes the default RFC3484 address ordering to prefer IPv4 for current
versions of Cobalt. This restores the behavior in prior Cobalt versions.

Test-on-device: True

b/359376180

Co-authored-by: Kaido Kert <[email protected]>
Co-authored-by: Jelle Foks <[email protected]>
  • Loading branch information
3 people authored Aug 14, 2024
1 parent 1ce5a18 commit 2d3f3d3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions net/dns/address_sorter_posix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,13 @@ const AddressSorterPosix::PolicyEntry kDefaultPrecedenceTable[] = {
// ::/0 -- any
{{}, 0, 40},
// ::ffff:0:0/96 -- IPv4 mapped
#if defined(STARBOARD)
// Cobalt currently prioritizes IPv4 addresses higher, as
// suggested in section 10.3 of RFC3484
{{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF}, 96, 100},
#else
{{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF}, 96, 35},
#endif
// 2002::/16 -- 6to4
{{
0x20,
Expand Down
4 changes: 4 additions & 0 deletions net/dns/address_sorter_posix_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,11 @@ TEST_P(AddressSorterPosixSyncOrAsyncTest, Rule6) {
AddMapping("2001::1", "2001::10"); // Teredo
const char* const addresses[] = {"2001::1", "::ffff:1234:1", "ff32::1", "::1",
nullptr};
#if defined(STARBOARD)
const int order[] = { 1, 3, 2, 0, -1 };
#else
const int order[] = { 3, 2, 1, 0, -1 };
#endif
Verify(addresses, order);
}

Expand Down

0 comments on commit 2d3f3d3

Please sign in to comment.