Page MenuHomeFreeBSD

Add log() style versions of device_printf() and if_printf()
ClosedPublic

Authored by adrian on Mar 18 2021, 6:46 AM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Dec 24, 1:45 AM
Unknown Object (File)
Sun, Dec 7, 7:50 AM
Unknown Object (File)
Nov 21 2025, 8:48 PM
Unknown Object (File)
Nov 20 2025, 11:25 AM
Unknown Object (File)
Nov 18 2025, 2:18 AM
Unknown Object (File)
Nov 13 2025, 11:55 AM
Unknown Object (File)
Nov 6 2025, 3:24 AM
Unknown Object (File)
Nov 6 2025, 3:23 AM

Details

Summary

This is intended to be used by devices and network devices
to log things to the kernel syslog rather than hand-rolling
log() stuff (like what happens in other places in net/if.c)
or being very spammy with device_printf()/printf() (like, well,
a lot of things.)

I've used this in my local tree to convert net80211 and ath_hal
logging over to log at INFO/DEBUG where appropriate and it
works quite well. On devices with serial consoles (ie, all the
weird things I use in my wifi test bed here) writing debug
information to the serial console causes quite bad behaviour.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 37910
Build 34799: arc lint + arc unit

Event Timeline

Seems good to me, but you'll want to make sure others sign off on it too.

sys/kern/subr_bus.c
2457

128 is kinda small, but on the other hand it's also kinda big for the stack :(, but I guess it's no different than device_printf.

This revision is now accepted and ready to land.Mar 18 2021, 4:06 PM
jhb added a subscriber: jhb.
jhb added inline comments.
sys/kern/subr_bus.c
2457

If you wanted to support longer lines you could add a drain routine that wrote to log(). Truncating is probably fine though.

That's a nice addition we should long have.
Please see some minor comments inside.

sys/kern/subr_bus.c
2462

Nit: should it be something like "unknown_device:" ?

sys/net/if.c
3955

Nit: maybe if_buf?