-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
network: obtain address instance from fd, bind-to-zero in ListenSocke… #645
Conversation
…tImpl. Refactor 33ece57 to assist with zero binding from integration tests.
7eb448a
to
46be529
Compare
socklen_t ss_len = sizeof ss; | ||
const int rc = ::getsockname(fd, reinterpret_cast<sockaddr*>(&ss), &ss_len); | ||
if (rc != 0) { | ||
const int err = errno; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: local var not needed
} | ||
default: | ||
throw EnvoyException(fmt::format("Unexpected family in getsockname result: {}", ss.ss_family)); | ||
return nullptr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: line can't be reached.
const struct sockaddr_in* sin = reinterpret_cast<const struct sockaddr_in*>(&ss); | ||
ASSERT(AF_INET == sin->sin_family); | ||
return InstanceConstSharedPtr(new Address::Ipv4Instance(sin)); | ||
break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: line can't be reached.
const struct sockaddr_in6* sin6 = reinterpret_cast<const struct sockaddr_in6*>(&ss); | ||
ASSERT(AF_INET6 == sin6->sin6_family); | ||
return InstanceConstSharedPtr(new Address::Ipv6Instance(*sin6)); | ||
break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: line can't be reached.
throw EnvoyException(fmt::format("Unexpected family in getsockname result: {}", ss.ss_family)); | ||
return nullptr; | ||
} | ||
return nullptr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Would just do NOT_REACHED here if compiler complains
@@ -15,6 +15,11 @@ void ListenSocketImpl::doBind() { | |||
throw EnvoyException( | |||
fmt::format("cannot bind '{}': {}", local_address_->asString(), strerror(errno))); | |||
} | |||
if (local_address_->ip()->port() == 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doBind() is also called in UdsListenSocket case so I think this line will crash without checking if ip() is not null or type is IP
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, didn't run the full tests before pushing, will fix.
Fixed, tests pass (this is what happens when you write code while in the middle of a meting ;) ) |
@@ -15,6 +15,12 @@ void ListenSocketImpl::doBind() { | |||
throw EnvoyException( | |||
fmt::format("cannot bind '{}': {}", local_address_->asString(), strerror(errno))); | |||
} | |||
if (local_address_->type() == Address::Type::Ip && local_address_->ip() != nullptr && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: local_address_->ip() != nullptr is guaranteed if local_address_->type() == Address::Type::Ip
Description: update the envoy ref. This bump includes #9767 which will enable us to turn on process logs for Android devices in a subsequent PR. Risk Level: med, as always with a ref update. Testing: CI Signed-off-by: Jose Nino <[email protected]> Signed-off-by: JP Simard <[email protected]>
Description: update the envoy ref. This bump includes #9767 which will enable us to turn on process logs for Android devices in a subsequent PR. Risk Level: med, as always with a ref update. Testing: CI Signed-off-by: Jose Nino <[email protected]> Signed-off-by: JP Simard <[email protected]>
…tImpl.
Refactor 33ece57 to assist with zero binding from integration tests.