Open
backport patch #201
zhongxuan2Add on Oct 10, 2024
backport patch #201
Open
Merged fromrefs/pull/201/headintoopenEuler-22.03-LTS-SP4
Total: 2 files changed+89-1
| @@ -0,0 +1,81 @@ | |||
| 1 | +From 1b5c7414a42a29d559af85022afebc307a2b9d12 Mon Sep 17 00:00:00 2001 | ||
| 2 | +From: Petr Machata <petrm@nvidia.com> | ||
| 3 | +Date: Wed, 9 Feb 2022 15:41:40 +0100 | ||
| 4 | +Subject: [PATCH] dcb: Fix error reporting when accessing "dcb app" | ||
| 5 | + | ||
| 6 | +Currently dcb decodes the response from "dcb app add" and "del" by | ||
| 7 | +interpreting the returned attribute as u8. But the value stored there is | ||
| 8 | +actually a negative errno value. | ||
| 9 | + | ||
| 10 | +Additionally, "dcb app" currently shows two sets of messages, one in | ||
| 11 | +dcb_set_attribute_attr_cb() where the issue is detected, and another as a | ||
| 12 | +result of error return from that function. | ||
| 13 | + | ||
| 14 | +The current state is as follows: | ||
| 15 | + | ||
| 16 | + # dcb app add dev swp36 dscp-prio 20:2 | ||
| 17 | + Error when attempting to set attribute: Unknown error 239 | ||
| 18 | + Attribute write: No such file or directory | ||
| 19 | + | ||
| 20 | +Fix the "unknown error" issue by correctly decoding the attribute as i8 and | ||
| 21 | +negating it. Furthermore, set errno to that value, and let the top-level | ||
| 22 | +"attribute write" error message show the correct message. | ||
| 23 | + | ||
| 24 | +Initialize errno to 0 before the dcb_talk() dispatch, and make the error | ||
| 25 | +print conditional on errno != 0. This way the few error messages that are | ||
| 26 | +worth describing in the place where they are detected will not cause the | ||
| 27 | +second error message to be printed. | ||
| 28 | + | ||
| 29 | +The fixed reporting looks like this: | ||
| 30 | + | ||
| 31 | + # dcb app add dev swp36 dscp-prio 20:2 | ||
| 32 | + Attribute write: File exists | ||
| 33 | + | ||
| 34 | +Reported-by: Maksym Yaremchuk <maksymy@nvidia.com> | ||
| 35 | +Signed-off-by: Petr Machata <petrm@nvidia.com> | ||
| 36 | +Signed-off-by: Stephen Hemminger <stephen@networkplumber.org> | ||
| 37 | +--- | ||
| 38 | + dcb/dcb.c | 12 ++++++++---- | ||
| 39 | + 1 file changed, 8 insertions(+), 4 deletions(-) | ||
| 40 | + | ||
| 41 | +diff --git a/dcb/dcb.c b/dcb/dcb.c | ||
| 42 | +index b7c2df546..8d75ab0a0 100644 | ||
| 43 | +--- a/dcb/dcb.c | ||
| 44 | ++++ b/dcb/dcb.c | ||
| 45 | +@@ -106,7 +106,7 @@ static int dcb_set_attribute_attr_cb(const struct nlattr *attr, void *data) | ||
| 46 | + { | ||
| 47 | + struct dcb_set_attribute_response *resp = data; | ||
| 48 | + uint16_t len; | ||
| 49 | +- uint8_t err; | ||
| 50 | ++ int8_t err; | ||
| 51 | + | ||
| 52 | + if (mnl_attr_get_type(attr) != resp->response_attr) | ||
| 53 | + return MNL_CB_OK; | ||
| 54 | +@@ -117,10 +117,12 @@ static int dcb_set_attribute_attr_cb(const struct nlattr *attr, void *data) | ||
| 55 | + return MNL_CB_ERROR; | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | ++ /* The attribute is formally u8, but actually an i8 containing a | ||
| 59 | ++ * negative errno value. | ||
| 60 | ++ */ | ||
| 61 | + err = mnl_attr_get_u8(attr); | ||
| 62 | + if (err) { | ||
| 63 | +- fprintf(stderr, "Error when attempting to set attribute: %s\n", | ||
| 64 | +- strerror(err)); | ||
| 65 | ++ errno = -err; | ||
| 66 | + return MNL_CB_ERROR; | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | +@@ -242,9 +244,11 @@ static int __dcb_set_attribute(struct dcb *dcb, int command, const char *dev, | ||
| 70 | + if (ret) | ||
| 71 | + return ret; | ||
| 72 | + | ||
| 73 | ++ errno = 0; | ||
| 74 | + ret = dcb_talk(dcb, nlh, dcb_set_attribute_cb, &resp); | ||
| 75 | + if (ret) { | ||
| 76 | +- perror("Attribute write"); | ||
| 77 | ++ if (errno) | ||
| 78 | ++ perror("Attribute write"); | ||
| 79 | + return ret; | ||
| 80 | + } | ||
| 81 | + return 0; | ||
| @@ -2,7 +2,7 @@ | |||
| 2 | Name: iproute | 2 | Name: iproute |
| 3 | Version: 5.15.0 | 3 | Version: 5.15.0 |
| 4 | Epoch: 1 | 4 | Epoch: 1 |
| 5 | -Release: 20 | 5 | +Release: 21 |
| 6 | Summary: Linux network configuration utilities | 6 | Summary: Linux network configuration utilities |
| 7 | License: GPLv2+ and Public Domain | 7 | License: GPLv2+ and Public Domain |
| 8 | URL: https://kernel.org/pub/linux/utils/net/iproute2/ | 8 | URL: https://kernel.org/pub/linux/utils/net/iproute2/ |
| @@ -70,6 +70,7 @@ patch6052: backport-mnl_utils-sanitize-incoming-netlink-payload-size-in-cal | |||
| 70 | Patch6053: backport-devlink-use-snprintf-instead-of-sprintf.patch | 70 | Patch6053: backport-devlink-use-snprintf-instead-of-sprintf.patch |
| 71 | Patch6054: backport-ctrl-Fix-fd-leak-in-ctrl_list.patch | 71 | Patch6054: backport-ctrl-Fix-fd-leak-in-ctrl_list.patch |
| 72 | Patch6055: backport-ctrl-Fix-fd-leak-in-ctrl_listen.patch | 72 | Patch6055: backport-ctrl-Fix-fd-leak-in-ctrl_listen.patch |
| 73 | +Patch6056: backport-dcb-fix-error-reporting-when-accessing-dcb-app.patch | ||
| 73 | 74 | ||
| 74 | Patch9000: feature-iproute-add-support-for-ipvlan-l2e-mode.patch | 75 | Patch9000: feature-iproute-add-support-for-ipvlan-l2e-mode.patch |
| 75 | Patch9001: bugfix-iproute2-cancel-some-test-cases.patch | 76 | Patch9001: bugfix-iproute2-cancel-some-test-cases.patch |
| @@ -150,6 +151,12 @@ install -m 0644 lib/libnetlink.a %{buildroot}%{_libdir}/libnetlink.a | |||
| 150 | %{_mandir}/* | 151 | %{_mandir}/* |
| 151 | 152 | ||
| 152 | %changelog | 153 | %changelog |
| 154 | +* Thu Oct 10 2024 zhongxuan <zhongxuan2@huawei.com> - 1:5.15.0-21 | ||
| 155 | +- Type:bugfix | ||
| 156 | +- ID:NA | ||
| 157 | +- SUG:NA | ||
| 158 | +- DESC:dcb: Fix error reporting when accessing "dcb app" | ||
| 159 | + | ||
| 153 | * Fri Jul 26 2024 caokeming <caokeming@huawei.com> - 1:5.15.0-20 | 160 | * Fri Jul 26 2024 caokeming <caokeming@huawei.com> - 1:5.15.0-20 |
| 154 | - Type:bugfix | 161 | - Type:bugfix |
| 155 | - ID:NA | 162 | - ID:NA |