From: Nikolay Aleksandrov Date: Thu, 30 Sep 2021 11:38:33 +0000 (+0300) Subject: ip: print_rta_if takes ifindex as device argument instead of attribute X-Git-Tag: v5.16.0~33^2~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f72789965effde12c29e50946281b3ebbaadbc51;p=thirdparty%2Fiproute2.git ip: print_rta_if takes ifindex as device argument instead of attribute We need print_rta_if() to take ifindex directly so later we can use it with cached converted nexthop objects. Signed-off-by: Nikolay Aleksandrov Signed-off-by: David Ahern --- diff --git a/ip/ip_common.h b/ip/ip_common.h index ad018183e..d3d50cbca 100644 --- a/ip/ip_common.h +++ b/ip/ip_common.h @@ -168,7 +168,7 @@ int name_is_vrf(const char *name); void print_num(FILE *fp, unsigned int width, uint64_t count); void print_rt_flags(FILE *fp, unsigned int flags); -void print_rta_if(FILE *fp, const struct rtattr *rta, const char *prefix); +void print_rta_ifidx(FILE *fp, __u32 ifidx, const char *prefix); void print_rta_gateway(FILE *fp, unsigned char family, const struct rtattr *rta); #endif /* _IP_COMMON_H_ */ diff --git a/ip/ipnexthop.c b/ip/ipnexthop.c index 9478aa529..a4048d803 100644 --- a/ip/ipnexthop.c +++ b/ip/ipnexthop.c @@ -381,7 +381,7 @@ int print_nexthop(struct nlmsghdr *n, void *arg) print_rta_gateway(fp, nhm->nh_family, tb[NHA_GATEWAY]); if (tb[NHA_OIF]) - print_rta_if(fp, tb[NHA_OIF], "dev"); + print_rta_ifidx(fp, rta_getattr_u32(tb[NHA_OIF]), "dev"); if (nhm->nh_scope != RT_SCOPE_UNIVERSE || show_details > 0) { print_string(PRINT_ANY, "scope", "scope %s ", diff --git a/ip/iproute.c b/ip/iproute.c index 1e5e2002d..f2bf4737b 100644 --- a/ip/iproute.c +++ b/ip/iproute.c @@ -410,13 +410,13 @@ static void print_rt_pref(FILE *fp, unsigned int pref) } } -void print_rta_if(FILE *fp, const struct rtattr *rta, const char *prefix) +void print_rta_ifidx(FILE *fp, __u32 ifidx, const char *prefix) { - const char *ifname = ll_index_to_name(rta_getattr_u32(rta)); + const char *ifname = ll_index_to_name(ifidx); - if (is_json_context()) + if (is_json_context()) { print_string(PRINT_JSON, prefix, NULL, ifname); - else { + } else { fprintf(fp, "%s ", prefix); color_fprintf(fp, COLOR_IFNAME, "%s ", ifname); } @@ -862,7 +862,7 @@ int print_route(struct nlmsghdr *n, void *arg) print_rta_via(fp, tb[RTA_VIA]); if (tb[RTA_OIF] && filter.oifmask != -1) - print_rta_if(fp, tb[RTA_OIF], "dev"); + print_rta_ifidx(fp, rta_getattr_u32(tb[RTA_OIF]), "dev"); if (table && (table != RT_TABLE_MAIN || show_details > 0) && !filter.tb) print_string(PRINT_ANY, @@ -946,7 +946,7 @@ int print_route(struct nlmsghdr *n, void *arg) print_rta_metrics(fp, tb[RTA_METRICS]); if (tb[RTA_IIF] && filter.iifmask != -1) - print_rta_if(fp, tb[RTA_IIF], "iif"); + print_rta_ifidx(fp, rta_getattr_u32(tb[RTA_IIF]), "iif"); if (tb[RTA_PREF]) print_rt_pref(fp, rta_getattr_u8(tb[RTA_PREF]));