git: 277ecc2488ca - stable/13 - net80211: format debug functions as single line
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 30 Dec 2021 19:22:40 UTC
The branch stable/13 has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=277ecc2488ca8b252c24d686a5ae3e46d0ee0df6 commit 277ecc2488ca8b252c24d686a5ae3e46d0ee0df6 Author: Bjoern A. Zeeb <bz@FreeBSD.org> AuthorDate: 2021-12-26 17:24:04 +0000 Commit: Bjoern A. Zeeb <bz@FreeBSD.org> CommitDate: 2021-12-30 18:26:42 +0000 net80211: format debug functions as single line Making use of the debug output was hard given debug lines were run in parts through vlog (if_printf) and in (multiple) parts through printf(s). Like some of the functions alreay have, use a local buffer to format the string and then use a single if_printf; in addition given these functions are debug-only, add an extra printf in case we find our buffers still to be too small so we can adjust for the future. We already found that 128 characters are to short for some log messages. Bump the buffer sizes collectively to 256 characters which also is the maximum of if_vlog() so getting longer would need further changes elsewhere. Sponsored by: The FreeBSD Foundation (cherry picked from commit 04435a1b145b310f8be62dd453e2f0c69d764cca) --- sys/net80211/ieee80211_input.c | 76 +++++++++++++++++++++++++++--------------- 1 file changed, 49 insertions(+), 27 deletions(-) diff --git a/sys/net80211/ieee80211_input.c b/sys/net80211/ieee80211_input.c index 66a5ba1c4035..516de781e23e 100644 --- a/sys/net80211/ieee80211_input.c +++ b/sys/net80211/ieee80211_input.c @@ -936,14 +936,18 @@ ieee80211_getbssid(const struct ieee80211vap *vap, void ieee80211_note(const struct ieee80211vap *vap, const char *fmt, ...) { - char buf[128]; /* XXX */ + char buf[256]; /* XXX */ va_list ap; + int len; va_start(ap, fmt); - vsnprintf(buf, sizeof(buf), fmt, ap); + len = vsnprintf(buf, sizeof(buf), fmt, ap); va_end(ap); if_printf(vap->iv_ifp, "%s", buf); /* NB: no \n */ + + if (len >= sizeof(buf)) + printf("%s: XXX buffer too small: len = %d\n", __func__, len); } void @@ -951,14 +955,18 @@ ieee80211_note_frame(const struct ieee80211vap *vap, const struct ieee80211_frame *wh, const char *fmt, ...) { - char buf[128]; /* XXX */ + char buf[256]; /* XXX */ va_list ap; + int len; va_start(ap, fmt); - vsnprintf(buf, sizeof(buf), fmt, ap); + len = vsnprintf(buf, sizeof(buf), fmt, ap); va_end(ap); if_printf(vap->iv_ifp, "[%s] %s\n", ether_sprintf(ieee80211_getbssid(vap, wh)), buf); + + if (len >= sizeof(buf)) + printf("%s: XXX buffer too small: len = %d\n", __func__, len); } void @@ -966,13 +974,17 @@ ieee80211_note_mac(const struct ieee80211vap *vap, const uint8_t mac[IEEE80211_ADDR_LEN], const char *fmt, ...) { - char buf[128]; /* XXX */ + char buf[256]; /* XXX */ va_list ap; + int len; va_start(ap, fmt); - vsnprintf(buf, sizeof(buf), fmt, ap); + len = vsnprintf(buf, sizeof(buf), fmt, ap); va_end(ap); if_printf(vap->iv_ifp, "[%s] %s\n", ether_sprintf(mac), buf); + + if (len >= sizeof(buf)) + printf("%s: XXX buffer too small: len = %d\n", __func__, len); } void @@ -980,16 +992,21 @@ ieee80211_discard_frame(const struct ieee80211vap *vap, const struct ieee80211_frame *wh, const char *type, const char *fmt, ...) { + char buf[256]; /* XXX */ va_list ap; + int len; - if_printf(vap->iv_ifp, "[%s] discard ", - ether_sprintf(ieee80211_getbssid(vap, wh))); - printf("%s frame, ", type != NULL ? type : - ieee80211_mgt_subtype_name(wh->i_fc[0])); va_start(ap, fmt); - vprintf(fmt, ap); + len = vsnprintf(buf, sizeof(buf), fmt, ap); va_end(ap); - printf("\n"); + + if_printf(vap->iv_ifp, "[%s] discard %s frame, %s\n", + ether_sprintf(ieee80211_getbssid(vap, wh)), + type != NULL ? type : ieee80211_mgt_subtype_name(wh->i_fc[0]), + buf); + + if (len >= sizeof(buf)) + printf("%s: XXX buffer too small: len = %d\n", __func__, len); } void @@ -997,18 +1014,20 @@ ieee80211_discard_ie(const struct ieee80211vap *vap, const struct ieee80211_frame *wh, const char *type, const char *fmt, ...) { + char buf[256]; /* XXX */ va_list ap; + int len; - if_printf(vap->iv_ifp, "[%s] discard ", - ether_sprintf(ieee80211_getbssid(vap, wh))); - if (type != NULL) - printf("%s information element, ", type); - else - printf("information element, "); va_start(ap, fmt); - vprintf(fmt, ap); + len = vsnprintf(buf, sizeof(buf), fmt, ap); va_end(ap); - printf("\n"); + + if_printf(vap->iv_ifp, "[%s] discard%s%s information element, %s\n", + ether_sprintf(ieee80211_getbssid(vap, wh)), + type != NULL ? " " : "", type != NULL ? type : "", buf); + + if (len >= sizeof(buf)) + printf("%s: XXX buffer too small: len = %d\n", __func__, len); } void @@ -1016,16 +1035,19 @@ ieee80211_discard_mac(const struct ieee80211vap *vap, const uint8_t mac[IEEE80211_ADDR_LEN], const char *type, const char *fmt, ...) { + char buf[256]; /* XXX */ va_list ap; + int len; - if_printf(vap->iv_ifp, "[%s] discard ", ether_sprintf(mac)); - if (type != NULL) - printf("%s frame, ", type); - else - printf("frame, "); va_start(ap, fmt); - vprintf(fmt, ap); + len = vsnprintf(buf, sizeof(buf), fmt, ap); va_end(ap); - printf("\n"); + + if_printf(vap->iv_ifp, "[%s] discard%s%s frame, %s\n", + ether_sprintf(mac), + type != NULL ? " " : "", type != NULL ? type : "", buf); + + if (len >= sizeof(buf)) + printf("%s: XXX buffer too small: len = %d\n", __func__, len); } #endif /* IEEE80211_DEBUG */