Skip to content

os syscalls: add getifaddrs to singleton - #18821

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

mattklein123 merged 28 commits into
mainfrom
getifaddrs-v2

Conversation

@junr03

@junr03 junr03 commented Oct 28, 2021

Copy link
Copy Markdown
Member

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 [email protected]

Jose Nino added 7 commits October 27, 2021 14:28
Signed-off-by: Jose Nino <[email protected]>
Jose Nino
fmt
Signed-off-by: Jose Nino <[email protected]>
Signed-off-by: Jose Nino <[email protected]>
Signed-off-by: Jose Nino <[email protected]>
Jose Nino
fix
Signed-off-by: Jose Nino <[email protected]>
Comment thread envoy/api/os_sys_calls.h

// 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
@junr03

junr03 commented Nov 10, 2021

Copy link
Copy Markdown
Member Author

@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 <[email protected]>
Signed-off-by: Jose Nino <[email protected]>
Jose Nino
fix
Signed-off-by: Jose Nino <[email protected]>
Jose Nino
fix
Signed-off-by: Jose Nino <[email protected]>
Jose Nino
fmt
Signed-off-by: Jose Nino <[email protected]>
Jose Nino added 2 commits November 11, 2021 15:48
Jose Nino
fix
Signed-off-by: Jose Nino <[email protected]>
Jose Nino
fmt
Signed-off-by: Jose Nino <[email protected]>
Jose Nino
fix
Signed-off-by: Jose Nino <[email protected]>
Signed-off-by: Jose Nino <[email protected]>
Signed-off-by: Jose Nino <[email protected]>

@mattklein123 mattklein123 left a comment

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.

LGTM with small comments, thanks.

/wait

Comment thread envoy/api/os_sys_calls.h Outdated
// 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 <[email protected]>
Signed-off-by: Jose Nino <[email protected]>
Signed-off-by: Jose Nino <[email protected]>
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