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 <nikolay@nvidia.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
This commit is contained in:
Nikolay Aleksandrov 2021-09-30 14:38:33 +03:00 committed by David Ahern
parent c8c9111a4c
commit f72789965e
3 changed files with 8 additions and 8 deletions

View File

@ -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_ */

View File

@ -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 ",

View File

@ -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]));