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..c5db4b1daa103fe189f3c086089a715d825e5780 --- /dev/null +++ b/backport-dcb-fix-error-reporting-when-accessing-dcb-app.patch @@ -0,0 +1,81 @@ +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 +--- + dcb/dcb.c | 12 ++++++++---- + 1 file changed, 8 insertions(+), 4 deletions(-) + +diff --git a/dcb/dcb.c b/dcb/dcb.c +index b7c2df546..8d75ab0a0 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; diff --git a/iproute.spec b/iproute.spec index 443ce9e3213ed6c02f5f60da32818a2d14420fd8..43507b91bf006338d346dd2238ff59503e479e73 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/ @@ -70,6 +70,7 @@ patch6052: backport-mnl_utils-sanitize-incoming-netlink-payload-size-in-cal Patch6053: backport-devlink-use-snprintf-instead-of-sprintf.patch Patch6054: backport-ctrl-Fix-fd-leak-in-ctrl_list.patch Patch6055: backport-ctrl-Fix-fd-leak-in-ctrl_listen.patch +Patch6056: backport-dcb-fix-error-reporting-when-accessing-dcb-app.patch Patch9000: feature-iproute-add-support-for-ipvlan-l2e-mode.patch Patch9001: bugfix-iproute2-cancel-some-test-cases.patch @@ -150,6 +151,12 @@ install -m 0644 lib/libnetlink.a %{buildroot}%{_libdir}/libnetlink.a %{_mandir}/* %changelog +* Thu Oct 10 2024 zhongxuan - 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