nos_
ENRU
Вся документация

Инструменты

Удалённая оболочка по UDP

docs/udp-shell.mdОткрыть на GitHub

Эта страница документации пока есть только на английском. Документация собирается прямо из каталога docs/ репозитория, поэтому всегда соответствует коду. По-русски написаны руководства.

When udpshell=PORT is set (see Kernel parameters), the kernel listens for commands on that UDP port. It runs whatever any datagram carrying its magic asks, unencrypted and with no authentication: fine on a VM's private network, not on a port the internet can reach. For that, sshd serves the same shell over SSH, to the keys it is given.

So it is off unless asked for, in every configuration the tree ships: the ISO, the disk image, scripts/qemu-arm64.sh (NOS_UDPSHELL=9000 turns it on there) and a server the system image is poured onto, where nos-install --udpshell asks for it (Install). The tests that drive the kernel through it put udpshell= on their own command lines.

A lightweight protocol header (16 bytes: magic, sequence number, chunk index, flags, payload length) frames every packet, enabling the client to validate replies, reassemble multi-chunk responses in order, and detect the end of a response without relying on timeouts.

Connect with the included Python client:

python3 scripts/udpsh.py <vm-ip> [port] [timeout]
  • Default port is 9000, default timeout is 30 seconds (long enough for blocking commands like ping).
  • On protocol errors or timeouts, the client reconnects automatically and resets state.
  • All shell commands work over the UDP session (including blocking ones like ping).
  • A reply is assembled in a 32 KB buffer and sent as chunks of 1384 bytes, one per millisecond -- paced for the same reason the netconsole drain is, since twenty-odd datagrams released at once lose their tail to the first narrow queue on the way. Whatever does not fit the buffer is dropped and marked [output truncated]. The client collects chunks by index, so one reordered datagram no longer discards the whole answer, and it names any that never arrived.
  • dmesg still takes a line count, because the log holds 2048 messages and even 32 KB is a fraction of it: a dump from the head returns the first minutes of boot and nothing since, so on a machine that has been up a while dmesg 40 is the useful form. Same reasoning as nctail=N for the netconsole backlog -- what you want is the end.
  • loglevel N raises the trace level on the running kernel, which is the only way to see a subsystem whose level constant is above the default 1 (UsbLL and KbdLL are 3, the allocators and MMIO are 4) without a rebuild and a reflash. It is loud: level 4 traces every allocation.
  • Warning: the UDP shell has no authentication — anyone who can reach the port has full kernel shell access. Use only for testing or behind a firewall.