diff --git a/backport-dcb-Fix-error-reporting-when-accessing-dcb-app.patch b/backport-dcb-Fix-error-reporting-when-accessing-dcb-app.patch new file mode 100644 index 0000000000000000000000000000000000000000..00fda53fd66e5f8ebf80aeae91cc8e4171c884fb --- /dev/null +++ b/backport-dcb-Fix-error-reporting-when-accessing-dcb-app.patch @@ -0,0 +1,86 @@ +From 1b5c7414a42a29d559af85022afebc307a2b9d12 Mon Sep 17 00:00:00 2001 +From: Petr Machata +Date: Wed, 9 Feb 2022 15:41:40 +0100 +Subject: [PATCH] dcb: Fix error reporting when accessing "dcb app" + +Currently dcb decodes the response from "dcb app add" and "del" by +interpreting the returned attribute as u8. But the value stored there is +actually a negative errno value. + +Additionally, "dcb app" currently shows two sets of messages, one in +dcb_set_attribute_attr_cb() where the issue is detected, and another as a +result of error return from that function. + +The current state is as follows: + + # dcb app add dev swp36 dscp-prio 20:2 + Error when attempting to set attribute: Unknown error 239 + Attribute write: No such file or directory + +Fix the "unknown error" issue by correctly decoding the attribute as i8 and +negating it. Furthermore, set errno to that value, and let the top-level +"attribute write" error message show the correct message. + +Initialize errno to 0 before the dcb_talk() dispatch, and make the error +print conditional on errno != 0. This way the few error messages that are +worth describing in the place where they are detected will not cause the +second error message to be printed. + +The fixed reporting looks like this: + + # dcb app add dev swp36 dscp-prio 20:2 + Attribute write: File exists + +Reported-by: Maksym Yaremchuk +Signed-off-by: Petr Machata +Signed-off-by: Stephen Hemminger + +Reference: https://github.com/iproute2/iproute2/commit/1b5c7414a42a29d559af85022afebc307a2b9d12 +--- + dcb/dcb.c | 12 ++++++++---- + 1 file changed, 8 insertions(+), 4 deletions(-) + +diff --git a/dcb/dcb.c b/dcb/dcb.c +index b7c2df54..8d75ab0a 100644 +--- a/dcb/dcb.c ++++ b/dcb/dcb.c +@@ -106,7 +106,7 @@ static int dcb_set_attribute_attr_cb(const struct nlattr *attr, void *data) + { + struct dcb_set_attribute_response *resp = data; + uint16_t len; +- uint8_t err; ++ int8_t err; + + if (mnl_attr_get_type(attr) != resp->response_attr) + return MNL_CB_OK; +@@ -117,10 +117,12 @@ static int dcb_set_attribute_attr_cb(const struct nlattr *attr, void *data) + return MNL_CB_ERROR; + } + ++ /* The attribute is formally u8, but actually an i8 containing a ++ * negative errno value. ++ */ + err = mnl_attr_get_u8(attr); + if (err) { +- fprintf(stderr, "Error when attempting to set attribute: %s\n", +- strerror(err)); ++ errno = -err; + return MNL_CB_ERROR; + } + +@@ -242,9 +244,11 @@ static int __dcb_set_attribute(struct dcb *dcb, int command, const char *dev, + if (ret) + return ret; + ++ errno = 0; + ret = dcb_talk(dcb, nlh, dcb_set_attribute_cb, &resp); + if (ret) { +- perror("Attribute write"); ++ if (errno) ++ perror("Attribute write"); + return ret; + } + return 0; +-- +2.43.0.windows.1 + diff --git a/iproute.spec b/iproute.spec index 443ce9e3213ed6c02f5f60da32818a2d14420fd8..7a2c7e89d389aeddc2b6c193931e0cec51d8492c 100644 --- a/iproute.spec +++ b/iproute.spec @@ -2,7 +2,7 @@ Name: iproute Version: 5.15.0 Epoch: 1 -Release: 20 +Release: 21 Summary: Linux network configuration utilities License: GPLv2+ and Public Domain URL: https://kernel.org/pub/linux/utils/net/iproute2/ @@ -75,6 +75,7 @@ Patch9000: feature-iproute-add-support-for-ipvlan-l2e-mode.patch Patch9001: bugfix-iproute2-cancel-some-test-cases.patch Patch9002: feature-iproute2-supports-to-parse-UB-device-and-related-display-of-vf-address.patch Patch9003: sync-ipvlan_mode-enum-with-kernel-headers.patch +Patch9004: backport-dcb-Fix-error-reporting-when-accessing-dcb-app.patch BuildRequires: gcc bison elfutils-libelf-devel flex iptables-devel BuildRequires: libmnl-devel libselinux-devel pkgconfig libbpf-devel sudo make @@ -150,6 +151,12 @@ install -m 0644 lib/libnetlink.a %{buildroot}%{_libdir}/libnetlink.a %{_mandir}/* %changelog +* Wed Oct 09 2024 liningjie - 1:5.15.0-21 +- Type:bugfix +- ID:NA +- SUG:NA +- DESC:dcb: Fix error reporting when accessing "dcb app" + * Fri Jul 26 2024 caokeming - 1:5.15.0-20 - Type:bugfix - ID:NA