Repository navigation
Description
Title: hot restart: UDP packet forwarding ignores the listener network namespace
Description:
Since #46502 the draining parent keeps its raw UDP listeners and forwards datagrams of unknown sessions to the child over the hot restart RPC. Two parts of that path are namespace-blind:
- The child's forwarding registry keys listeners by
address->asString()(HotRestartingChild::UdpForwardingContext::registerListener,source/server/hot_restarting_child.cc), which for IP addresses is justip:portand omits the network namespace of a listener bound withnetwork_namespace_filepath. With several listeners on the sameip:portin different namespaces, only the first registration survives (try_emplace; the duplicate assert is debug-only). - The parent forwards
urlFromDatagramAddress(packet.addresses_.local_)(HotRestartingParent::Internal::handle,source/server/hot_restarting_parent.cc), i.e. the datagram's destination, also without a namespace. On atransparentsocket that is the original destination address rather than the bind address, so the child's lookup falls through to the0.0.0.0:<port>default entry.
Result: every forwarded datagram from any of those listeners is delivered to the first-registered listener's udp_proxy, so replies leave from a socket in the wrong namespace and sessions are counted under the wrong listener's stats. Socket inheritance itself is namespace-aware (getListenSocketsForChild matches with withNetworkNamespace, and address equality compares the namespace), so only the forwarding path is affected.
Repro steps:
- Configure N UDP listeners bound to
0.0.0.0:<port>with distinctnetwork_namespace_filepathvalues and audp_proxyfilter each. - Hot restart while new UDP flows arrive on listeners other than the first one configured.
- During the drain overlap the flows are handled by the first listener's
udp_proxy(visible under its stat prefix), and replies are sent from that listener's socket.
Proposed fix:
Forward the listener's bind address and network namespace in ForwardedUdpPacket (in addition to the datagram destination, for compatibility with older parents), key the child's registry on address plus namespace, and resolve forwarded packets by listener address first, falling back to the destination-based lookup only for messages without the new fields.
I have a change for this in progress.
Activity
hot restart: forward UDP packets by listener address and network name…