# Disable ath0 (wlan) console messages



## Arthurc (Sep 5, 2020)

I redirected most of the console messages to /var/log/console.log but the WLAN message seems does not honor /etc/syslog.conf.
I am still and only getting console messages like "ath0: bb hang detected (0x4), resetting". Is there any way to redirect or suppress them?


----------



## Mjölnir (Sep 8, 2020)

Since that's a simple printf(3) (in /usr/src/sys/dev/ath/if_ath.c:2495) -- not by syslog(3) -- it doesn't go through syslogd(8).  And it's not a debug message (_DPRINTF()_), so it can not be disabled by wlandebug(8) or sysctl(8) knobs.
You can patch the source and change all those _device_printf()_'s to _DPRINTF()_, which can be switched on/off.


----------



## Arthurc (Sep 9, 2020)

I am not very familiar with FreeBSD's code. Does it cause any problem?


----------



## Mjölnir (Sep 9, 2020)

Arthurc said:


> I am not very familiar with FreeBSD's code. Does it cause any problem?


The following assumes you're running 12.1-RELEASE-p9; for 11.x, the line numbers may be different!

Any change, no matter how small, can cause unforseen damage...
IMHO the risk is so small that I would try to get rid of it if it bugs me; YMMV.
When you run a custom or patched kernel, any changes will be overwritten by freebsd-update(8).  Thus you have to save your patch & apply it again after each update:

Prepare your patch: optionally create a new boot environment: `beadm create patch` and `beadm activate patch`, reboot.
`cd /usr/src`, then `mv sys/dev/ath/if_ath.c{,.orig}`
`cp sys/dev/ath/if_ath.c{.orig,}`
Edit the desired behaviour: change line 2494 to `DPRINTF(sc, ATH_DEBUG_BEACON,`
Save your patch: `diff -U 5 sys/dev/ath/if_ath.c{.orig,} > ~/quite_ath.patch`
Not now, but after each update (freebsd-update(8) will update the source tree if it's installed):
`patch --dry-run -d /usr/src < ~/quite_ath.patch`
Build & install your patched kernel: `\nohup nice make -C /usr/src {build,install}kernel &` and `less nohup.out` (press G F to follow the build messages flying in, or use sysutils/most, there it's B F)
If it does not work as expected (or doesn't boot at all), boot from kernel.old or switch to your previous boot environment.
Then you should be able to switch that mesage on/off via wlandebug(8) or `sysctl dev.ath.0.debug`.  If it works, consider to file in a bug report, append your patch (also inline in the text of the bug report), and kindly ask the developer to apply such changes for all printf(3)()s, e.g. use a macro IPRINTF() (_info printf_) like DPRINTF() that can be switched on/off via a sysctl(8) knob `dev.<driver>.<num>.info` à la `dev.<driver>.<num>.debug`.
Happy hacking!


----------

