Skip to content

hot restart: forward UDP packets by listener address and network namespace - #47743

Merged
mattklein123 merged 1 commit into
envoyproxy:mainfrom
bpalermo:hot-restart-udp-forwarding-netns
Sep 30, 2026
Merged

mattklein123 merged 1 commit into
envoyproxy:mainfrom
bpalermo:hot-restart-udp-forwarding-netns

Conversation

@bpalermo

Copy link
Copy Markdown
Contributor

Commit Message

hot restart: forward UDP packets by listener address and network namespace

Additional Description

Since #46502 the draining parent forwards datagrams of unknown sessions to the child. Two parts of
that path ignored the listener's network namespace: UdpForwardingContext::registerListener keyed
the child's registry on address->asString(), which omits the namespace, so listeners bound to the
same ip:port via different network_namespace_filepath values collapsed to one entry (the
duplicate assert is debug-only); and the parent forwarded the datagram's destination
(urlFromDatagramAddress(packet.addresses_.local_)), which on a transparent socket is the
original destination rather than the bind address, so the lookup fell through to the any-address
entry. Every forwarded datagram from any such listener was delivered to the first registered
listener's udp_proxy, replying from a socket in the wrong namespace.

The NonDispatchedUdpPacketHandler interface now receives the forwarding listener's bind address
(both the raw UDP and the QUIC listener pass their listen socket's local address), the parent adds
listener_addr and network_namespace to ForwardedUdpPacket, and the child keys its registry on
namespace plus address and resolves forwarded packets by listener address. A message without the
new fields, from a parent that predates them, is resolved exactly as before, so mixed-version hot
restarts keep working in both directions. Socket inheritance was already namespace-aware and is
unchanged.

Risk Level

Low. Only affects hot restart UDP forwarding; no behavior change for listeners without a network
namespace or with distinct addresses.

Testing

  • hot_restarting_child_test: forwarding by listener address to the right one of two listeners
    sharing an address across namespaces with a transparent destination; destination-based fallback
    for messages without the new fields; no cross-namespace or namespace-less match of a namespaced
    listener.
  • hot_restarting_parent_test: the forwarded message carries the listener address and namespace.
  • Updated active_udp_listener_test, active_quic_listener_test and connection_handler_test
    for the handler signature.

Docs Changes

One sentence in the listeners overview.

Release Notes

Added a bug fix fragment.

Platform Specific Features

N/A

Fixes #47742

…space

The draining parent forwarded datagrams of unknown sessions keyed on the
datagram's destination, and the child resolved the target listener from an
address string without the network namespace. Listeners bound to the same
address in different namespaces collapsed to one registry entry, and
transparent sockets, whose destination is not the bind address, fell through to
the any-address entry, so forwarded datagrams from every such listener were
delivered to the first one registered.

The parent now forwards the listener's bind address and network namespace with
each datagram, the child keys its registry on both and resolves forwarded
packets by listener address, and the destination-based lookup is kept for
parents that predate the new fields.

Fixes envoyproxy#47742

Signed-off-by: Bruno Palermo <[email protected]>
@repokitteh-read-only

Copy link
Copy Markdown

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: #47743 was opened by bpalermo.

see: more, trace.

bpalermo added a commit to bpalermo/aether that referenced this pull request Sep 26, 2026
…stener address + netns) as a patch on the 726d7ac pin

aether#967: during a hot restart the parent forwards datagrams of unknown UDP
sessions to the child keyed only by ip:port, so N per-netns capture listeners
on 0.0.0.0:18082 collapse onto the first-registered one in the child (wrong
udp_proxy instance, reply from the wrong pod netns). Upstream fix e92e96dc7a
(on top of exactly our pin) forwards the listener's bind address + network
namespace and keys the child's registry on both, keeping the old destination
lookup for parents that predate the fields.

Applied as single_version_override(patches) on the registry module; the
source-only hunks (connection_handler.h, hot_restart.proto,
hot_restarting_{parent,child}.{h,cc}, active_udp_listener.cc,
active_quic_listener.cc), test/docs/changelog dropped. `git apply --check`
clean at 726d7ac; `bazel build --nobuild --config=release //:envoy` fetches
the patched module (hot_restart.proto carries listener_addr = 6 and
network_namespace = 7). Drop the override at the next pin that contains the
merged PR.

Validation on talos-main (two proxy rolls, per the plan on #967): roll 1 is
unpatched parent -> patched child (control: old destination-based lookup, same
loss as today); roll 2 is patched -> patched. E1 predicts the loss stays the
same either way (the datagrams were held on the right listener, not
misdelivered), so the expected result is "no regression, no effect" for the
forwarding registry and the timing evidence decides fix B.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
bpalermo added a commit to bpalermo/aether that referenced this pull request Sep 26, 2026
…stener address + netns) as a patch on the 726d7ac pin (#970)

aether#967: during a hot restart the parent forwards datagrams of unknown UDP
sessions to the child keyed only by ip:port, so N per-netns capture listeners
on 0.0.0.0:18082 collapse onto the first-registered one in the child (wrong
udp_proxy instance, reply from the wrong pod netns). Upstream fix e92e96dc7a
(on top of exactly our pin) forwards the listener's bind address + network
namespace and keys the child's registry on both, keeping the old destination
lookup for parents that predate the fields.

Applied as single_version_override(patches) on the registry module; the
source-only hunks (connection_handler.h, hot_restart.proto,
hot_restarting_{parent,child}.{h,cc}, active_udp_listener.cc,
active_quic_listener.cc), test/docs/changelog dropped. `git apply --check`
clean at 726d7ac; `bazel build --nobuild --config=release //:envoy` fetches
the patched module (hot_restart.proto carries listener_addr = 6 and
network_namespace = 7). Drop the override at the next pin that contains the
merged PR.

Validation on talos-main (two proxy rolls, per the plan on #967): roll 1 is
unpatched parent -> patched child (control: old destination-based lookup, same
loss as today); roll 2 is patched -> patched. E1 predicts the loss stays the
same either way (the datagrams were held on the right listener, not
misdelivered), so the expected result is "no regression, no effect" for the
forwarding registry and the timing evidence decides fix B.


Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

Co-authored-by: Claude Fable 5.1 <[email protected]>
@bpalermo

Copy link
Copy Markdown
Contributor Author

/retest

@mattklein123
mattklein123 merged commit a644fc6 into envoyproxy:main Sep 30, 2026
25 checks passed
bpalermo added a commit to bpalermo/aether that referenced this pull request Oct 10, 2026
…the two carried patches it contains are dropped (#980) (#1643)

The pin is one fact in three places and moves as one: envoy and envoy_api
(proxy/MODULE.bazel) and the envoyproxy/bazel-registry commit
(proxy/.bazelrc, 5db29c09de17218d24f58c665be38208284754d8), written by
scripts/bump-envoy-pin.sh. rules_python follows what the envoy module
requests (2.2.0 -> 2.3.3). The lockfile is refreshed.

Dropped, because Envoy 189f198 contains them:
- envoy-47743-udp-hot-restart-forwarding-netns (envoyproxy/envoy#47743,
  a644fc670e): the carried hunks reverse-apply cleanly to the snapshot.
- envoy-aether1022-exec-in-netns-thread-self (envoyproxy/envoy#47776,
  7d6ca3273c): the snapshot opens /proc/thread-self/ns/net. The carried
  fallback for kernels older than 3.17 and its per-thread model test go with
  it.

Kept, in the same order:
- 47740 (still open upstream): unchanged content, hunk positions refreshed.
- aether1050: replaced by the diff of its upstream pull request,
  envoyproxy/envoy#47834 at 72408727eb, docs and changelog dropped. Same
  source as before plus three counters,
  server.hot_restart_udp_forwarding_{datagrams,retries,dropped}; the test
  hunks no longer carry the 47743 test changes.
- aether1054: rebased over envoyproxy/envoy#47991, which rewrote
  ConnectionManagerImpl::onDrain() to drain idle connections proactively in
  the last third of the drain time. That arms nothing when the drain time
  leaves no room after the drain timeout (the chart's 10s with the default
  5s), so the carried idle HTTP/3 drain stays, armed beside it from
  armIdleHttp3DrainTimer(). Upstream's ProactiveDrain* tests notify the drain
  before a codec exists and turn the carried timer off; the carried gradual
  case now asserts both timers.
- aether1054b, aether1054c, aether1074, aether1126: unchanged content.

proxy/.bazelrc: envoyproxy/envoy#47806 removed the --@envoy//bazel:libc++
flag and the force_libcpp define, so both leave the libc++ config; nothing
else upstream removed from its own .bazelrc is required to go, and the rest
is kept as built before.

Refs #980


Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

Co-authored-by: Claude Opus 5.5 <[email protected]>
@bpalermo
bpalermo deleted the hot-restart-udp-forwarding-netns branch October 13, 2026 21:23
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.

hot restart: UDP packet forwarding ignores the listener network namespace

2 participants