Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 27 Jul 2026 09:28:18 +0000
From:      Kristof Provost <kp@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Cc:        Ishan Agrawal <iagrawal9990@gmail.com>
Subject:   git: 407b7bcc9386 - main - libsysdecode: decode combined Netlink message flags
Message-ID:  <6a6724b2.19b7e.6b2f266a@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch main has been updated by kp:

URL: https://cgit.FreeBSD.org/src/commit/?id=407b7bcc93862fe0c026e254bac8ec0e8318e7e6

commit 407b7bcc93862fe0c026e254bac8ec0e8318e7e6
Author:     Ishan Agrawal <iagrawal9990@gmail.com>
AuthorDate: 2026-07-23 02:29:48 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2026-07-27 09:27:54 +0000

    libsysdecode: decode combined Netlink message flags
    
    Change sysdecode_nlm_flag() to decode Netlink message flags as a
    bitmask instead of looking up a single flag value. This correctly
    prints combinations of NLM_F_* flags while preserving any unknown
    bits in hexadecimal.
    
    Reported by:    androvonx95 <androvonx95@tutamail.com>
    Reviewed by:    kp
    Signed-off-by:  Ishan Agrawal <iagrawal9990@gmail.com>
    Sponsored-by:   Google LLC (GSoC 2026)
---
 lib/libsysdecode/flags.c     | 11 ++++++++---
 lib/libsysdecode/netlink.c   |  7 +------
 lib/libsysdecode/sysdecode.h |  2 +-
 3 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/lib/libsysdecode/flags.c b/lib/libsysdecode/flags.c
index f94fb88ebf83..880fe5e1ed49 100644
--- a/lib/libsysdecode/flags.c
+++ b/lib/libsysdecode/flags.c
@@ -1217,9 +1217,14 @@ sysdecode_pfnl_cmd(int cmd)
 	return (lookup_value(pfnl_cmd, cmd));
 }
 
-const char *
-sysdecode_nlm_flag(int flag)
+void
+sysdecode_nlm_flag(FILE *fp, int flags)
 {
 
-	return (lookup_value(nlm_flag, flag));
+	int rem;
+
+	if (!print_mask_int(fp, nlm_flag, flags, &rem))
+		fprintf(fp, "0x%x", rem);
+	else if (rem != 0)
+		fprintf(fp, "|0x%x", rem);
 }
diff --git a/lib/libsysdecode/netlink.c b/lib/libsysdecode/netlink.c
index bb07ad2e4bf7..6e2af72374b0 100644
--- a/lib/libsysdecode/netlink.c
+++ b/lib/libsysdecode/netlink.c
@@ -287,11 +287,7 @@ sysdecode_netlink(FILE *fp, const void *buf, size_t len, int protocol)
 		}
 
 		fprintf(fp, "flags=");
-		const char *nlm_f = sysdecode_nlm_flag(nl->nlmsg_flags);
-		if (nlm_f != NULL)
-			fprintf(fp, "%s", nlm_f);
-		else
-			fprintf(fp, "0x%x", nl->nlmsg_flags);
+		sysdecode_nlm_flag(fp, nl->nlmsg_flags);
 
 		fprintf(fp, ",seq=%u,pid=%u", nl->nlmsg_seq, nl->nlmsg_pid);
 
@@ -371,7 +367,6 @@ sysdecode_netlink(FILE *fp, const void *buf, size_t len, int protocol)
 				family_table[num_family] =
 				    (struct name_table){0, NULL};
 			}
-
 			fprintf(fp, "}");
 			break;
 		default:
diff --git a/lib/libsysdecode/sysdecode.h b/lib/libsysdecode/sysdecode.h
index bd38bb5bdc42..513ecddf07bd 100644
--- a/lib/libsysdecode/sysdecode.h
+++ b/lib/libsysdecode/sysdecode.h
@@ -67,7 +67,7 @@ void	sysdecode_kevent_fflags(FILE *_fp, short _filter, int _fflags,
 	    int _base);
 const char *sysdecode_itimer(int _which);
 const char *sysdecode_pfnl_cmd(int _cmd);
-const char *sysdecode_nlm_flag(int _flag);
+void	sysdecode_nlm_flag(FILE *_fp, int _flag);
 const char *sysdecode_kevent_filter(int _filter);
 bool	sysdecode_kevent_flags(FILE *_fp, int _flags, int *_rem);
 const char *sysdecode_kldsym_cmd(int _cmd);


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6a6724b2.19b7e.6b2f266a>