Skip to content

address_impl: Return an Ipv4Instance for v4-mapped v6 addresses.#2309

Merged
zuercher merged 4 commits intoenvoyproxy:masterfrom
jrajahalme:transparent-v4-compatible-v6
Jan 5, 2018
Merged

address_impl: Return an Ipv4Instance for v4-mapped v6 addresses.#2309
zuercher merged 4 commits intoenvoyproxy:masterfrom
jrajahalme:transparent-v4-compatible-v6

Conversation

@jrajahalme
Copy link
Copy Markdown
Contributor

Recognize v6-mapped v4 addresses and use IPv4 address
instances to represent them so that rest of Envoy can treat v4 connections
the same regardless if they were received from a v6 or a v4 socket.

Signed-off-by: Jarno Rajahalme [email protected]

Recognize v6-mapped v4 addresses and use IPv4 address
instances to represent them so that rest of Envoy can treat v4 connections
the same regardless if they were received from a v6 or a v4 socket.

Signed-off-by: Jarno Rajahalme <[email protected]>
Copy link
Copy Markdown
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.

@jrajahalme seems reasonable to me and thanks for the change, but will need a test. Thank you.

Copy link
Copy Markdown
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

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

LGTM modulo tests. This is neat and has some benefits (e.g. logging). Thanks.

@jrajahalme jrajahalme force-pushed the transparent-v4-compatible-v6 branch from b404f30 to 06e0b1d Compare January 4, 2018 18:15
@jrajahalme
Copy link
Copy Markdown
Contributor Author

OK, thanks! Working on OSX fix for missing s6_addr32 and tests :-)

Check that addressFromSockAddr() returns an Ipv4Instance for an
IPv4-mapped IPv6 address.

Signed-off-by: Jarno Rajahalme <[email protected]>
@jrajahalme
Copy link
Copy Markdown
Contributor Author

Sorry for the forced change on the first commit, added OSX compat macros there you may want to check out.

@htuch htuch requested a review from zuercher January 4, 2018 19:10
@htuch
Copy link
Copy Markdown
Member

htuch commented Jan 4, 2018

LGTM. @zuercher can you take a look at the OS X handling here?

Signed-off-by: Jarno Rajahalme <[email protected]>
Copy link
Copy Markdown
Member

@zuercher zuercher left a comment

Choose a reason for hiding this comment

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

One nit, otherwise LGTM.

return std::make_shared<Address::Ipv6Instance>(*sin6, v6only);
if (!v6only && IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) {
#ifndef s6_addr32
#if defined(__APPLE__) && defined(__MACH__)
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.

We've left it as just #ifdef __APPLE__ elsewhere. I don't think this is actually mach-specific in any event, as it was copied from BSD.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Changed as requested, thanks for the review!

Checking for __APPLE__ only is sufficient.

Signed-off-by: Jarno Rajahalme <[email protected]>
@zuercher zuercher merged commit 3b3c009 into envoyproxy:master Jan 5, 2018
jrajahalme added a commit to jrajahalme/envoy that referenced this pull request Feb 10, 2018
Currently the local address of a new connection is mapped to an IPv4
address instance if the listening socket is not in V6ONLY mode and the
local address of the socket is an IPv4-mapped IPv6 address. This leads
to connections having an (IPv4-mapped) IPv6 instance for the remote
address and an IPv4 instance for the local address, which is
confusing. Fix this by allowing the remote address to be v4-mapped if the
local address is an IPv4 address. Or conversely, set the 'v6only'
parameter to 'true' if the local address is an IPv6 address instance.

Fixes: 3b3c009 ("address_impl: Return an Ipv4Instance for v4-mapped v6 addresses. (envoyproxy#2309)")
Signed-off-by: Jarno Rajahalme <[email protected]>
htuch pushed a commit that referenced this pull request Feb 15, 2018
Currently the local address of a new connection is mapped to an IPv4
address instance if the listening socket is not in V6ONLY mode and the
local address of the socket is an IPv4-mapped IPv6 address. This leads
to connections having an (IPv4-mapped) IPv6 instance for the remote
address and an IPv4 instance for the local address, which is
confusing. Fix this by allowing the remote address to be v4-mapped if the
local address is an IPv4 address. Or conversely, set the 'v6only'
parameter to 'true' if the local address is an IPv6 address instance.

Fixes: 3b3c009 ("address_impl: Return an Ipv4Instance for v4-mapped v6 addresses. (#2309)")
Signed-off-by: Jarno Rajahalme [email protected]
Risk Level: Low
Shikugawa pushed a commit to Shikugawa/envoy that referenced this pull request Mar 28, 2020
jpsim added a commit that referenced this pull request Nov 28, 2022
Signed-off-by: GitHub Action <[email protected]>

Co-authored-by: jpsim <[email protected]>
Signed-off-by: JP Simard <[email protected]>
jpsim added a commit that referenced this pull request Nov 29, 2022
Signed-off-by: GitHub Action <[email protected]>

Co-authored-by: jpsim <[email protected]>
Signed-off-by: JP Simard <[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.

4 participants