Skip to content

os syscalls: add getifaddrs to singleton#18821

Merged
mattklein123 merged 28 commits intomainfrom
getifaddrs-v2
Nov 19, 2021
Merged

os syscalls: add getifaddrs to singleton#18821
mattklein123 merged 28 commits intomainfrom
getifaddrs-v2

Conversation

@junr03
Copy link
Copy Markdown
Member

@junr03 junr03 commented Oct 28, 2021

Commit Message: os syscalls - add getifaddrs to singleton
Additional Description: this PR reverts #18566 and adjusts code in order to be able to compile against android in Envoy Mobile
Risk Level: low, new API. Also tested against existing code.
Testing: existing UT.

Signed-off-by: Jose Nino jnino@lyft.com

Jose Nino added 7 commits October 27, 2021 14:28
)"

This reverts commit b777701.

Signed-off-by: Jose Nino <jnino@lyft.com>
Signed-off-by: Jose Nino <jnino@lyft.com>
fmt
Signed-off-by: Jose Nino <jnino@lyft.com>
Signed-off-by: Jose Nino <jnino@lyft.com>
Signed-off-by: Jose Nino <jnino@lyft.com>
Signed-off-by: Jose Nino <jnino@lyft.com>
fix
Signed-off-by: Jose Nino <jnino@lyft.com>

// Small struct to avoid exposing ifaddrs -- which is not defined in all platforms -- to the
// codebase.
struct InterfaceAddress {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

happy to move this to address.h if we think it makes more sense there. I couldn't decide.

Jose Nino added 8 commits November 4, 2021 14:20
Signed-off-by: Jose Nino <jnino@lyft.com>
Signed-off-by: Jose Nino <jnino@lyft.com>
Signed-off-by: Jose Nino <jnino@lyft.com>
Signed-off-by: Jose Nino <jnino@lyft.com>
fmt
Signed-off-by: Jose Nino <jnino@lyft.com>
Signed-off-by: Jose Nino <jnino@lyft.com>
win
Signed-off-by: Jose Nino <jnino@lyft.com>
@junr03
Copy link
Copy Markdown
Member Author

junr03 commented Nov 10, 2021

@mattklein123 still not done updating. I will ping you when this is ready for review.

Jose Nino added 4 commits November 10, 2021 10:18
Signed-off-by: Jose Nino <jnino@lyft.com>
Signed-off-by: Jose Nino <jnino@lyft.com>
fix
Signed-off-by: Jose Nino <jnino@lyft.com>
fix
Signed-off-by: Jose Nino <jnino@lyft.com>
fmt
Signed-off-by: Jose Nino <jnino@lyft.com>
Jose Nino added 2 commits November 11, 2021 15:48
fix
Signed-off-by: Jose Nino <jnino@lyft.com>
fmt
Signed-off-by: Jose Nino <jnino@lyft.com>
fix
Signed-off-by: Jose Nino <jnino@lyft.com>
Signed-off-by: Jose Nino <jnino@lyft.com>
Signed-off-by: Jose Nino <jnino@lyft.com>
Copy link
Copy Markdown
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

LGTM with small comments, thanks.

/wait

// Small struct to avoid exposing ifaddrs -- which is not defined in all platforms -- to the
// codebase.
struct InterfaceAddress {
InterfaceAddress(absl::string_view ifa_name, unsigned int ifa_flags,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: can you just s/ifa/interface. It's easier to read.

// TODO: eliminate this branching by upstreaming an alternative Android implementation
// e.g.: https://github.com/envoyproxy/envoy-mobile/blob/main/third_party/android/ifaddrs-android.h
#if defined(__ANDROID_API__) && __ANDROID_API__ < 24
if (alternate_getifaddrs_.has_value()) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Shouldn't you be doing this in all cases otherwise the interface docs are misleading?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@mattklein123 I think I might be misunderstanding your point. Where else should I be checking this that is not checked?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You should check this outside of the #ifdef ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I see what you mean now @mattklein123. My thought was that in posix the class would default to true for supporting getifaddrs regardless of if an alternate implementation is given. Only for Android<24 do we need to check for existence of an alternate implementation.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

OK I see. Makes sense. Can you just add a small comment?

/wait

Signed-off-by: Jose Nino <jnino@lyft.com>
Signed-off-by: Jose Nino <jnino@lyft.com>
Signed-off-by: Jose Nino <jnino@lyft.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.

3 participants