|
|
4aca6e |
From db77b23a4cf4c140881e68bd1a32fb08508a918e Mon Sep 17 00:00:00 2001
|
|
|
4aca6e |
From: Phil Sutter <psutter@redhat.com>
|
|
|
4aca6e |
Date: Thu, 20 Apr 2017 13:30:19 +0200
|
|
|
4aca6e |
Subject: [PATCH] ip-route: Prevent some other double spaces in output
|
|
|
4aca6e |
|
|
|
4aca6e |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1374446
|
|
|
4aca6e |
Upstream Status: iproute2.git commit 5551ed44d394f
|
|
|
4aca6e |
Conflicts: Adjusted for missing upstream commits:
|
|
|
4aca6e |
* 194e9b855d053 ("ip: support RFC4191 router preference")
|
|
|
4aca6e |
* 528c2551cdb27 ("iproute2: add support to print 'linkdown' nexthop flag")
|
|
|
4aca6e |
* ecc509f9a36be ("ip route: add mpls multipath support")
|
|
|
4aca6e |
* 93ae283594094 ("add support for the RTA_VIA attribute")
|
|
|
4aca6e |
* 56f5daac98da0 ("ip: code cleanup")
|
|
|
4aca6e |
|
|
|
4aca6e |
commit 5551ed44d394fac6e9a035dadb259580fbda84d3
|
|
|
4aca6e |
Author: Timothy Redaelli <tredaelli@redhat.com>
|
|
|
4aca6e |
Date: Wed Apr 5 19:10:26 2017 +0200
|
|
|
4aca6e |
|
|
|
4aca6e |
ip-route: Prevent some other double spaces in output
|
|
|
4aca6e |
|
|
|
4aca6e |
Print spaces only after text.
|
|
|
4aca6e |
|
|
|
4aca6e |
CC: Phil Sutter <phil@nwl.cc>
|
|
|
4aca6e |
Signed-off-by: Timothy Redaelli <tredaelli@redhat.com>
|
|
|
4aca6e |
Acked-by: Phil Sutter <phil@nwl.cc>
|
|
|
4aca6e |
---
|
|
|
4aca6e |
ip/iproute.c | 69 ++++++++++++++++++++++++++++++------------------------------
|
|
|
4aca6e |
1 file changed, 35 insertions(+), 34 deletions(-)
|
|
|
4aca6e |
|
|
|
4aca6e |
diff --git a/ip/iproute.c b/ip/iproute.c
|
|
|
4aca6e |
index 134b146..2b50709 100644
|
|
|
4aca6e |
--- a/ip/iproute.c
|
|
|
4aca6e |
+++ b/ip/iproute.c
|
|
|
4aca6e |
@@ -292,12 +292,12 @@ static void print_rtax_features(FILE *fp, unsigned int features)
|
|
|
4aca6e |
unsigned int of = features;
|
|
|
4aca6e |
|
|
|
4aca6e |
if (features & RTAX_FEATURE_ECN) {
|
|
|
4aca6e |
- fprintf(fp, " ecn");
|
|
|
4aca6e |
+ fprintf(fp, "ecn ");
|
|
|
4aca6e |
features &= ~RTAX_FEATURE_ECN;
|
|
|
4aca6e |
}
|
|
|
4aca6e |
|
|
|
4aca6e |
if (features)
|
|
|
4aca6e |
- fprintf(fp, " 0x%x", of);
|
|
|
4aca6e |
+ fprintf(fp, "0x%x ", of);
|
|
|
4aca6e |
}
|
|
|
4aca6e |
|
|
|
4aca6e |
int print_route(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
|
|
|
4aca6e |
@@ -483,21 +483,21 @@ int print_route(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
|
|
|
4aca6e |
if (!hz)
|
|
|
4aca6e |
hz = get_user_hz();
|
|
|
4aca6e |
if (ci->rta_expires != 0)
|
|
|
4aca6e |
- fprintf(fp, " expires %dsec", ci->rta_expires/hz);
|
|
|
4aca6e |
+ fprintf(fp, "expires %dsec ", ci->rta_expires/hz);
|
|
|
4aca6e |
if (ci->rta_error != 0)
|
|
|
4aca6e |
- fprintf(fp, " error %d", ci->rta_error);
|
|
|
4aca6e |
+ fprintf(fp, "error %d ", ci->rta_error);
|
|
|
4aca6e |
if (show_stats) {
|
|
|
4aca6e |
if (ci->rta_clntref)
|
|
|
4aca6e |
- fprintf(fp, " users %d", ci->rta_clntref);
|
|
|
4aca6e |
+ fprintf(fp, "users %d ", ci->rta_clntref);
|
|
|
4aca6e |
if (ci->rta_used != 0)
|
|
|
4aca6e |
- fprintf(fp, " used %d", ci->rta_used);
|
|
|
4aca6e |
+ fprintf(fp, "used %d ", ci->rta_used);
|
|
|
4aca6e |
if (ci->rta_lastuse != 0)
|
|
|
4aca6e |
- fprintf(fp, " age %dsec", ci->rta_lastuse/hz);
|
|
|
4aca6e |
+ fprintf(fp, "age %dsec ", ci->rta_lastuse/hz);
|
|
|
4aca6e |
}
|
|
|
4aca6e |
if (ci->rta_id)
|
|
|
4aca6e |
- fprintf(fp, " ipid 0x%04x", ci->rta_id);
|
|
|
4aca6e |
+ fprintf(fp, "ipid 0x%04x ", ci->rta_id);
|
|
|
4aca6e |
if (ci->rta_ts || ci->rta_tsage)
|
|
|
4aca6e |
- fprintf(fp, " ts 0x%x tsage %dsec",
|
|
|
4aca6e |
+ fprintf(fp, "ts 0x%x tsage %dsec ",
|
|
|
4aca6e |
ci->rta_ts, ci->rta_tsage);
|
|
|
4aca6e |
}
|
|
|
4aca6e |
} else if (r->rtm_family == AF_INET6) {
|
|
|
4aca6e |
@@ -510,20 +510,20 @@ int print_route(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
|
|
|
4aca6e |
if (r->rtm_flags & RTM_F_CLONED)
|
|
|
4aca6e |
fprintf(fp, "%s cache ", _SL_);
|
|
|
4aca6e |
if (ci->rta_expires)
|
|
|
4aca6e |
- fprintf(fp, " expires %dsec", ci->rta_expires/hz);
|
|
|
4aca6e |
+ fprintf(fp, "expires %dsec ", ci->rta_expires/hz);
|
|
|
4aca6e |
if (ci->rta_error != 0)
|
|
|
4aca6e |
- fprintf(fp, " error %d", ci->rta_error);
|
|
|
4aca6e |
+ fprintf(fp, "error %d ", ci->rta_error);
|
|
|
4aca6e |
if (show_stats) {
|
|
|
4aca6e |
if (ci->rta_clntref)
|
|
|
4aca6e |
- fprintf(fp, " users %d", ci->rta_clntref);
|
|
|
4aca6e |
+ fprintf(fp, "users %d ", ci->rta_clntref);
|
|
|
4aca6e |
if (ci->rta_used != 0)
|
|
|
4aca6e |
- fprintf(fp, " used %d", ci->rta_used);
|
|
|
4aca6e |
+ fprintf(fp, "used %d ", ci->rta_used);
|
|
|
4aca6e |
if (ci->rta_lastuse != 0)
|
|
|
4aca6e |
- fprintf(fp, " age %dsec", ci->rta_lastuse/hz);
|
|
|
4aca6e |
+ fprintf(fp, "age %dsec ", ci->rta_lastuse/hz);
|
|
|
4aca6e |
}
|
|
|
4aca6e |
} else if (ci) {
|
|
|
4aca6e |
if (ci->rta_error != 0)
|
|
|
4aca6e |
- fprintf(fp, " error %d", ci->rta_error);
|
|
|
4aca6e |
+ fprintf(fp, "error %d ", ci->rta_error);
|
|
|
4aca6e |
}
|
|
|
4aca6e |
}
|
|
|
4aca6e |
if (tb[RTA_METRICS]) {
|
|
|
4aca6e |
@@ -549,19 +549,19 @@ int print_route(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
|
|
|
4aca6e |
continue;
|
|
|
4aca6e |
|
|
|
4aca6e |
if (i < sizeof(mx_names)/sizeof(char*) && mx_names[i])
|
|
|
4aca6e |
- fprintf(fp, " %s", mx_names[i]);
|
|
|
4aca6e |
+ fprintf(fp, "%s ", mx_names[i]);
|
|
|
4aca6e |
else
|
|
|
4aca6e |
- fprintf(fp, " metric %d", i);
|
|
|
4aca6e |
+ fprintf(fp, "metric %d ", i);
|
|
|
4aca6e |
|
|
|
4aca6e |
if (mxlock & (1<
|
|
|
4aca6e |
- fprintf(fp, " lock");
|
|
|
4aca6e |
+ fprintf(fp, "lock ");
|
|
|
4aca6e |
|
|
|
4aca6e |
switch (i) {
|
|
|
4aca6e |
case RTAX_FEATURES:
|
|
|
4aca6e |
print_rtax_features(fp, val);
|
|
|
4aca6e |
break;
|
|
|
4aca6e |
default:
|
|
|
4aca6e |
- fprintf(fp, " %u", val);
|
|
|
4aca6e |
+ fprintf(fp, "%u ", val);
|
|
|
4aca6e |
break;
|
|
|
4aca6e |
|
|
|
4aca6e |
case RTAX_RTT:
|
|
|
4aca6e |
@@ -573,18 +573,18 @@ int print_route(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
|
|
|
4aca6e |
val /= 4;
|
|
|
4aca6e |
|
|
|
4aca6e |
if (val >= 1000)
|
|
|
4aca6e |
- fprintf(fp, " %gs", val/1e3);
|
|
|
4aca6e |
+ fprintf(fp, "%gs ", val/1e3);
|
|
|
4aca6e |
else
|
|
|
4aca6e |
- fprintf(fp, " %ums", val);
|
|
|
4aca6e |
+ fprintf(fp, "%ums ", val);
|
|
|
4aca6e |
break;
|
|
|
4aca6e |
case RTAX_CC_ALGO:
|
|
|
4aca6e |
- fprintf(fp, " %s", rta_getattr_str(mxrta[i]));
|
|
|
4aca6e |
+ fprintf(fp, "%s ", rta_getattr_str(mxrta[i]));
|
|
|
4aca6e |
break;
|
|
|
4aca6e |
}
|
|
|
4aca6e |
}
|
|
|
4aca6e |
}
|
|
|
4aca6e |
if (tb[RTA_IIF] && filter.iifmask != -1) {
|
|
|
4aca6e |
- fprintf(fp, " iif %s", ll_index_to_name(*(int*)RTA_DATA(tb[RTA_IIF])));
|
|
|
4aca6e |
+ fprintf(fp, "iif %s ", ll_index_to_name(*(int*)RTA_DATA(tb[RTA_IIF])));
|
|
|
4aca6e |
}
|
|
|
4aca6e |
if (tb[RTA_MULTIPATH]) {
|
|
|
4aca6e |
struct rtnexthop *nh = RTA_DATA(tb[RTA_MULTIPATH]);
|
|
|
4aca6e |
@@ -599,11 +599,11 @@ int print_route(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
|
|
|
4aca6e |
break;
|
|
|
4aca6e |
if (r->rtm_flags&RTM_F_CLONED && r->rtm_type == RTN_MULTICAST) {
|
|
|
4aca6e |
if (first)
|
|
|
4aca6e |
- fprintf(fp, " Oifs:");
|
|
|
4aca6e |
+ fprintf(fp, "Oifs: ");
|
|
|
4aca6e |
else
|
|
|
4aca6e |
fprintf(fp, " ");
|
|
|
4aca6e |
} else
|
|
|
4aca6e |
- fprintf(fp, "%s\tnexthop", _SL_);
|
|
|
4aca6e |
+ fprintf(fp, "%s\tnexthop ", _SL_);
|
|
|
4aca6e |
if (nh->rtnh_len > sizeof(*nh)) {
|
|
|
4aca6e |
parse_rtattr(tb, RTA_MAX, RTNH_DATA(nh), nh->rtnh_len - sizeof(*nh));
|
|
|
4aca6e |
if (tb[RTA_GATEWAY]) {
|
|
|
4aca6e |
@@ -613,7 +613,7 @@ int print_route(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
|
|
|
4aca6e |
if (nh->rtnh_len > sizeof(*nh)) {
|
|
|
4aca6e |
parse_rtattr(tb, RTA_MAX, RTNH_DATA(nh), nh->rtnh_len - sizeof(*nh));
|
|
|
4aca6e |
if (tb[RTA_GATEWAY]) {
|
|
|
4aca6e |
- fprintf(fp, " via %s ",
|
|
|
4aca6e |
+ fprintf(fp, "via %s ",
|
|
|
4aca6e |
format_host(r->rtm_family,
|
|
|
4aca6e |
RTA_PAYLOAD(tb[RTA_GATEWAY]),
|
|
|
4aca6e |
RTA_DATA(tb[RTA_GATEWAY])));
|
|
|
4aca6e |
@@ -622,29 +622,30 @@ int print_route(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
|
|
|
4aca6e |
__u32 to = rta_getattr_u32(tb[RTA_FLOW]);
|
|
|
4aca6e |
__u32 from = to>>16;
|
|
|
4aca6e |
to &= 0xFFFF;
|
|
|
4aca6e |
- fprintf(fp, " realm%s ", from ? "s" : "");
|
|
|
4aca6e |
+ fprintf(fp, "realm%s ", from ? "s" : "");
|
|
|
4aca6e |
if (from) {
|
|
|
4aca6e |
fprintf(fp, "%s/",
|
|
|
4aca6e |
rtnl_rtrealm_n2a(from, b1, sizeof(b1)));
|
|
|
4aca6e |
}
|
|
|
4aca6e |
- fprintf(fp, "%s",
|
|
|
4aca6e |
+ fprintf(fp, "%s ",
|
|
|
4aca6e |
rtnl_rtrealm_n2a(to, b1, sizeof(b1)));
|
|
|
4aca6e |
}
|
|
|
4aca6e |
}
|
|
|
4aca6e |
if (r->rtm_flags&RTM_F_CLONED && r->rtm_type == RTN_MULTICAST) {
|
|
|
4aca6e |
- fprintf(fp, " %s", ll_index_to_name(nh->rtnh_ifindex));
|
|
|
4aca6e |
+ fprintf(fp, "%s", ll_index_to_name(nh->rtnh_ifindex));
|
|
|
4aca6e |
if (nh->rtnh_hops != 1)
|
|
|
4aca6e |
fprintf(fp, "(ttl>%d)", nh->rtnh_hops);
|
|
|
4aca6e |
+ fprintf(fp, " ");
|
|
|
4aca6e |
} else {
|
|
|
4aca6e |
- fprintf(fp, " dev %s", ll_index_to_name(nh->rtnh_ifindex));
|
|
|
4aca6e |
- fprintf(fp, " weight %d", nh->rtnh_hops+1);
|
|
|
4aca6e |
+ fprintf(fp, "dev %s ", ll_index_to_name(nh->rtnh_ifindex));
|
|
|
4aca6e |
+ fprintf(fp, "weight %d ", nh->rtnh_hops+1);
|
|
|
4aca6e |
}
|
|
|
4aca6e |
if (nh->rtnh_flags & RTNH_F_DEAD)
|
|
|
4aca6e |
- fprintf(fp, " dead");
|
|
|
4aca6e |
+ fprintf(fp, "dead ");
|
|
|
4aca6e |
if (nh->rtnh_flags & RTNH_F_ONLINK)
|
|
|
4aca6e |
- fprintf(fp, " onlink");
|
|
|
4aca6e |
+ fprintf(fp, "onlink ");
|
|
|
4aca6e |
if (nh->rtnh_flags & RTNH_F_PERVASIVE)
|
|
|
4aca6e |
- fprintf(fp, " pervasive");
|
|
|
4aca6e |
+ fprintf(fp, "pervasive ");
|
|
|
4aca6e |
len -= NLMSG_ALIGN(nh->rtnh_len);
|
|
|
4aca6e |
nh = RTNH_NEXT(nh);
|
|
|
4aca6e |
}
|
|
|
4aca6e |
--
|
|
|
4aca6e |
1.8.3.1
|
|
|
4aca6e |
|