net: the DHCP lease goes to the log, not over the user's shell
"net: eth0 10.0.2.15/255.255.255.0 via 10.0.2.2" arrived on the display seconds after the prompt did, so the first thing anyone saw after booting was the kernel typing into their session. It lands wherever the cursor happens to be -- in the middle of a command, a fastfetch, or later a compositor's output. console_takeover() hands the framebuffer to userspace on the first exec, and after that the screen belongs to whoever is using the machine. cons_serial_only already encodes that rule for the boot path -- "the display is the product; the serial line is the diagnostics" -- and it starts set for exactly this reason. What was missing is the rule for messages that cannot be timed to happen before userspace starts, because they are waiting on a network. klog() is that: the serial port only, whatever cons_serial_only currently says. A macro rather than a function, because cprintf's varargs cannot be forwarded -- there is no vcprintf, and adding one to duplicate the formatter would cost more than it buys. cprintf holds cons.lock for the whole message, so the flag cannot be observed half-changed by another CPU printing at the same time. Nothing is lost. The line still goes out the UART, which is where bootcheck reads it from and where you want it when something is wrong, and a person who wants to know their address reads /proc/netif. Verified by screendumping the framebuffer after a boot and two fastfetch runs: no interruption on screen, still one occurrence on serial. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VQ7Qx8E1q1M1bbCq8QLHS2
This commit is contained in:
parent
1754cbf1aa
commit
d97dd9ed90
7 changed files with 42 additions and 76 deletions
|
|
@ -246,7 +246,11 @@ net_thread(void)
|
|||
const ip4_addr_t *a = netif_ip4_addr(nif);
|
||||
const ip4_addr_t *m = netif_ip4_netmask(nif);
|
||||
const ip4_addr_t *gw = netif_ip4_gw(nif);
|
||||
cprintf("net: %s %d.%d.%d.%d/%d.%d.%d.%d via %d.%d.%d.%d\n",
|
||||
// klog, not cprintf: a lease arrives seconds after the shell
|
||||
// prompt does, so on the display this lands in the middle of
|
||||
// whatever the user is doing. /proc/netif is where a person looks
|
||||
// for an address; the serial line is where the log belongs.
|
||||
klog("net: %s %d.%d.%d.%d/%d.%d.%d.%d via %d.%d.%d.%d\n",
|
||||
net_eth_device(i)->name,
|
||||
ip4_addr1(a), ip4_addr2(a), ip4_addr3(a), ip4_addr4(a),
|
||||
ip4_addr1(m), ip4_addr2(m), ip4_addr3(m), ip4_addr4(m),
|
||||
|
|
|
|||
Loading…
Reference in a new issue