From 6739068fb08a5b699f4a1136894b26690401f968 Mon Sep 17 00:00:00 2001 From: Luca Boccassi Date: Sun, 28 Feb 2021 12:45:20 +0000 Subject: [PATCH 1/3] iproute: fix printing resolved localhost format_host_rta_r might return a cached hostname via its return value and not use the input buffer. Before: $ ip -resolve -6 route dev lo proto kernel metric 256 pref medium After: $ ip/ip -resolve -6 route localhost dev lo proto kernel metric 256 pref medium Bug-Debian: https://bugs.debian.org/983591 Reported-by: Axel Scheepers Signed-off-by: Luca Boccassi Signed-off-by: Stephen Hemminger --- ip/iproute.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ip/iproute.c b/ip/iproute.c index 291f1a58..5853f026 100644 --- a/ip/iproute.c +++ b/ip/iproute.c @@ -796,9 +796,10 @@ int print_route(struct nlmsghdr *n, void *arg) "%s/%u", rt_addr_n2a_rta(family, tb[RTA_DST]), r->rtm_dst_len); } else { - format_host_rta_r(family, tb[RTA_DST], + const char *hostname = format_host_rta_r(family, tb[RTA_DST], b1, sizeof(b1)); - + if (hostname) + strncpy(b1, hostname, sizeof(b1) - 1); } } else if (r->rtm_dst_len) { snprintf(b1, sizeof(b1), "0/%d ", r->rtm_dst_len); @@ -818,8 +819,10 @@ int print_route(struct nlmsghdr *n, void *arg) rt_addr_n2a_rta(family, tb[RTA_SRC]), r->rtm_src_len); } else { - format_host_rta_r(family, tb[RTA_SRC], + const char *hostname = format_host_rta_r(family, tb[RTA_SRC], b1, sizeof(b1)); + if (hostname) + strncpy(b1, hostname, sizeof(b1) - 1); } print_color_string(PRINT_ANY, color, "from", "from %s ", b1); From 9f366536edb5158343152604e82b968be46dbf26 Mon Sep 17 00:00:00 2001 From: Roi Dayan Date: Mon, 22 Feb 2021 14:10:30 +0200 Subject: [PATCH 2/3] dcb: Fix compilation warning about reallocarray MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In older distros we need bsd/stdlib.h but newer distro doesn't need it. Also old distro will need libbsd-devel installed and newer doesn't. To remove a possible dependency on libbsd-devel replace usage of reallocarray to realloc. dcb_app.c: In function ‘dcb_app_table_push’: dcb_app.c:68:25: warning: implicit declaration of function ‘reallocarray’; did you mean ‘realloc’? Fixes: 8e9bed1493f5 ("dcb: Add a subtool for the DCB APP object") Signed-off-by: Roi Dayan Reviewed-by: Petr Machata Signed-off-by: Stephen Hemminger --- dcb/dcb_app.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/dcb/dcb_app.c b/dcb/dcb_app.c index 7ce80f85..c4816bc2 100644 --- a/dcb/dcb_app.c +++ b/dcb/dcb_app.c @@ -65,8 +65,7 @@ static void dcb_app_table_fini(struct dcb_app_table *tab) static int dcb_app_table_push(struct dcb_app_table *tab, struct dcb_app *app) { - struct dcb_app *apps = reallocarray(tab->apps, tab->n_apps + 1, - sizeof(*tab->apps)); + struct dcb_app *apps = realloc(tab->apps, (tab->n_apps + 1) * sizeof(*tab->apps)); if (apps == NULL) { perror("Cannot allocate APP table"); From 60204c81e47dfdb1ef066c3cb2cfd0f3f19570df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toke=20H=C3=B8iland-J=C3=B8rgensen?= Date: Wed, 3 Mar 2021 13:30:18 +0100 Subject: [PATCH 3/3] q_cake: Fix incorrect printing of signed values in class statistics MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The deficit returned from the kernel is signed, but was printed with a %u specifier in the format string, leading to negative values to be printed as high unsigned values instead. In addition, we passed a negative value to sprint_time() even though that expects an unsigned value. Fix this by changing the format specifier and reversing the sign of negative time values. Fixes: 714444c0cb26 ("Add support for CAKE qdisc") Signed-off-by: Toke Høiland-Jørgensen Signed-off-by: Stephen Hemminger --- tc/q_cake.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tc/q_cake.c b/tc/q_cake.c index b7da731b..4ff6056a 100644 --- a/tc/q_cake.c +++ b/tc/q_cake.c @@ -675,7 +675,7 @@ static int cake_print_xstats(struct qdisc_util *qu, FILE *f, /* class stats */ if (st[TCA_CAKE_STATS_DEFICIT]) - print_int(PRINT_ANY, "deficit", " deficit %u", + print_int(PRINT_ANY, "deficit", " deficit %d", GET_STAT_S32(DEFICIT)); if (st[TCA_CAKE_STATS_COBALT_COUNT]) print_uint(PRINT_ANY, "count", " count %u", @@ -688,7 +688,7 @@ static int cake_print_xstats(struct qdisc_util *qu, FILE *f, if (drop_next < 0) { print_string(PRINT_FP, NULL, " drop_next -%s", - sprint_time(drop_next, b1)); + sprint_time(-drop_next, b1)); } else { print_uint(PRINT_JSON, "drop_next", NULL, drop_next);