]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
ip: print_rta_if takes ifindex as device argument instead of attribute
authorNikolay Aleksandrov <nikolay@nvidia.com>
Thu, 30 Sep 2021 11:38:33 +0000 (14:38 +0300)
committerDavid Ahern <dsahern@kernel.org>
Mon, 4 Oct 2021 00:23:31 +0000 (18:23 -0600)
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>
ip/ip_common.h
ip/ipnexthop.c
ip/iproute.c

index ad018183eac0380b59c3df39e3b539f7b0d6e954..d3d50cbca74d13c621e8bd348179a04b50125ac1 100644 (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_ */
index 9478aa5298eb149ad44de35b5ac8b6ac494c0ed1..a4048d803325bf381d1c28f34354b9fa903fb14f 100644 (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 ",
index 1e5e2002d2edf2faa62360121dde4dcfc9699932..f2bf4737b958d2f8178ce9abfd340bf155d1bdf2 100644 (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]));