Skip to content

network: allow IP instance creation for unsupported IP families#42422

Draft
bencebeky wants to merge 1 commit intoenvoyproxy:mainfrom
bencebeky:bencebeky/ip-family
Draft

network: allow IP instance creation for unsupported IP families#42422
bencebeky wants to merge 1 commit intoenvoyproxy:mainfrom
bencebeky:bencebeky/ip-family

Conversation

@bencebeky
Copy link
Contributor

@bencebeky bencebeky commented Dec 4, 2025

Commit Message:

  1. Allow Ipv4Instance and Ipv6Instance objects to be created even if host does not support IPv4 or IPv6.
  2. Add support for SocketInterfaceImpl::socket() to return error status to signal unsupported IP family at socket creation time.

Additional Description: This PR is inspired by #41836 (comment) and in its first iteration is a proof of concept as an alternative to #41836. In order to be considered for merging, it will require flag protection and extensive testing.
Risk Level: medium
Testing: TODO
Docs Changes: n/a
Release Notes: allow proxy_protocol to parse IPv4 or IPv6 addresses even when not supported by host
Platform Specific Features: n/a
Optional Runtime guard: TODO
Fixes #41826

@repokitteh-read-only
Copy link

As a reminder, PRs marked as draft will not be automatically assigned reviewers,
or be handled by maintainer-oncall triage.

Please mark your PR as ready when you want it to be reviewed!

🐱

Caused by: #42422 was opened by bencebeky.

see: more, trace.

@bencebeky bencebeky force-pushed the bencebeky/ip-family branch from f123ef1 to 1521e18 Compare December 4, 2025 21:59
@ggreenway
Copy link
Member

cc @agrawroh

@bencebeky bencebeky force-pushed the bencebeky/ip-family branch 5 times, most recently from 6613b7a to a3c4661 Compare December 5, 2025 21:14
@bencebeky bencebeky force-pushed the bencebeky/ip-family branch 8 times, most recently from 871875f to 528bf57 Compare January 14, 2026 17:31
1. Allow Ipv4Instance and Ipv6Instance objects to be created even if host does
not support IPv4 or IPv6.

2. Add support for SocketInterfaceImpl::socket() to return error status to
signal unsupported IP family at socket creation time.

Fixes envoyproxy#41826

Signed-off-by: Bence Béky <bence.beky@datadoghq.com>
@bencebeky bencebeky force-pushed the bencebeky/ip-family branch from b857332 to b477bd7 Compare January 15, 2026 10:00
Network::ConnectionSocketPtr connection_socket =
connection_socket_or.ok() ? std::move(*connection_socket_or)
: std::make_unique<Network::ConnectionSocketImpl>(
std::make_unique<Network::IoSocketHandleImpl>(INVALID_SOCKET),
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure why we would create a socket with invalid socket here. did you check the call path to see how this was handled?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

At

// Not null but can be a bad socket if creation goes wrong.
it is stated that the socket can be bad inside the CreationResult struct. I returned StatusOr in an earlier draft of this PR but that necessitates changing dozens of more files to handle something that can probably be lumped together with the invalid socket case. But I didn't yet investigate how a bad socket is handled.

absl::StatusOr<Network::IoHandlePtr> io_handle_or =
socket_interface.socket(socket_type, address, creation_options);
RETURN_IF_NOT_OK(io_handle_or.status());
if (*io_handle_or == nullptr) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if this check might be redudant with previous RETURN IF NOT OK

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The existing code handles the nullptr case. I do not want to remove that logic unless we thoroughly investigate to make sure all previous nullptr paths are replaced with an error status. But yes, ideally every method that this PR converts to return StatusOr or StatusOr should then guarantee that the pointer is never nullptr.

@yanavlasov
Copy link
Contributor

Hi @bencebeky . Good to see you again. Thanks for making this change.

There are a few significant behavioral changes that are present together in this PR making it hard to reason about correctness. Can you split this PR into smaller changes please? For example:

  1. Just the change to the SocketInterface::socket to return StatusOr It will allow us to see how call sites needs to be modified to take advantage of the new error reporting way.
  2. Change to the how the address instances are created and how address types incompatible with the IP stack config are reported.

I think it will be easier to discuss these two changes in isolation.

/wait-any

@bencebeky
Copy link
Contributor Author

Hi @bencebeky . Good to see you again. Thanks for making this change.

There are a few significant behavioral changes that are present together in this PR making it hard to reason about correctness. Can you split this PR into smaller changes please? For example:

  1. Just the change to the SocketInterface::socket to return StatusOr It will allow us to see how call sites needs to be modified to take advantage of the new error reporting way.
  2. Change to the how the address instances are created and how address types incompatible with the IP stack config are reported.

I think it will be easier to discuss these two changes in isolation.

/wait-any

Hello @yanavlasov. It is indeed good to see so many familiar GitHub handles. Thank you for taking a look at the first iteration of this change. I wanted to start by getting a sense of whether Envoy maintainers are generally supportive of this design, and am happy to see no objections so far. (I also communicated with Greg privately.) Thank you for your recommendation, I agree that splitting up this PR into two would make it easier to reason about.

/wait

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

proxy protocol parsing without system support

4 participants