kernel/network: forget a network device's state when it is removed #719

Merged
Burer merged 2 commits from net-device-removal into main 2026-09-29 13:30:01 +00:00
Contributor
  • net_remove_device: clear the slot's IPv4 settings, ARP table and counters, and drop its frames from the ethernet input queue.
  • ipv4_route:
    • skip slots without a device;
    • an interface without an address routes broadcasts only;
    • off-link without a gateway fails instead of resolving 0.0.0.0.
  • ipv4_output_raw: check the route before resolving it.
  • eth_output, arp_output_request: refuse a null device.
  • eth_output: count a too-large frame on the device, not on eax.
- `net_remove_device`: clear the slot's IPv4 settings, ARP table and counters, and drop its frames from the ethernet input queue. - `ipv4_route`: - skip slots without a device; - an interface without an address routes broadcasts only; - off-link without a gateway fails instead of resolving 0.0.0.0. - `ipv4_output_raw`: check the route before resolving it. - `eth_output`, `arp_output_request`: refuse a null device. - `eth_output`: count a too-large frame on the device, not on `eax`.
CODEOWNERS rules requested review from system 2026-09-24 16:23:52 +00:00
CODEOWNERS rules requested review from network 2026-09-24 16:23:52 +00:00
Leency requested review from hidnplayr 2026-09-24 16:25:42 +00:00
Leency requested review from Burer 2026-09-24 16:25:49 +00:00
Leency added the Subsystem/Network label 2026-09-24 16:30:00 +00:00
hidnplayr approved these changes 2026-09-28 18:10:09 +00:00
Burer changed title from kernel/net: forget a network device's state when it is removed to kernel/network: forget a network device's state when it is removed 2026-09-29 13:17:54 +00:00
Burer approved these changes 2026-09-29 13:17:57 +00:00
Burer added 2 commits 2026-09-29 13:18:06 +00:00
net_remove_device only cleared the slot in net_device_list. The IPv4
address, subnet, gateway and nameserver of the slot stayed, so
ipv4_route kept picking the removed interface, and output then called
through the empty slot: after unplugging a USB network adapter the next
connect() crashed the kernel (EIP 0x6000, EBX=0). Its ARP table
survived as well and was reused by the next device registered in the
same slot, and frames it had queued for input kept a device pointer to
freed memory.

On removal, clear the slot's IPv4 settings, ARP table and counters, and
drop its frames from the ethernet input queue. ipv4_route skips slots
without a device, ipv4_output_raw checks the route before resolving it,
and eth_output / arp_output_request refuse a null device. Also fix
eth_output's too-large path, which counted the error on eax instead of
the device.

Tested in QEMU with a USB network device removed and re-added over the
monitor in a loop while a guest app kept reconnecting: no crash, and
the network comes back after every re-add.

Assisted-by: Claude Opus 5 <noreply@anthropic.com>
kernel/net: no unicast route from an interface without an address
Check kernel codestyle / Check kernel codestyle (pull_request) Successful in 26s
Test PR / Build (es_ES) (pull_request) Successful in 2m32s
Test PR / Build (en_US) (pull_request) Successful in 2m38s
Test PR / Build (ru_RU) (pull_request) Successful in 2m40s
1350bd20de
In ipv4_route's bound-device path an interface whose address and mask
are both zero compared as on-link with every destination, so a segment
sent right after the address was dropped (link lost, DHCP not redone
yet) went out as an ARP request for an internet address on behalf of
0.0.0.0 - which nobody answers, and the sender then waited for the
reply. Route only broadcasts from such an interface, and fail as well
when the destination is off-link and no gateway is known instead of
resolving 0.0.0.0.

Assisted-by: Claude Opus 5 <noreply@anthropic.com>
Burer force-pushed net-device-removal from 1605fdc189 to 1350bd20de 2026-09-29 13:18:06 +00:00 Compare
CODEOWNERS rules requested review from system 2026-09-29 13:18:07 +00:00
CODEOWNERS rules requested review from network 2026-09-29 13:18:07 +00:00
Burer merged commit b59e371c0e into main 2026-09-29 13:30:01 +00:00
Burer deleted branch net-device-removal 2026-09-29 13:30:02 +00:00
Sign in to join this conversation.
No Reviewers
KolibriOS/system
KolibriOS/network
No labels Subsystem/Network
3 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: KolibriOS/kolibrios#719