Expand description
The TCP port a gdbserver serves its one gdb client on, bound in the host’s network namespace.
The gdbserver runs in the tracer, inside the container. A port the tracer
bound itself would be in the guest’s network namespace, which a gdb client
on the host cannot reach while the guest has a private network
(--network=local). So the CLI binds the port before it makes the
container (GdbPort::bind): a socket stays in the network namespace it
was made in, and the tracer inherits it at the clone. Just before the
tracer spawns the guest it listens on that socket (connection), and a
relay accepts the one client and passes its bytes to the gdbserver, which
listens on an abstract Unix socket in the tracer’s own namespace. The guest
keeps the network it was given, and a host gdb client reaches the port
either way.
The relay is a task on the tracer’s Tokio runtime, not a thread: a thread in the tracer would take a PID in the container’s PID namespace and shift every guest PID after it.
Structs§
- GdbPort
- A loopback TCP port bound, not yet listening, in the network namespace of the process that bound it, for a gdbserver to serve its client on.