]> git.proxmox.com Git - mirror_iproute2.git/commitdiff
ip route: Export print_rt_flags, print_rta_if and print_rta_gateway
authorDavid Ahern <dsahern@gmail.com>
Fri, 7 Jun 2019 22:38:12 +0000 (15:38 -0700)
committerDavid Ahern <dsahern@gmail.com>
Tue, 11 Jun 2019 17:30:55 +0000 (10:30 -0700)
Export print_rt_flags and print_rta_if for use by the nexthop
command.

Change print_rta_gateway to take the family versus rtmsg struct and
export for use by the nexthop command.

Signed-off-by: David Ahern <dsahern@gmail.com>
ip/ip_common.h
ip/iproute.c

index df279e4f7b9af1b72ae0f0e0293c44d785f5267a..3e8183e2c48c4c2b68f9f656851ed44902e0c132 100644 (file)
@@ -156,5 +156,8 @@ int name_is_vrf(const char *name);
 #endif
 
 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_gateway(FILE *fp, unsigned char family,
+                      const struct rtattr *rta);
 #endif /* _IP_COMMON_H_ */
index 440b1fc8b413b64a97aa2bd721b2ebaa28933934..1c443265d4795fd6d26c302245b0baa0cb22e0d6 100644 (file)
@@ -349,7 +349,7 @@ static void print_rtax_features(FILE *fp, unsigned int features)
                            "features", "%#llx ", of);
 }
 
-static void print_rt_flags(FILE *fp, unsigned int flags)
+void print_rt_flags(FILE *fp, unsigned int flags)
 {
        open_json_array(PRINT_JSON,
                        is_json_context() ?  "flags" : "");
@@ -394,8 +394,7 @@ static void print_rt_pref(FILE *fp, unsigned int pref)
        }
 }
 
-static void print_rta_if(FILE *fp, const struct rtattr *rta,
-                       const char *prefix)
+void print_rta_if(FILE *fp, const struct rtattr *rta, const char *prefix)
 {
        const char *ifname = ll_index_to_name(rta_getattr_u32(rta));
 
@@ -532,17 +531,16 @@ static void print_rta_newdst(FILE *fp, const struct rtmsg *r,
        }
 }
 
-static void print_rta_gateway(FILE *fp, const struct rtmsg *r,
-                             const struct rtattr *rta)
+void print_rta_gateway(FILE *fp, unsigned char family, const struct rtattr *rta)
 {
-       const char *gateway = format_host_rta(r->rtm_family, rta);
+       const char *gateway = format_host_rta(family, rta);
 
        if (is_json_context())
                print_string(PRINT_JSON, "gateway", NULL, gateway);
        else {
                fprintf(fp, "via ");
                print_color_string(PRINT_FP,
-                                  ifa_family_color(r->rtm_family),
+                                  ifa_family_color(family),
                                   NULL, "%s ", gateway);
        }
 }
@@ -679,7 +677,8 @@ static void print_rta_multipath(FILE *fp, const struct rtmsg *r,
                        if (tb[RTA_NEWDST])
                                print_rta_newdst(fp, r, tb[RTA_NEWDST]);
                        if (tb[RTA_GATEWAY])
-                               print_rta_gateway(fp, r, tb[RTA_GATEWAY]);
+                               print_rta_gateway(fp, r->rtm_family,
+                                                 tb[RTA_GATEWAY]);
                        if (tb[RTA_VIA])
                                print_rta_via(fp, tb[RTA_VIA]);
                        if (tb[RTA_FLOW])
@@ -822,7 +821,7 @@ int print_route(struct nlmsghdr *n, void *arg)
        }
 
        if (tb[RTA_GATEWAY] && filter.rvia.bitlen != host_len)
-               print_rta_gateway(fp, r, tb[RTA_GATEWAY]);
+               print_rta_gateway(fp, r->rtm_family, tb[RTA_GATEWAY]);
 
        if (tb[RTA_VIA])
                print_rta_via(fp, tb[RTA_VIA]);