Page MenuHomeFreeBSD

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

Authored by adrian on Thu, Mar 18, 6:46 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
R10 FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

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

sys/kern/subr_bus.c
2456

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.Thu, Mar 18, 4:06 PM
jhb added a subscriber: jhb.
jhb added inline comments.
sys/kern/subr_bus.c
2456

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
2461

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

sys/net/if.c
3973

Nit: maybe if_buf?