Date: Sun, 08 Feb 2026 20:05:49 +0000 From: Michael Tuexen <tuexen@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Cc: Timo =?utf-8?Q?V=C3=B6lker?= <timo.voelker@fh-muenster.de> Subject: git: d84870d90baf - main - ifinfo: improve output of hwassist value Message-ID: <6988ec9d.3c8ce.5586fa2c@gitrepo.freebsd.org>
index | next in thread | raw e-mail
The branch main has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=d84870d90bafe75eb87759df0ab41ff0214c866e commit d84870d90bafe75eb87759df0ab41ff0214c866e Author: Timo Völker <timo.voelker@fh-muenster.de> AuthorDate: 2026-02-08 20:02:58 +0000 Commit: Michael Tuexen <tuexen@FreeBSD.org> CommitDate: 2026-02-08 20:02:58 +0000 ifinfo: improve output of hwassist value In addition to print the hexadecimal number hwassist, also print the symbolic names of the corresponding CSUM_* flags. Reviewed by: tuexen MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D55055 --- tools/tools/ifinfo/ifinfo.c | 48 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/tools/tools/ifinfo/ifinfo.c b/tools/tools/ifinfo/ifinfo.c index 89d17f0c75fa..e8837de0b383 100644 --- a/tools/tools/ifinfo/ifinfo.c +++ b/tools/tools/ifinfo/ifinfo.c @@ -30,6 +30,7 @@ #include <sys/socket.h> /* for PF_LINK */ #include <sys/sysctl.h> #include <sys/time.h> +#include <sys/mbuf.h> #include <err.h> #include <errno.h> @@ -38,6 +39,8 @@ #include <string.h> #include <sysexits.h> #include <unistd.h> +#include <stdbool.h> +#include <ctype.h> #include <net/if.h> #include <net/if_types.h> @@ -149,6 +152,47 @@ main(int argc, char **argv) return retval; } +/* code after this line copied or based on code from src/sys/kern/subr_prf.c */ +static inline bool +isbitpos(char c) +{ + return (c != '\0' && (c <= ' ' || (c & 0x80) != 0)); +} + +static inline bool +isprintnospace(char c) +{ + return (isprint(c) && c != ' '); +} + +static void +print_bits(uintmax_t num, const char *bitstring) +{ + bool first; + const char *c; + int shift; + + c = ++bitstring; + first = true; + while (isbitpos(*c)) { + if ((*c & 0x80) != 0) + shift = *c++ & 0x7f; + else + shift = *c++ - 1; + if (num & (1ULL << shift)) { + putchar(first ? (first = false, '<') : ','); + for (; isprintnospace(*c); ++c) + putchar(*c); + } else + for (; isprintnospace(*c); ++c) + continue; + } + if (!first) { + putchar('>'); + } +} +/* code before this line copied or based on code from src/sys/kern/subr_prf.c */ + static void printit(const struct ifmibdata *ifmd, const char *dname) { @@ -182,8 +226,10 @@ printit(const struct ifmibdata *ifmd, const char *dname) printf("\tinput queue drops: %lu\n", ifmd->ifmd_data.ifi_iqdrops); printf("\tpackets for unknown protocol: %lu\n", ifmd->ifmd_data.ifi_noproto); - printf("\tHW offload capabilities: 0x%lx\n", + printf("\tHW offload capabilities: 0x%lx", ifmd->ifmd_data.ifi_hwassist); + print_bits(ifmd->ifmd_data.ifi_hwassist, CSUM_BITS); + printf("\n"); printf("\tuptime at attach or stat reset: %lu\n", ifmd->ifmd_data.ifi_epoch); #ifdef notdefhome | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6988ec9d.3c8ce.5586fa2c>
