From nobody Sun Jul 5 14:15:54 2026 X-Original-To: dev-commits-src-main@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 4gtTzv11swz6kLSX for ; Sun, 05 Jul 2026 14:15:55 +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 "YR1" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4gtTzt5yPSz3Cm2 for ; Sun, 05 Jul 2026 14:15:54 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1783260954; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=LcMs9aTyS34ctPgor2Vvjro6AQeDYNX7UCXCZtbcyyk=; b=pjsDEzq4Ab5kGnorYhuV9DQPG60GaJlystDmlp6XUrd30C5+V1XDFgFuW9XCjzkpcpgvki f6STSsTIaePjOFlW4IkUDsmEZZg5o3x4F+ObePKMQIF4qAAMIrQG1Bip0Z3/VOrtr8RPjq mv3fYg25myJp53dsj92+JbUrUIVFwDSNmGpMHikI5wxQUxz/MS2jzFnlU7/jOtadCUXPEe dIr4HqrxyC2rEkWtkWK79NpW1WDqFscr0yILP49Vb0zR7G5SQZfhU/KzEOVE10YIYguRtc zvCobnpr4cnnwbdDPr+j8lhUsNFvk2EG/XbFSJPjUMtONMcMn6F7WybN42ZPOQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1783260954; a=rsa-sha256; cv=none; b=yq89uoaW9vjg/zDFrkjEseehoEAo36tHr8m+wHAYV0MCbTmOPQJUidtVDygBT29ZvtlI+4 DwTwvvH3EB48CTWGHPf//tsAWRHH0Ce3zQYyYoKhqrZIWykXc6whbcMW2/8C7IkzCufu3/ 3Pg6grFcoCSse92JMlSAfB170SpD41MbuakX5888nAbKQ2CNWYmPG8QgX1V3nNbLr5Ki3v srYVB02l8za33DirO3ubtZ6fZQFbUKwyat+qZiypspAHuq6jkRsHdnXvN6q17Hp2/vr4Bv KwQywPaGwqv/c0fcIcAGt9dBXhvHpkp5MXoX1PeR8l3pNqXDLxVt8Fz2zy9wjg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1783260954; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=LcMs9aTyS34ctPgor2Vvjro6AQeDYNX7UCXCZtbcyyk=; b=Ie7l4n5REhNrxrqyvOOvUEWDvsV3mZ057hIiqv4PYd4UhkEqovyJ96+joU09+xM2Zk1Yqa s8WiElM/H2rfiM28+DuuaN0BAd1bvrX2HmfED6jRRh9jx78Knz2q1eOpSjioU6sk1oLP5e Vk/sG6vNPWuBE+zxsqedDOYW67AuYccJunJBlQTG8iS0takIWgSAbUZowh+bBCAirKkhiQ W6MvjOHUAtI5WzOpKdbbi9qxS63/CpqJ4Ipc2IVHJI50RY4EvAndWOsIN6Dv1d22xasetX PZtEsRyjdk4T3MsRCIzEFcl75ivhRakyS3HquAe8XrTspZxaELX5qXEHTkBlEg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gtTzt3vBWz6KV for ; Sun, 05 Jul 2026 14:15:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 3d2df by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sun, 05 Jul 2026 14:15:54 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Cc: Ishan Agrawal From: Kristof Provost Subject: git: 80586e853674 - main - libsysdecode: decode Generic Netlink controller messages List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 80586e853674c6d63888379274accea5c82407f2 Auto-Submitted: auto-generated Date: Sun, 05 Jul 2026 14:15:54 +0000 Message-Id: <6a4a671a.3d2df.6ffd9424@gitrepo.freebsd.org> The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=80586e853674c6d63888379274accea5c82407f2 commit 80586e853674c6d63888379274accea5c82407f2 Author: Ishan Agrawal AuthorDate: 2026-06-29 05:17:14 +0000 Commit: Kristof Provost CommitDate: 2026-07-05 14:03:34 +0000 libsysdecode: decode Generic Netlink controller messages Decode Generic Netlink controller (GENL_ID_CTRL) messages in Netlink payloads. Display the Generic Netlink header along with the CTRL_CMD_GETFAMILY attributes, including the family ID and family name. Signed-off-by: Ishan Agrawal Reviewed by: kp Sponsored-by: Google LLC (GSoC 2026) --- lib/libsysdecode/netlink.c | 70 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 60 insertions(+), 10 deletions(-) diff --git a/lib/libsysdecode/netlink.c b/lib/libsysdecode/netlink.c index 723272d3b8da..4dbe6c087dcf 100644 --- a/lib/libsysdecode/netlink.c +++ b/lib/libsysdecode/netlink.c @@ -6,6 +6,8 @@ #include #include +#include +#include #include #include @@ -20,6 +22,7 @@ * Returns false if the data is malformed, allowing the caller * to fallback to a standard hex/string dump. */ + bool sysdecode_netlink(FILE *fp, const void *buf, size_t len, int protocol) { @@ -51,7 +54,16 @@ sysdecode_netlink(FILE *fp, const void *buf, size_t len, int protocol) break; } - fprintf(fp, "len=%u,type=", nl->nlmsg_len); + 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); + + fprintf(fp, ",seq=%u,pid=%u", nl->nlmsg_seq, nl->nlmsg_pid); + + fprintf(fp, ",len=%u,type=", nl->nlmsg_len); /* Decode Standard Message Types. */ switch (nl->nlmsg_type) { @@ -67,20 +79,58 @@ sysdecode_netlink(FILE *fp, const void *buf, size_t len, int protocol) case NLMSG_OVERRUN: fprintf(fp, "NLMSG_OVERRUN"); break; + case GENL_ID_CTRL: + if (protocol != NETLINK_GENERIC) + break; + + fprintf(fp, "GENL_ID_CTRL"); + + const struct genlmsghdr *genl = + (const struct genlmsghdr *)(const void *) + ((const char *)nl + sizeof(struct nlmsghdr)); + + uint16_t family_id = 0; + const char *family_name = NULL; + + fprintf(fp, + ",genl={cmd=%u," + "ver=%u,reserve=%u", + genl->cmd, + genl->version, genl->reserved); + + size_t cur_len = (sizeof(struct nlmsghdr) + + sizeof(struct genlmsghdr)); + size_t nla_len = nl->nlmsg_len - cur_len; + + const struct nlattr *nla; + const struct nlattr *nla_head = (const struct nlattr *) + (const void *)((const char *)nl + cur_len); + + NLA_FOREACH_CONST(nla, nla_head, nla_len) { + switch (nla->nla_type) { + case CTRL_ATTR_FAMILY_ID: + memcpy(&family_id, NLA_DATA_CONST(nla), + sizeof(family_id)); + fprintf(fp, ",family_id=%u", family_id); + break; + case CTRL_ATTR_FAMILY_NAME: + family_name = + ((const char *)NLA_DATA_CONST(nla)); + fprintf(fp, ",family_name=%s", + family_name); + break; + default: + break; + } + } + + fprintf(fp, "}"); + break; default: fprintf(fp, "%u", nl->nlmsg_type); break; } - 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); - - fprintf(fp, ",seq=%u,pid=%u", nl->nlmsg_seq, nl->nlmsg_pid); - /* Handle Alignment (Netlink messages are 4-byte aligned). */ size_t aligned_len = NLMSG_ALIGN(nl->nlmsg_len); if (aligned_len > remaining)