Skip to content

upstream: gracefully handle upstream connection creation failure#45975

Open
bpalermo wants to merge 1 commit into
envoyproxy:mainfrom
bpalermo:bug/upstream-bind-netns-crash
Open

upstream: gracefully handle upstream connection creation failure#45975
bpalermo wants to merge 1 commit into
envoyproxy:mainfrom
bpalermo:bug/upstream-bind-netns-crash

Conversation

@bpalermo

@bpalermo bpalermo commented Jul 4, 2026

Copy link
Copy Markdown

Commit Message

upstream: gracefully handle upstream connection creation failure

Additional Description

Split out of #45721 (crash-fix half), as requested in review.

Binding an upstream connection to a configured Linux network namespace
(SocketAddress.network_namespace_filepath) could crash Envoy when the namespace was not
available: DispatcherImpl::createClientConnection returns nullptr on netns failure, and the
result was dereferenced unconditionally in HostImplBase::createConnection.

HostImplBase::createConnection now returns a null connection in this case, and the
TCP/HTTP1/HTTP2/mixed connection pools surface it as a FailedToCreateConnection pool failure
(LocalConnectionFailure to the caller) — matching how the HTTP/3 pool already behaves — instead
of crashing.

The companion PR (#45976) adds opt-in validation of the network namespace at config load time.

Risk Level

Low — converts a crash into the existing graceful pool-failure path.

Testing

Unit tests added: HostImplTest.CreateConnectionFailure (null connection surfaced by
HostImplBase::createConnection) and TcpConnPoolImplDestructorTest.ConnectionCreationFailure
(pool surfaces LocalConnectionFailure).

Docs Changes

N/A

Release Notes

Added a bug-fix changelog fragment.

Platform Specific Features

The motivating failure (network namespace binding) is Linux-only, but the null-connection
handling is platform-independent.

Binding an upstream connection to a configured Linux network namespace
(SocketAddress.network_namespace_filepath) could crash Envoy when the
namespace did not exist: DispatcherImpl::createClientConnection returns
nullptr on netns failure, and the result was dereferenced unconditionally
in HostImplBase::createConnection.

HostImplBase::createConnection now returns a null connection in this
case, and the TCP/HTTP1/HTTP2/mixed connection pools surface it as a
FailedToCreateConnection pool failure -- matching how the HTTP/3 pool
already behaves -- instead of crashing.

Signed-off-by: Bruno Palermo <b@palermo.dev>
@bpalermo bpalermo requested a deployment to external-contributors July 4, 2026 18:51 — with GitHub Actions Waiting
@repokitteh-read-only

Copy link
Copy Markdown

Hi @bpalermo, welcome and thank you for your contribution.

We will try to review your Pull Request as quickly as possible.

In the meantime, please take a look at the contribution guidelines if you have not done so already.

🐱

Caused by: #45975 was opened by bpalermo.

see: more, trace.

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.

1 participant