All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nikolay Aleksandrov <razor@blackwall.org>
To: netdev@vger.kernel.org
Cc: roopa@nvidia.com, donaldsharp72@gmail.com, dsahern@gmail.com,
	idosch@idosch.org, Nikolay Aleksandrov <nikolay@nvidia.com>
Subject: [RFC iproute2-next 02/11] ip: export print_rta_gateway version which outputs prepared gateway string
Date: Wed, 29 Sep 2021 18:28:39 +0300	[thread overview]
Message-ID: <20210929152848.1710552-3-razor@blackwall.org> (raw)
In-Reply-To: <20210929152848.1710552-1-razor@blackwall.org>

From: Nikolay Aleksandrov <nikolay@nvidia.com>

Export a new __print_rta_gateway that takes a prepared gateway string to
print which is also used by print_rta_gateway for consistent format.

Signed-off-by: Nikolay Aleksandrov <nikolay@nvidia.com>
---
 ip/ip_common.h |  1 +
 ip/iproute.c   | 15 ++++++++++-----
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/ip/ip_common.h b/ip/ip_common.h
index d3d50cbca74d..a02a3b96f7fd 100644
--- a/ip/ip_common.h
+++ b/ip/ip_common.h
@@ -169,6 +169,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_ifidx(FILE *fp, __u32 ifidx, const char *prefix);
+void __print_rta_gateway(FILE *fp, unsigned char family, const char *gateway);
 void print_rta_gateway(FILE *fp, unsigned char family,
 		       const struct rtattr *rta);
 #endif /* _IP_COMMON_H_ */
diff --git a/ip/iproute.c b/ip/iproute.c
index f2bf4737b958..3c933df4dd29 100644
--- a/ip/iproute.c
+++ b/ip/iproute.c
@@ -547,13 +547,11 @@ static void print_rta_newdst(FILE *fp, const struct rtmsg *r,
 	}
 }
 
-void print_rta_gateway(FILE *fp, unsigned char family, const struct rtattr *rta)
+void __print_rta_gateway(FILE *fp, unsigned char family, const char *gateway)
 {
-	const char *gateway = format_host_rta(family, rta);
-
-	if (is_json_context())
+	if (is_json_context()) {
 		print_string(PRINT_JSON, "gateway", NULL, gateway);
-	else {
+	} else {
 		fprintf(fp, "via ");
 		print_color_string(PRINT_FP,
 				   ifa_family_color(family),
@@ -561,6 +559,13 @@ void print_rta_gateway(FILE *fp, unsigned char family, const struct rtattr *rta)
 	}
 }
 
+void print_rta_gateway(FILE *fp, unsigned char family, const struct rtattr *rta)
+{
+	const char *gateway = format_host_rta(family, rta);
+
+	__print_rta_gateway(fp, family, gateway);
+}
+
 static void print_rta_via(FILE *fp, const struct rtattr *rta)
 {
 	size_t len = RTA_PAYLOAD(rta) - 2;
-- 
2.31.1


  parent reply	other threads:[~2021-09-29 15:29 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-29 15:28 [RFC iproute2-next 00/11] ip: nexthop: cache nexthops and print routes' nh info Nikolay Aleksandrov
2021-09-29 15:28 ` [RFC iproute2-next 01/11] ip: print_rta_if takes ifindex as device argument instead of attribute Nikolay Aleksandrov
2021-09-29 15:28 ` Nikolay Aleksandrov [this message]
2021-09-29 15:28 ` [RFC iproute2-next 03/11] ip: nexthop: add nh struct and a helper to parse nhmsg into it Nikolay Aleksandrov
2021-09-30  3:33   ` David Ahern
2021-09-29 15:28 ` [RFC iproute2-next 04/11] ip: nexthop: parse resilient nexthop group attribute into structure Nikolay Aleksandrov
2021-09-30  3:35   ` David Ahern
2021-09-29 15:28 ` [RFC iproute2-next 05/11] ip: nexthop: always parse attributes for printing Nikolay Aleksandrov
2021-09-30  3:37   ` David Ahern
2021-09-30  7:10     ` Nikolay Aleksandrov
2021-09-29 15:28 ` [RFC iproute2-next 06/11] ip: nexthop: pull ipnh_get_id rtnl talk into a helper Nikolay Aleksandrov
2021-09-29 15:28 ` [RFC iproute2-next 07/11] ip: nexthop: add cache helpers Nikolay Aleksandrov
2021-09-30  3:39   ` David Ahern
2021-09-30  6:53     ` Nikolay Aleksandrov
2021-09-29 15:28 ` [RFC iproute2-next 08/11] ip: nexthop: factor out entry printing Nikolay Aleksandrov
2021-09-29 15:28 ` [RFC iproute2-next 09/11] ip: nexthop: add a helper which retrieves and prints cached nh entry Nikolay Aleksandrov
2021-09-29 15:28 ` [RFC iproute2-next 10/11] ip: route: print and cache detailed nexthop information when requested Nikolay Aleksandrov
2021-09-29 15:28 ` [RFC iproute2-next 11/11] ip: nexthop: add print_cache_nexthop which prints and manages the nh cache Nikolay Aleksandrov
2021-09-30  3:42 ` [RFC iproute2-next 00/11] ip: nexthop: cache nexthops and print routes' nh info David Ahern
2021-09-30  7:17   ` Nikolay Aleksandrov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210929152848.1710552-3-razor@blackwall.org \
    --to=razor@blackwall.org \
    --cc=donaldsharp72@gmail.com \
    --cc=dsahern@gmail.com \
    --cc=idosch@idosch.org \
    --cc=netdev@vger.kernel.org \
    --cc=nikolay@nvidia.com \
    --cc=roopa@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.