From 7cc7cb8a888bf50c4e118b6bce4c6926321d0689 Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Tue, 23 Aug 2016 11:52:45 +0200 Subject: [PATCH 1/4] ip-route: Prevent some double spaces in output The code is a bit messy, as it starts with space after text and at some point switches to space before text. But either way, printing space before *and* after text almost certainly leads to printing more whitespace than necessary. Signed-off-by: Phil Sutter --- ip/iproute.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ip/iproute.c b/ip/iproute.c index 3da23af9..4d7da023 100644 --- a/ip/iproute.c +++ b/ip/iproute.c @@ -417,22 +417,22 @@ int print_route(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg) fprintf(fp, "dev %s ", ll_index_to_name(*(int *)RTA_DATA(tb[RTA_OIF]))); if (table && (table != RT_TABLE_MAIN || show_details > 0) && !filter.tb) - fprintf(fp, " table %s ", rtnl_rttable_n2a(table, b1, sizeof(b1))); + fprintf(fp, "table %s ", rtnl_rttable_n2a(table, b1, sizeof(b1))); if (!(r->rtm_flags&RTM_F_CLONED)) { if ((r->rtm_protocol != RTPROT_BOOT || show_details > 0) && filter.protocolmask != -1) - fprintf(fp, " proto %s ", rtnl_rtprot_n2a(r->rtm_protocol, b1, sizeof(b1))); + fprintf(fp, "proto %s ", rtnl_rtprot_n2a(r->rtm_protocol, b1, sizeof(b1))); if ((r->rtm_scope != RT_SCOPE_UNIVERSE || show_details > 0) && filter.scopemask != -1) - fprintf(fp, " scope %s ", rtnl_rtscope_n2a(r->rtm_scope, b1, sizeof(b1))); + fprintf(fp, "scope %s ", rtnl_rtscope_n2a(r->rtm_scope, b1, sizeof(b1))); } if (tb[RTA_PREFSRC] && filter.rprefsrc.bitlen != host_len) { /* Do not use format_host(). It is our local addr and symbolic name will not be useful. */ - fprintf(fp, " src %s ", + fprintf(fp, "src %s ", rt_addr_n2a_rta(r->rtm_family, tb[RTA_PREFSRC])); } if (tb[RTA_PRIORITY]) - fprintf(fp, " metric %u ", rta_getattr_u32(tb[RTA_PRIORITY])); + fprintf(fp, "metric %u ", rta_getattr_u32(tb[RTA_PRIORITY])); if (r->rtm_flags & RTNH_F_DEAD) fprintf(fp, "dead "); if (r->rtm_flags & RTNH_F_ONLINK) @@ -450,9 +450,9 @@ int print_route(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg) if (mark) { if (mark >= 16) - fprintf(fp, " mark 0x%x", mark); + fprintf(fp, "mark 0x%x ", mark); else - fprintf(fp, " mark %u", mark); + fprintf(fp, "mark %u ", mark); } } From cef49e514a184dfd6cfa11192cfb0b723a418be0 Mon Sep 17 00:00:00 2001 From: Roman Mashak Date: Sun, 28 Aug 2016 08:52:40 -0400 Subject: [PATCH 2/4] police: add extra space to improve police result printing Signed-off-by: Roman Mashak Signed-off-by: Jamal Hadi Salim --- tc/m_police.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tc/m_police.c b/tc/m_police.c index f0b179fc..d7fa8f66 100644 --- a/tc/m_police.c +++ b/tc/m_police.c @@ -322,7 +322,7 @@ int print_police(struct action_util *a, FILE *f, struct rtattr *arg) if (tb[TCA_POLICE_RESULT]) { __u32 action = rta_getattr_u32(tb[TCA_POLICE_RESULT]); - fprintf(f, "/%s", action_n2a(action)); + fprintf(f, "/%s ", action_n2a(action)); } else fprintf(f, " "); From 3de88c4b471185866268e0d338ff79a2bd33ec6b Mon Sep 17 00:00:00 2001 From: Roman Mashak Date: Sun, 28 Aug 2016 08:52:41 -0400 Subject: [PATCH 3/4] police: improve usage message Signed-off-by: Roman Mashak Signed-off-by: Jamal Hadi Salim --- tc/m_police.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tc/m_police.c b/tc/m_police.c index d7fa8f66..226e20e4 100644 --- a/tc/m_police.c +++ b/tc/m_police.c @@ -36,11 +36,12 @@ static void usage(void) { fprintf(stderr, "Usage: ... police rate BPS burst BYTES[/BYTES] [ mtu BYTES[/BYTES] ]\n"); fprintf(stderr, " [ peakrate BPS ] [ avrate BPS ] [ overhead BYTES ]\n"); - fprintf(stderr, " [ linklayer TYPE ] [ ACTIONTERM ]\n"); + fprintf(stderr, " [ linklayer TYPE ] [ CONTROL ]\n"); - fprintf(stderr, "New Syntax ACTIONTERM := conform-exceed [/NOTEXCEEDACT]\n"); - fprintf(stderr, "Where: *EXCEEDACT := pipe | ok | reclassify | drop | continue\n"); - fprintf(stderr, "Where: pipe is only valid for new syntax\n"); + fprintf(stderr, "Where: CONTROL := conform-exceed [/NOTEXCEEDACT]\n"); + fprintf(stderr, " Define how to handle packets which exceed ()\n"); + fprintf(stderr, " or conform () the configured bandwidth limit.\n"); + fprintf(stderr, " EXCEEDACT/NOTEXCEEDACT := { pipe | ok | reclassify | drop | continue }\n"); exit(-1); } From 27d2b08e23abc8427ad6b3977247d4670f689fcb Mon Sep 17 00:00:00 2001 From: Roman Mashak Date: Sun, 28 Aug 2016 08:52:42 -0400 Subject: [PATCH 4/4] police: bug fix man page Signed-off-by: Roman Mashak Signed-off-by: Jamal Hadi Salim --- man/man8/tc-police.8 | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/man/man8/tc-police.8 b/man/man8/tc-police.8 index 5c5a6323..620c2881 100644 --- a/man/man8/tc-police.8 +++ b/man/man8/tc-police.8 @@ -26,10 +26,10 @@ police - policing action .ti -8 .IR CONTROL " :=" -.BI conform-exceed " EXCEEDACT\fR[\fB/\fIEXCEEDACT" +.BI conform-exceed " EXCEEDACT\fR[\fB/\fINOTEXCEEDACT" .ti -8 -.IR EXCEEDACT " := { " +.IR EXCEEDACT/NOTEXCEEDACT " := { " .BR pipe " | " ok " | " reclassify " | " drop " | " continue " }" .SH DESCRIPTION The @@ -94,11 +94,9 @@ Fine-tune the in-kernel packet rate estimator. are time values and control the frequency in which samples are taken and over what timespan an average is built. .TP -.BI conform-exceed " EXCEEDACT\fR[\fB/\fIEXCEEDACT\fR]" -Define how to handle packets which exceed (and, if the second -.I EXCEEDACT -is given, also those who don't), the configured bandwidth limit. Possible values -are: +.BI conform-exceed " EXCEEDACT\fR[\fB/\fINOTEXCEEDACT\fR]" +Define how to handle packets which exceed or conform the +configured bandwidth limit. Possible values are: .RS .IP continue Don't do anything, just continue with the next action in line.