Skip to content

Always use IPv6 sockets on Android#21803

Merged
mattklein123 merged 8 commits intomainfrom
android-v6
Jun 22, 2022
Merged

Always use IPv6 sockets on Android#21803
mattklein123 merged 8 commits intomainfrom
android-v6

Conversation

@mattklein123
Copy link
Member

@mattklein123 mattklein123 commented Jun 21, 2022

Investigation shows that Android always uses IPv6 dual stack sockets. There is a chance that some long tail connectivity issues are related to this. This change adds a runtime guard (applicable to Android only) which will force use of IPv6 sockets and translate IPv4 addresses to mapped IPv6 addresses upon connection. This is the same as what is done for Java platform sockets.

Risk Level: None, runtime guarded to false on Android.
Testing: No possible tests here. EM will provide testing.
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features: Android only
Runtime guard: envoy.reloadable_features.android_always_use_v6 (default false)

Signed-off-by: Matt Klein <mklein@lyft.com>
Signed-off-by: Matt Klein <mklein@lyft.com>
Signed-off-by: Matt Klein <mklein@lyft.com>
Signed-off-by: Matt Klein <mklein@lyft.com>
Signed-off-by: Matt Klein <mklein@lyft.com>
@mattklein123
Copy link
Member Author

cc @Reflejo @alyssawilk @Augustyniak

Augustyniak
Augustyniak previously approved these changes Jun 21, 2022
Copy link
Contributor

@alyssawilk alyssawilk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeesh, good find. Any idea if this is true for the versions of android E-M supports?

// Used to track if runtime is initialized.
FALSE_RUNTIME_GUARD(envoy_reloadable_features_runtime_initialized);
// TODO(mattklein123): Flip this to true and/or remove completely once verified by Envoy Mobile.
FALSE_RUNTIME_GUARD(envoy_reloadable_features_android_always_use_v6);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also please unit test, or add unit tests to the TODO here if the timing is too tight.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have a suggestion of how to unit test this in this repo? This is all behind an android only ifdef.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

random drive by comment (ignore me if this doesnt make sense) can you make this:

#if defined(__ANDROID_API__) || defined(ENVOY_FORCE_ANDROID)

and add a bazel defines to test it?

if you want to resuse this you can wrap it with a constexpr bool function and reuse it in the codebase.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I would prefer to not have a build flag for it since that will be harder to test. I think Alyssa's suggestion is good to just refactor it and add a unit test. I can do that but will do it as a follow up.

@mattklein123
Copy link
Member Author

Any idea if this is true for the versions of android E-M supports?

I haven't looked back through the Android history. It's true on main branch. I can take a look through previous versions of someone can tell me which versions to look back to.

@mattklein123
Copy link
Member Author

I haven't looked back through the Android history. It's true on main branch. I can take a look through previous versions of someone can tell me which versions to look back to.

I looked and this applies all the way back to Android 6: https://cs.android.com/android/platform/superproject/+/android-6.0.1_r81:libcore/luni/src/main/native/libcore_io_Posix.cpp;l=91-128

Signed-off-by: Matt Klein <mklein@lyft.com>
@alyssawilk
Copy link
Contributor

Give connect method a boolean argument which defaults to forceV6ForAndroid() and explicitly set the boolean in test? Otherwise test upstream for E-M on android only CI? Again I'm fine with TODO but I think it's possible to test with a little refactor work.

@mattklein123
Copy link
Member Author

Otherwise test upstream for E-M on android only CI?

Yes my assumption is this will be implicitly tested in upstream EM CI, but yeah, let me add a TODO for unit testing this if this solution holds.

alyssawilk
alyssawilk previously approved these changes Jun 21, 2022
Copy link
Contributor

@alyssawilk alyssawilk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not super confident of the change but as it's off by default and y'all are testing it I'm totally fine letting you folks figure out if there are corner cases missed :-) Good luck!

Augustyniak added a commit to envoyproxy/envoy-mobile that referenced this pull request Jun 21, 2022
Description: Bumping upstream Envoy sha so that it includes recent changes that allow us to force IPv6 use on Android. The Envoy sha that we use in this PR is NOT from Envoy main. The idea is to pick up only @mattklein123's change from envoyproxy/envoy#21803 without any other changes. We are going to move back to Envoy main later this week.
Risk Level: Low, disabled by default
Testing: Manual, passed
Docs Changes: N/A
Release Notes: N/A

Signed-off-by: Rafal Augustyniak <raugustyniak@lyft.com>
Signed-off-by: Matt Klein <mklein@lyft.com>
Signed-off-by: Matt Klein <mklein@lyft.com>
@alyssawilk
Copy link
Contributor

/retest

@repokitteh-read-only
Copy link

Retrying Azure Pipelines:
Retried failed jobs in: envoy-presubmit

🐱

Caused by: a #21803 (comment) was created by @alyssawilk.

see: more, trace.

@mattklein123 mattklein123 enabled auto-merge (squash) June 22, 2022 14:44
@mattklein123 mattklein123 merged commit 665b4d5 into main Jun 22, 2022
@mattklein123 mattklein123 deleted the android-v6 branch June 22, 2022 15:17
Amila-Rukshan pushed a commit to Amila-Rukshan/envoy that referenced this pull request Jun 28, 2022
Signed-off-by: Matt Klein <mklein@lyft.com>
Signed-off-by: Amila Senadheera <amila.15@cse.mrt.ac.lk>
Augustyniak added a commit to envoyproxy/envoy-mobile that referenced this pull request Jun 28, 2022
Description: Bumping upstream Envoy sha so that it includes recent changes that allow us to force IPv6 use on Android. The Envoy sha that we use in this PR is NOT from Envoy main. The idea is to pick up only @mattklein123's change from envoyproxy/envoy#21803 without any other changes. We are going to move back to Envoy main later this week.
Risk Level: Low, disabled by default
Testing: Manual, passed
Docs Changes: N/A
Release Notes: N/A

Signed-off-by: Rafal Augustyniak <raugustyniak@lyft.com>
Augustyniak added a commit to envoyproxy/envoy-mobile that referenced this pull request Sep 1, 2022
Description: Forcing the use of IPv6 socket addresses is required to make Envoy Mobile work with some carriers when running on an Android device. The option was introduced upstream in envoyproxy/envoy#21803.
Risk Level: Low, enabled a well tested option.
Testing: Manual, launched the example app
Docs Changes: Updated
Release Notes: Updated

Signed-off-by: Rafal Augustyniak <raugustyniak@lyft.com>
colibie pushed a commit to colibie/envoy-mobile that referenced this pull request Sep 21, 2022
Description: Forcing the use of IPv6 socket addresses is required to make Envoy Mobile work with some carriers when running on an Android device. The option was introduced upstream in envoyproxy/envoy#21803.
Risk Level: Low, enabled a well tested option.
Testing: Manual, launched the example app
Docs Changes: Updated
Release Notes: Updated

Signed-off-by: Rafal Augustyniak <raugustyniak@lyft.com>
Signed-off-by: Chidera Olibie <colibie@google.com>
jpsim pushed a commit that referenced this pull request Nov 29, 2022
Description: Bumping upstream Envoy sha so that it includes recent changes that allow us to force IPv6 use on Android. The Envoy sha that we use in this PR is NOT from Envoy main. The idea is to pick up only @mattklein123's change from #21803 without any other changes. We are going to move back to Envoy main later this week.
Risk Level: Low, disabled by default
Testing: Manual, passed
Docs Changes: N/A
Release Notes: N/A

Signed-off-by: Rafal Augustyniak <raugustyniak@lyft.com>
Signed-off-by: JP Simard <jp@jpsim.com>
jpsim pushed a commit that referenced this pull request Nov 29, 2022
Description: Forcing the use of IPv6 socket addresses is required to make Envoy Mobile work with some carriers when running on an Android device. The option was introduced upstream in #21803.
Risk Level: Low, enabled a well tested option.
Testing: Manual, launched the example app
Docs Changes: Updated
Release Notes: Updated

Signed-off-by: Rafal Augustyniak <raugustyniak@lyft.com>
Signed-off-by: JP Simard <jp@jpsim.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants