From nobody Thu Dec 30 19:22:40 2021 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 47DFE191F98B; Thu, 30 Dec 2021 19:22:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JPypT3dTdz3C58; Thu, 30 Dec 2021 19:22:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 476DC1DCC3; Thu, 30 Dec 2021 19:22:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1BUJMeRI017387; Thu, 30 Dec 2021 19:22:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BUJMe5d017386; Thu, 30 Dec 2021 19:22:40 GMT (envelope-from git) Date: Thu, 30 Dec 2021 19:22:40 GMT Message-Id: <202112301922.1BUJMe5d017386@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: 277ecc2488ca - stable/13 - net80211: format debug functions as single line List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bz X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 277ecc2488ca8b252c24d686a5ae3e46d0ee0df6 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1640892161; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=DYZqgEpxkLRdit/jLudy6tN/+p9yFbEdLgfSgKC21iU=; b=YTbXMAW9ywJhuM2+M+S9QMWaKc4AWYpMFZwd3bwuP7Ojt5PKsDZYTvwv48Ql+ntpXlRpBd rc8jdGHeDeXbr3MW6+8mDK8atHpZDfXNBaL5yTvmSPW7AMVYHdDILb+KXxHIjEvMjvmVl5 pgirpHQPOQlLMo4QATW+XVuu0ydmkPWhiOGRDx0J7uwb/UowsfjXYNsD9G/eiIMFRsy4yF IsDCi3619dZX/8ErZFjAKzAsuo8T7UnFjiD4bzxa8tasGCwSEWqeHQ/xnRozky+4b+TcXk Un3+oII/pGvV6zH3y7+OVQoQG6c70PSdaMyWMCpWjo+mBiaQi49AlRpjkhOX5g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1640892161; a=rsa-sha256; cv=none; b=gKIsstpWe2vqackHLbPuFEJC8FCN+QyOEGJU3v3B3OoMcgAtFH8UfAOVJNuDVpRx+5150j G+0Fbl5LIMxyj2kA2gmKck3opnYTgvbWmfco7cA8O0VdC201hDDqVL+LDoG2mFqcGwqKtg hdegTxCSP/chLaIQcB7DYCrcoNyZTntyqn4CmfrJRfwORez22Jlu07pyRCSezjB8jZgkvQ 3AblzRE3Xxnj6Dyx8XSd7CpsjSFkeCSrtvOtffc9CknA1o44buZPy3tu+F493VmZsVisI8 j8xa40Uaosgu0cEUfvOzGruviHKoXiNpNVpypYSGwxIzl6I9AglFfOzCo5uJHg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=277ecc2488ca8b252c24d686a5ae3e46d0ee0df6 commit 277ecc2488ca8b252c24d686a5ae3e46d0ee0df6 Author: Bjoern A. Zeeb AuthorDate: 2021-12-26 17:24:04 +0000 Commit: Bjoern A. Zeeb 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 */