From nobody Mon Nov 10 19:51:43 2025 X-Original-To: dev-commits-src-branches@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 4d50fl2xB2z63LPG; Mon, 10 Nov 2025 19:51: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 "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4d50fl2Mlvz3WwP; Mon, 10 Nov 2025 19:51:43 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1762804303; 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=2pgC6n43kkOCBDgJc4DkB86kCPXuFh3sOTqlUVME+hA=; b=S2qXrQ1U15CWhLla57nrRkMTuE260MWvsDCVAh3JyJRD5En6xv59wsM5948zTRIGpUNeJJ 2B2bNGviCYvEhg/63FI9whtPN5Ah7JER+BFxDfQ5qDZpsl5gxs538iX/ThFBkNqmj9KL7B NppFZXNsGvVZTguEium9sBIs85ek8uuJuTN5A5QQhpj36bnbHwsAGHC2CJmXml6+WcK/4t 1jEm10A1WtX1OJXdmyLYtct5IVbics1Dep3jD6VfQpLPc5N/XLpnlQfS3lT6xYx/PRZJc8 vBL8s89qo21iY6eOkAU2M6x0f3OZnYietkr96yPY7Vj8ZC+Xei7ZtU4xT0fA5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1762804303; 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=2pgC6n43kkOCBDgJc4DkB86kCPXuFh3sOTqlUVME+hA=; b=EVFZf48c3Ub0UWBoDBaAaa4TPAjQN7l3u3W7ltvoZ867lF8vnoOSpkQtE2QfMFedodkBGn h7ScQF4GgSmGNIKnoAfV8kGTDzOWjbPSjZzaU92/EaS+ngN0OlUsUtvwqLEpMyejfii74a K/5FWaxBqFiPXxKRItLZHEaqu2zxLluSEIKhyMq7+7ukY0t2/PAbH0v3Pu4wicFjP4hydD 905BuvnBU3HE6L2m1Et9whTd5R80dHwkrdLa1nxLpz/7rAIxG/4Csus7KWZSCyeCh2qGqo t2XBbaab5pg7EyZl5zEm0QpMCANnEcKu4KSMpMUluggRBuzpCL7yVp4/AawGbw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1762804303; a=rsa-sha256; cv=none; b=a1yDiLXIuZM7y7TgACYHtVZX/hZTjS8gvlzFRFkidOJdFXlpgO77vSmoiZtlHVIfzqQ4tA mM+QiUBgqUNPqksK3f5/00vADv+QMkSGhqb7OV0IFgxIMiciAWE/eBgVx3obfJDN9GZ4yX QbgsQupTmTrV1Hw5TrfexCJyqx7CpgZWuveoxzT1jEv9pW2UKn80scUlParxS8WbnfBweC SE/uuFSYZDRkse82pOM2J1CVzloNKaZ3HGRuwDpY/dKMMwThwCWeUyrA0pOwc2wa0eC9D8 ovNgKzFgxJbxAkrxjc9QblljAFpFG/mGa53JpbB2gfrQorl+YKJHRHFOKe2/gA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none 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 4d50fl1l6dzXXd; Mon, 10 Nov 2025 19:51:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 5AAJphZB004586; Mon, 10 Nov 2025 19:51:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 5AAJphdu004583; Mon, 10 Nov 2025 19:51:43 GMT (envelope-from git) Date: Mon, 10 Nov 2025 19:51:43 GMT Message-Id: <202511101951.5AAJphdu004583@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Michael Tuexen Subject: git: 1ccc6de2d215 - stable/14 - ddb: use %b when showing flags for an inp List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: tuexen X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 1ccc6de2d215647b074a45462c86a09c65cf467c Auto-Submitted: auto-generated The branch stable/14 has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=1ccc6de2d215647b074a45462c86a09c65cf467c commit 1ccc6de2d215647b074a45462c86a09c65cf467c Author: Michael Tuexen AuthorDate: 2025-11-02 16:12:32 +0000 Commit: Michael Tuexen CommitDate: 2025-11-10 19:50:10 +0000 ddb: use %b when showing flags for an inp This is much more compact. Thanks to markj@ for suggesting the change. Reviewed by: markj Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D53507 (cherry picked from commit e8c50058e8d03af17b7458bb560ddee29062082f) --- sys/netinet/in_pcb.c | 160 ++------------------------------------------------- sys/netinet/in_pcb.h | 14 +++++ 2 files changed, 18 insertions(+), 156 deletions(-) diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c index dd35f9583650..2263997ea154 100644 --- a/sys/netinet/in_pcb.c +++ b/sys/netinet/in_pcb.c @@ -3155,154 +3155,6 @@ db_print_inconninfo(struct in_conninfo *inc, const char *name, int indent) } void -db_print_inpflags(int inp_flags) -{ - int comma; - - comma = 0; - if (inp_flags & INP_RECVOPTS) { - db_printf("%sINP_RECVOPTS", comma ? ", " : ""); - comma = 1; - } - if (inp_flags & INP_RECVRETOPTS) { - db_printf("%sINP_RECVRETOPTS", comma ? ", " : ""); - comma = 1; - } - if (inp_flags & INP_RECVDSTADDR) { - db_printf("%sINP_RECVDSTADDR", comma ? ", " : ""); - comma = 1; - } - if (inp_flags & INP_HDRINCL) { - db_printf("%sINP_HDRINCL", comma ? ", " : ""); - comma = 1; - } - if (inp_flags & INP_HIGHPORT) { - db_printf("%sINP_HIGHPORT", comma ? ", " : ""); - comma = 1; - } - if (inp_flags & INP_LOWPORT) { - db_printf("%sINP_LOWPORT", comma ? ", " : ""); - comma = 1; - } - if (inp_flags & INP_ANONPORT) { - db_printf("%sINP_ANONPORT", comma ? ", " : ""); - comma = 1; - } - if (inp_flags & INP_RECVIF) { - db_printf("%sINP_RECVIF", comma ? ", " : ""); - comma = 1; - } - if (inp_flags & INP_MTUDISC) { - db_printf("%sINP_MTUDISC", comma ? ", " : ""); - comma = 1; - } - if (inp_flags & INP_RECVTTL) { - db_printf("%sINP_RECVTTL", comma ? ", " : ""); - comma = 1; - } - if (inp_flags & INP_DONTFRAG) { - db_printf("%sINP_DONTFRAG", comma ? ", " : ""); - comma = 1; - } - if (inp_flags & INP_BINDANY) { - db_printf("%sINP_BINDANY", comma ? ", " : ""); - comma = 1; - } - if (inp_flags & INP_INHASHLIST) { - db_printf("%sINP_INHASHLIST", comma ? ", " : ""); - comma = 1; - } - if (inp_flags & INP_RECVTOS) { - db_printf("%sINP_RECVTOS", comma ? ", " : ""); - comma = 1; - } - if (inp_flags & IN6P_IPV6_V6ONLY) { - db_printf("%sIN6P_IPV6_V6ONLY", comma ? ", " : ""); - comma = 1; - } - if (inp_flags & IN6P_PKTINFO) { - db_printf("%sIN6P_PKTINFO", comma ? ", " : ""); - comma = 1; - } - if (inp_flags & IN6P_HOPLIMIT) { - db_printf("%sIN6P_HOPLIMIT", comma ? ", " : ""); - comma = 1; - } - if (inp_flags & IN6P_HOPOPTS) { - db_printf("%sIN6P_HOPOPTS", comma ? ", " : ""); - comma = 1; - } - if (inp_flags & IN6P_DSTOPTS) { - db_printf("%sIN6P_DSTOPTS", comma ? ", " : ""); - comma = 1; - } - if (inp_flags & IN6P_RTHDR) { - db_printf("%sIN6P_RTHDR", comma ? ", " : ""); - comma = 1; - } - if (inp_flags & IN6P_RTHDRDSTOPTS) { - db_printf("%sIN6P_RTHDRDSTOPTS", comma ? ", " : ""); - comma = 1; - } - if (inp_flags & IN6P_TCLASS) { - db_printf("%sIN6P_TCLASS", comma ? ", " : ""); - comma = 1; - } - if (inp_flags & IN6P_AUTOFLOWLABEL) { - db_printf("%sIN6P_AUTOFLOWLABEL", comma ? ", " : ""); - comma = 1; - } - if (inp_flags & INP_ONESBCAST) { - db_printf("%sINP_ONESBCAST", comma ? ", " : ""); - comma = 1; - } - if (inp_flags & INP_DROPPED) { - db_printf("%sINP_DROPPED", comma ? ", " : ""); - comma = 1; - } - if (inp_flags & INP_SOCKREF) { - db_printf("%sINP_SOCKREF", comma ? ", " : ""); - comma = 1; - } - if (inp_flags & INP_RESERVED_0) { - db_printf("%sINP_RESERVED_0", comma ? ", " : ""); - comma = 1; - } - if (inp_flags & INP_BOUNDFIB) { - db_printf("%sINP_BOUNDFIB", comma ? ", " : ""); - comma = 1; - } - if (inp_flags & IN6P_RFC2292) { - db_printf("%sIN6P_RFC2292", comma ? ", " : ""); - comma = 1; - } - if (inp_flags & IN6P_MTU) { - db_printf("IN6P_MTU%s", comma ? ", " : ""); - comma = 1; - } -} - -static void -db_print_inpvflag(u_char inp_vflag) -{ - int comma; - - comma = 0; - if (inp_vflag & INP_IPV4) { - db_printf("%sINP_IPV4", comma ? ", " : ""); - comma = 1; - } - if (inp_vflag & INP_IPV6) { - db_printf("%sINP_IPV6", comma ? ", " : ""); - comma = 1; - } - if (inp_vflag & INP_IPV6PROTO) { - db_printf("%sINP_IPV6PROTO", comma ? ", " : ""); - comma = 1; - } -} - -static void db_print_inpcb(struct inpcb *inp, const char *name, int indent) { @@ -3321,16 +3173,12 @@ db_print_inpcb(struct inpcb *inp, const char *name, int indent) inp->inp_ppcb, inp->inp_pcbinfo, inp->inp_socket); db_print_indent(indent); - db_printf("inp_label: %p inp_flags: 0x%x (", - inp->inp_label, inp->inp_flags); - db_print_inpflags(inp->inp_flags); - db_printf(")\n"); + db_printf("inp_label: %p inp_flags: 0x%b\n", + inp->inp_label, inp->inp_flags, INP_FLAGS_BITS); db_print_indent(indent); - db_printf("inp_sp: %p inp_vflag: 0x%x (", inp->inp_sp, - inp->inp_vflag); - db_print_inpvflag(inp->inp_vflag); - db_printf(")\n"); + db_printf("inp_sp: %p inp_vflag: 0x%b\n", inp->inp_sp, + inp->inp_vflag, INP_VFLAGS_BITS); db_print_indent(indent); db_printf("inp_ip_ttl: %d inp_ip_p: %d inp_ip_minttl: %d\n", diff --git a/sys/netinet/in_pcb.h b/sys/netinet/in_pcb.h index 9095e6bb71bf..0492bf78bfaa 100644 --- a/sys/netinet/in_pcb.h +++ b/sys/netinet/in_pcb.h @@ -524,6 +524,9 @@ void inp_4tuple_get(struct inpcb *inp, uint32_t *laddr, uint16_t *lp, #define INP_IPV6 0x2 #define INP_IPV6PROTO 0x4 /* opened under IPv6 protocol */ +/* inp_vflags description for use with printf(9) %b identifier. */ +#define INP_VFLAGS_BITS "\20\1INP_IPV4\2INP_IPV6\3INP_IPV6PROTO" + /* * Flags for inp_flags. */ @@ -567,6 +570,17 @@ void inp_4tuple_get(struct inpcb *inp, uint32_t *laddr, uint16_t *lp, IN6P_TCLASS|IN6P_AUTOFLOWLABEL|IN6P_RFC2292|\ IN6P_MTU) +/* inp_flags description for use with printf(9) %b identifier. */ +#define INP_FLAGS_BITS "\20" \ + "\1INP_RECVOPTS\2INP_RECVRETOPTS\3INP_RECVDSTADDR\4INP_HDRINCL" \ + "\5INP_HIGHPORT\6INP_LOWPORT\7INP_ANONPORT\10INP_RECVIF" \ + "\11INP_MTUDISC\12INP_FREED\13INP_RECVTTL\14INP_DONTFRAG" \ + "\15INP_BINDANY\16INP_INHASHLIST\17INP_RECVTOS\20IN6P_IPV6_V6ONLY" \ + "\21IN6P_PKTINFO\22IN6P_HOPLIMIT\23IN6P_HOPOPTS\24IN6P_DSTOPTS" \ + "\25IN6P_RTHDR\26IN6P_RTHDRDSTOPTS\27IN6P_TCLASS\30IN6P_AUTOFLOWLABEL" \ + "\31INP_INLBGROUP\32INP_ONESBCAST\33INP_DROPPED\34INP_SOCKREF" \ + "\35INP_RESERVED_0\36INP_BOUNDFIB\37IN6P_RFC2292\40IN6P_MTU" + /* * Flags for inp_flags2. */