netlink: fix missing headers in text output.

Resolves: RHEL-106544

Signed-off-by: Mohammad Heib <mheib@redhat.com>
This commit is contained in:
Mohammad Heib 2025-08-01 11:43:05 +03:00
parent 7f1d42eb5b
commit a7682716fb
2 changed files with 71 additions and 2 deletions

View File

@ -0,0 +1,64 @@
From b70c928661024cd07914feb49122275daab904ea Mon Sep 17 00:00:00 2001
From: Jakub Kicinski <kuba@kernel.org>
Date: Sat, 12 Jul 2025 07:51:05 -0700
Subject: [PATCH] netlink: fix missing headers in text output
The commit under fixes added a NULL-check which prevents us from
printing text headers. Conversions to add JSON support often use:
print_string(PRINT_FP, NULL, "some text:\n", NULL);
to print in plain text mode.
Correct output:
Channel parameters for vpn0:
Pre-set maximums:
RX: n/a
TX: n/a
Other: n/a
Combined: 1
Current hardware settings:
RX: n/a
TX: n/a
Other: n/a
Combined: 0
With the buggy patch:
Channel parameters for vpn0:
RX: n/a
TX: n/a
Other: n/a
Combined: 1
RX: n/a
TX: n/a
Other: n/a
Combined: 0
Fixes: fd328ccb3cc0 ("json_print: add NULL check before jsonw_string_field() in print_string()")
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
json_print.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/json_print.c b/json_print.c
index 4f61640..e07c651 100644
--- a/json_print.c
+++ b/json_print.c
@@ -143,10 +143,11 @@ void print_string(enum output_type type,
} else if (_IS_FP_CONTEXT(type)) {
if (value)
fprintf(stdout, fmt, value);
+ else
+ fprintf(stdout, "%s", fmt);
}
}
-
/*
* value's type is bool. When using this function in FP context you can't pass
* a value to it, you will need to use "is_json_context()" to have different
--
2.49.0

View File

@ -2,13 +2,14 @@ Summary: Settings tool for Ethernet NICs
Name: ethtool
Epoch: 2
Version: 6.15
Release: 1%{?dist}
Release: 2%{?dist}
# {json_print,qsfp,sff-common}.{c,h} are GPL-2.0-or-later, rest is GPL-2.0-only
License: GPL-2.0-only AND GPL-2.0-or-later
URL: https://www.kernel.org/pub/software/network/%{name}/
Source0: https://www.kernel.org/pub/software/network/%{name}/%{name}-%{version}.tar.xz
Source1: https://www.kernel.org/pub/software/network/%{name}/%{name}-%{version}.tar.sign
Source2: https://keys.openpgp.org/vks/v1/by-fingerprint/D2CB120AB45957B721CD9596F4554567B91DE934
Patch0: 0001-netlink-fix-missing-headers-in-text-output.patch
BuildRequires: gnupg2, xz
BuildRequires: gcc
BuildRequires: libmnl-devel
@ -22,7 +23,7 @@ network devices, especially of Ethernet devices.
%prep
xzcat '%{SOURCE0}' | %{gpgverify} --keyring='%{SOURCE2}' --signature='%{SOURCE1}' --data=-
%autosetup
%autosetup -p1
%build
%configure
@ -45,6 +46,10 @@ make check
%{_datadir}/metainfo/org.kernel.software.network.ethtool.metainfo.xml
%changelog
* Fri Aug 01 2025 Mohammad Heib <mheib@redhat.com>
- netlink: fix missing headers in text output.
Resolves: RHEL-106544
* Tue Jun 24 2025 Mohammad Heib <mheib@redhat.com> - 2:6.15-1
- Update to latest upstream release v6.15.
Resolves RHEL-99667.