From nobody Mon Nov 10 19:51:40 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 4d50fh1vyXz63LCF; Mon, 10 Nov 2025 19:51:40 +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 4d50fh1Pdfz3X3T; Mon, 10 Nov 2025 19:51:40 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1762804300; 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=fQuQa3M6KEZPAX21wxDnfOMWiR07UxTDx2r19qKAOwA=; b=DRI7Z4VEsKWTWlbBqeImEbEjwgr7OlJydiH6nZis1zyXQiIAH59mPw9vhjcZ7WBxk3qnNv NEr0KR/9ez3uxDH4teP1Jdu2pF9MTFSeLP20sw2sZA+Ue3qKVOwvD6YJ1QdcuW5MRLQFRV yzwQ/zFxE+I2LHE8Qt9LdyGgdE3070cwbXfiVL5GEkbh9DeVwciAdVG6Jjv2G8qooY4yRT ef95pI5f0XOgw2xfxOInYGIHOvsfWNp20eh9HQbEx7MXwRd12GyLGT6gKCBwSLAjFnY2ie ejHxZJ1gNfUREVCxzm1xC/UbYayYPJxc6mgll7BMOYwS1lL9Nlqyl7WFNjzKHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1762804300; 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=fQuQa3M6KEZPAX21wxDnfOMWiR07UxTDx2r19qKAOwA=; b=TE3A4sTAsRIuzkdlylDy1BsmhxjnsBFgCerPMbeGJ5s6PmuLcwvQe3XZIlryY4C9ft+44A FO1sMwZ3+OV68Xjs1QZ3WN264Vw+IX2I5OVe+6kGKk8zPdgP9NXjBh0Pv26IsTaA25rWai PG2BIBpZ6q3PnW6x80APzQpb51+YpL+C5ZipiPCi4UHdaY9iexslkoOzAgSrGIToAKiqpe hTCmk4mASXTVkl6vS6ZwAmYIAZjOlY1SpH/43SsuRyQIn3X9NMaLyUBLtcd7QCI4+wWkMQ BES0XtKdcZiAwxi3xtlh1+vR7M707H13/hawcVChX9aN/3B3BgmH7L+BoYcC5g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1762804300; a=rsa-sha256; cv=none; b=C3xHW8RAssnJA436hXTIMZC3EEJHPhx4qFqgApCE8QKv4yXEL3x6eQJjRHW9togVDgA/CX non1yR9l68CeBD7sJeozqIwL12dJtEoIpbRLijLjwIJxwL0Ecp0nLwY00xjjMw9NeZRLMD ZShk4G3P/U25Zyc1wEuQwrj485c6B7jcesQbaGjSfl07qz7SpJ4Octppllzs6D1SdsmP04 vWiBFC7eMIVag1M2YK4deiquDbEwrUtzXamaG5Llh/HqzzdqK3BknmCUNZspf8GHa9uO6g d6wv/KD6laFERKTgaDVRjfr5bI/N/x/LMSElBmO6uSzy9SEV0sBS+07C5lN45Q== 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 4d50fh0pR6zXMJ; Mon, 10 Nov 2025 19:51:40 +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 5AAJpebk004448; Mon, 10 Nov 2025 19:51:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 5AAJpeUC004445; Mon, 10 Nov 2025 19:51:40 GMT (envelope-from git) Date: Mon, 10 Nov 2025 19:51:40 GMT Message-Id: <202511101951.5AAJpeUC004445@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: 44305e736871 - stable/15 - 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/15 X-Git-Reftype: branch X-Git-Commit: 44305e736871be896c8a3280a749f2c786b5da26 Auto-Submitted: auto-generated The branch stable/15 has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=44305e736871be896c8a3280a749f2c786b5da26 commit 44305e736871be896c8a3280a749f2c786b5da26 Author: Michael Tuexen AuthorDate: 2025-11-02 16:12:32 +0000 Commit: Michael Tuexen CommitDate: 2025-11-10 19:46:09 +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 f573e07163fd..4a1a8cdea619 100644 --- a/sys/netinet/in_pcb.c +++ b/sys/netinet/in_pcb.c @@ -3059,154 +3059,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) { @@ -3221,16 +3073,12 @@ db_print_inpcb(struct inpcb *inp, const char *name, int indent) db_print_inconninfo(&inp->inp_inc, "inp_conninfo", indent); 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 7d41e3d690e0..60f129bce216 100644 --- a/sys/netinet/in_pcb.h +++ b/sys/netinet/in_pcb.h @@ -539,6 +539,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. */ @@ -582,6 +585,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. */