-
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
address refactor #429
address refactor #429
Conversation
This is a large refactor that moves away from representing addresses internally as strings of "URL" form into proper objects. With this change in place, it should be very straightforward to add IPv6 support, as most places in the code no longer need to understand anything about the underlying address. Additionally, adding NT support in the future should also be easier. There are still some unfortunate legacy aspects, such as the fact that when loading from configuration we still parse tcp:// as well as unix:// style addresses. In the future this should likely become ip:// as well as pipe:// but we will probably need to continue to support both. Note that although this change is huge in number of lines, most of it is very straightforward, and certain portions of the code have become substantially simpler such as listener handling and client connection handling. Fixes #390
@lyft/network-team @jamessynge I will be OOO tomorrow and am probably going to add some more tests and possibly do a little more cleanup, but this should be ready for a first pass. As I said in the title, though this change is a huge number of lines, most of it is very straightforward. |
6a56c05
to
86aeb4b
Compare
include/envoy/network/address.h
Outdated
virtual const std::string& asString() const PURE; | ||
|
||
/** | ||
* Bind a socket to to this address. The socket should have been created with a call to socket() |
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.
duplicate to
source/common/network/utility.h
Outdated
* @param url supplies the url to resolve. | ||
* @return EventAddrInfoPtr the resolved address. | ||
* @return a resolved 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: return type instead of a
source/common/network/utility.h
Outdated
|
||
/** | ||
* Retrieve the original destination address from an accepted fd. | ||
* The address (IP and port) may be not local and the port may differ from | ||
* the listener port if the packets were redirected using iptables | ||
* @param fd is the descriptor returned by accept() | ||
* @param orig_addr is the data structure that contains the original address | ||
* @return true if the operation succeeded, false otherwise | ||
* @return the original destination or nullptr not available. |
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.
nullptr if not...
// TODO: Currently the DNS interface does not consider port. We need to make a new | ||
// address that has port in it. We need to both support IPv6 as well as potentially | ||
// move port handling into the DNS interface itself, which would work better for | ||
// SRV. |
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.
general knowledge question: What does SRV stand for?
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.
@ccaraman updated |
* Bind a socket to this address. The socket should have been created with a call to socket() on | ||
* this object. | ||
* @param fd supplies the platform socket handle. | ||
* @return the platform error code. |
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.
and zero if no errors?
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.
it's platform specific. The idea is we can use this eventually to support NT.
* Connect a socket to this address. The socket should have been created with a call to socket() | ||
* on this object. | ||
* @param fd supplies the platform socket handle. | ||
* @return the platform error code. |
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.
same here
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.
same
@@ -94,7 +95,7 @@ void AsyncStreamImpl::encodeTrailers(HeaderMapPtr&& trailers) { | |||
|
|||
void AsyncStreamImpl::sendHeaders(HeaderMap& headers, bool end_stream) { | |||
headers.insertEnvoyInternalRequest().value(Headers::get().EnvoyInternalRequestValues.True); | |||
headers.insertForwardedFor().value(parent_.config_.local_info_.address()); | |||
Utility::appendXff(headers, *parent_.config_.local_info_.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.
Is that intended to add address to XFF instead of rewriting one? iirc, if we have 2 addresses in xff, isInternal and other things will not work as expected on the upstream Envoy side, but i might be missing something
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.
appendXff now has logic to deal with not appending if not IP address type. Sharing code.
Automatic merge from submit-queue. [DO NOT MERGE] Auto PR to update dependencies of mixerclient This PR will be merged automatically once checks are successful. ```release-note none ```
Signed-off-by: Piotr Sikora <piotrsikora@google.com>
… (#166) * Make callout responses accessible from stream context. (envoyproxy#429) Signed-off-by: Piotr Sikora <piotrsikora@google.com> * review: Kick CI. Signed-off-by: Piotr Sikora <piotrsikora@google.com>
Signed-off-by: Piotr Sikora <piotrsikora@google.com>
Signed-off-by: Mike Schore <mike.schore@gmail.com> Signed-off-by: JP Simard <jp@jpsim.com>
Signed-off-by: Mike Schore <mike.schore@gmail.com> Signed-off-by: JP Simard <jp@jpsim.com>
This is a large refactor that moves away from representing addresses
internally as strings of "URL" form into proper objects. With this
change in place, it should be very straightforward to add IPv6
support, as most places in the code no longer need to understand
anything about the underlying address. Additionally, adding NT support
in the future should also be easier.
There are still some unfortunate legacy aspects, such as the fact that
when loading from configuration we still parse tcp:// as well as unix://
style addresses. In the future this should likely become ip:// as well
as pipe:// but we will probably need to continue to support both.
Note that although this change is huge in number of lines, most of it is
very straightforward, and certain portions of the code have become
substantially simpler such as listener handling and client connection
handling.
Fixes #390