-
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
Define Ipv6Instance, implementation and tests. Not yet used except in… #520
Conversation
include/envoy/network/address.h
Outdated
/** | ||
* @return the 16-byte IPv6 address in network byte order. | ||
*/ | ||
virtual std::string address() const PURE; |
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.
std::array<uint8_t, 16> ?
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.
Done.
|
||
std::string Ipv6Instance::Ipv6Helper::makeFriendlyAddress() const { | ||
char str[INET6_ADDRSTRLEN]; | ||
if (nullptr == inet_ntop(AF_INET6, &address_.sin6_addr, str, INET6_ADDRSTRLEN)) { |
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.
I don't think this can actually happen? I would just ASSERT that it returns non-null if you want (might want to fix IPv4 code above to do the same thing).
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.
Done.
ip_.ipv6_.address_.sin6_family = AF_INET; | ||
ip_.ipv6_.address_.sin6_port = htons(port); | ||
|
||
// TODO: Consider pulling this out of ctor flow and into a static method used to construct |
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.
I know there is a larger offline conversation happening around exceptions right now. If possible I would rather not change course and/or code style (and pollute this PR) until we finish that offline conversation. Assuming we are using exceptions, this is the right way to structure this code (and throwing exceptions out of constructors is fine). If we are not using exceptions and are going to actively remove them, a whole lot of code has to be changed, and it seems like we should do it at that point if that actually transpires.
cc @tschroed
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.
Comments removed.
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.
@jamessynge did you forget to push a commit somewhere? You mention addressing comments in a commit below but I don't see a change here.
* change return type of Ipv6::address to std::array<uint8_t, 16> * Replace one check with an ASSERT * Remove some comments
Are you looking for any other changes? |
@jamessynge the TODO for comments is still there as well as the error checking for inet_ntop. It sounds like you fixed that but I don't see the delta. Did you forget to push something? |
How odd! I'll double check when back in the office.
On Mar 2, 2017 5:11 PM, "Matt Klein" <notifications@github.com> wrote:
@jamessynge <https://github.com/jamessynge> the TODO for comments is still
there as well as the error checking for inet_ntop. It sounds like you fixed
that but I don't see the delta. Did you forget to push something?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#520 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ABYmU1_XMXW2JtschGpiRYGq0Kl1Ebz9ks5rhz6hgaJpZM4MO7fu>
.
|
* Replace one if check with an ASSERT. * Remove some comments.
Apparently I suck at git (still new to the tool), so somehow I lost some changes that I'm pretty sure I made. Oh well, they were easy to repeat. PTAL |
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.
looks good, tiny nit
memset(&ip_.ipv6_.address_, 0, sizeof(ip_.ipv6_.address_)); | ||
ip_.ipv6_.address_.sin6_family = AF_INET; | ||
ip_.ipv6_.address_.sin6_port = htons(port); | ||
if (address != "") { |
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: !address.empty()
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.
Done (if I didn't mess up the git foo again).
} | ||
|
||
int Ipv6Instance::socket(SocketType type) const { | ||
return ::socket(AF_INET, flagsFromSocketType(type), 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.
@jamessynge sorry I didn't notice this before, but this should be AF_INET6. (I'm sure you would have noticed that when you start using this). In follow ups can you make sure that there is full coverage for the new code? There is a bunch missing now.
Will do, and thanks for noticing.
…On Mar 4, 2017 1:25 PM, "Matt Klein" ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In source/common/network/address_impl.cc
<#520 (comment)>:
> +}
+
+Ipv6Instance::Ipv6Instance(uint32_t port) : Ipv6Instance("", port) {}
+
+int Ipv6Instance::bind(int fd) const {
+ return ::bind(fd, reinterpret_cast<const sockaddr*>(&ip_.ipv6_.address_),
+ sizeof(ip_.ipv6_.address_));
+}
+
+int Ipv6Instance::connect(int fd) const {
+ return ::connect(fd, reinterpret_cast<const sockaddr*>(&ip_.ipv6_.address_),
+ sizeof(ip_.ipv6_.address_));
+}
+
+int Ipv6Instance::socket(SocketType type) const {
+ return ::socket(AF_INET, flagsFromSocketType(type), 0);
@jamessynge <https://github.com/jamessynge> sorry I didn't notice this
before, but this should be AF_INET6. (I'm sure you would have noticed that
when you start using this). In follow ups can you make sure that there is
full coverage for the new code? There is a bunch missing now.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#520 (review)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ABYmUzjbobVcuvYTPTKJMP6RNGWxG3nqks5riax8gaJpZM4MO7fu>
.
|
* Add integration tests. * add fault_inject_test * format * Update comment. * fix format.
Description: after a bit more discussion we have decided to go ahead and make buffering configurable. This PR revives #456 Risk Level: med - adds new surface area to the API Testing: local apps and CI Signed-off-by: Jose Nino <jnino@lyft.com> Signed-off-by: JP Simard <jp@jpsim.com>
Description: after a bit more discussion we have decided to go ahead and make buffering configurable. This PR revives #456 Risk Level: med - adds new surface area to the API Testing: local apps and CI Signed-off-by: Jose Nino <jnino@lyft.com> Signed-off-by: JP Simard <jp@jpsim.com>
… tests. Partially addressing #351