Skip to content

Commit

Permalink
Prioritize IPv4 addresses over IPv6 (#3972)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
kaidokert authored Aug 13, 2024
1 parent 9755f54 commit bf34fc7
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 bf34fc7

Please sign in to comment.