Skip to content
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

Merged
merged 5 commits into from
Mar 4, 2017

Conversation

jamessynge
Copy link
Contributor

… tests. Partially addressing #351

/**
* @return the 16-byte IPv6 address in network byte order.
*/
virtual std::string address() const PURE;
Copy link
Member

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> ?

Copy link
Contributor Author

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)) {
Copy link
Member

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).

Copy link
Contributor Author

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
Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comments removed.

Copy link
Member

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.

@mattklein123 mattklein123 reopened this Mar 1, 2017
* change return type of Ipv6::address to std::array<uint8_t, 16>
* Replace one check with an ASSERT
* Remove some comments
@jamessynge
Copy link
Contributor Author

Are you looking for any other changes?

@mattklein123
Copy link
Member

@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?

@jamessynge
Copy link
Contributor Author

jamessynge commented Mar 2, 2017 via email

* Replace one if check with an ASSERT.
* Remove some comments.
@jamessynge
Copy link
Contributor Author

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

Copy link
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.

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 != "") {
Copy link
Member

Choose a reason for hiding this comment

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

nit: !address.empty()

Copy link
Contributor Author

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).

@mattklein123 mattklein123 merged commit c932d60 into envoyproxy:master Mar 4, 2017
}

int Ipv6Instance::socket(SocketType type) const {
return ::socket(AF_INET, flagsFromSocketType(type), 0);
Copy link
Member

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.

@jamessynge
Copy link
Contributor Author

jamessynge commented Mar 4, 2017 via email

rshriram pushed a commit to rshriram/envoy that referenced this pull request Oct 30, 2018
* Add integration tests.

* add fault_inject_test

* format

* Update comment.

* fix format.
jpsim pushed a commit that referenced this pull request Nov 28, 2022
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>
jpsim pushed a commit that referenced this pull request Nov 29, 2022
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>
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.

2 participants