tc: do not output newline in oneline mode
In oneline mode the line seperator should be \ but several parts of tc aren't doing it right. Signed-off-by: Stephen Hemminger <stephen@networkplumber.org> Signed-off-by: David Ahern <dsahern@gmail.com>
This commit is contained in:
parent
f39da545b6
commit
7b0d424abe
|
|
@ -1624,7 +1624,8 @@ static void flower_print_eth_type(__be16 *p_eth_type,
|
|||
else
|
||||
sprintf(out, "%04x", ntohs(eth_type));
|
||||
|
||||
print_string(PRINT_ANY, "eth_type", "\n eth_type %s", out);
|
||||
print_nl();
|
||||
print_string(PRINT_ANY, "eth_type", " eth_type %s", out);
|
||||
*p_eth_type = eth_type;
|
||||
}
|
||||
|
||||
|
|
@ -1651,7 +1652,8 @@ static void flower_print_ip_proto(__u8 *p_ip_proto,
|
|||
else
|
||||
sprintf(out, "%02x", ip_proto);
|
||||
|
||||
print_string(PRINT_ANY, "ip_proto", "\n ip_proto %s", out);
|
||||
print_nl();
|
||||
print_string(PRINT_ANY, "ip_proto", " ip_proto %s", out);
|
||||
*p_ip_proto = ip_proto;
|
||||
}
|
||||
|
||||
|
|
@ -1682,7 +1684,8 @@ static void flower_print_matching_flags(char *name,
|
|||
continue;
|
||||
if (mtf_mask & flags_str[i].flag) {
|
||||
if (++count == 1) {
|
||||
print_string(PRINT_FP, NULL, "\n %s ", name);
|
||||
print_nl();
|
||||
print_string(PRINT_FP, NULL, " %s ", name);
|
||||
open_json_object(name);
|
||||
} else {
|
||||
print_string(PRINT_FP, NULL, "/", NULL);
|
||||
|
|
@ -1829,7 +1832,8 @@ static void flower_print_ct_state(struct rtattr *flags_attr,
|
|||
flower_ct_states[i].str);
|
||||
}
|
||||
|
||||
print_string(PRINT_ANY, "ct_state", "\n ct_state %s", out);
|
||||
print_nl();
|
||||
print_string(PRINT_ANY, "ct_state", " ct_state %s", out);
|
||||
}
|
||||
|
||||
static void flower_print_ct_label(struct rtattr *attr,
|
||||
|
|
@ -1864,7 +1868,8 @@ static void flower_print_ct_label(struct rtattr *attr,
|
|||
}
|
||||
*p = '\0';
|
||||
|
||||
print_string(PRINT_ANY, "ct_label", "\n ct_label %s", out);
|
||||
print_nl();
|
||||
print_string(PRINT_ANY, "ct_label", " ct_label %s", out);
|
||||
}
|
||||
|
||||
static void flower_print_ct_zone(struct rtattr *attr,
|
||||
|
|
@ -1886,7 +1891,8 @@ static void flower_print_key_id(const char *name, struct rtattr *attr)
|
|||
if (!attr)
|
||||
return;
|
||||
|
||||
sprintf(namefrm,"\n %s %%u", name);
|
||||
print_nl();
|
||||
sprintf(namefrm, " %s %%u", name);
|
||||
print_uint(PRINT_ANY, name, namefrm, rta_getattr_be32(attr));
|
||||
}
|
||||
|
||||
|
|
@ -1934,7 +1940,7 @@ static void flower_print_geneve_opts(const char *name, struct rtattr *attr,
|
|||
static void flower_print_geneve_parts(const char *name, struct rtattr *attr,
|
||||
char *key, char *mask)
|
||||
{
|
||||
char *namefrm = "\n geneve_opt %s";
|
||||
char *namefrm = " geneve_opt %s";
|
||||
char *key_token, *mask_token, *out;
|
||||
int len;
|
||||
|
||||
|
|
@ -1952,6 +1958,7 @@ static void flower_print_geneve_parts(const char *name, struct rtattr *attr,
|
|||
}
|
||||
|
||||
out[len - 1] = '\0';
|
||||
print_nl();
|
||||
print_string(PRINT_FP, name, namefrm, out);
|
||||
free(out);
|
||||
}
|
||||
|
|
@ -2015,7 +2022,8 @@ static void flower_print_masked_u8(const char *name, struct rtattr *attr,
|
|||
if (mask != UINT8_MAX)
|
||||
sprintf(out + done, "/%d", mask);
|
||||
|
||||
sprintf(namefrm,"\n %s %%s", name);
|
||||
print_nl();
|
||||
sprintf(namefrm, " %s %%s", name);
|
||||
print_string(PRINT_ANY, name, namefrm, out);
|
||||
}
|
||||
|
||||
|
|
@ -2031,7 +2039,8 @@ static void flower_print_u32(const char *name, struct rtattr *attr)
|
|||
if (!attr)
|
||||
return;
|
||||
|
||||
sprintf(namefrm,"\n %s %%u", name);
|
||||
print_nl();
|
||||
sprintf(namefrm, " %s %%u", name);
|
||||
print_uint(PRINT_ANY, name, namefrm, rta_getattr_u32(attr));
|
||||
}
|
||||
|
||||
|
|
@ -2086,14 +2095,16 @@ static int flower_print_opt(struct filter_util *qu, FILE *f,
|
|||
if (tb[TCA_FLOWER_KEY_VLAN_ID]) {
|
||||
struct rtattr *attr = tb[TCA_FLOWER_KEY_VLAN_ID];
|
||||
|
||||
print_uint(PRINT_ANY, "vlan_id", "\n vlan_id %u",
|
||||
print_nl();
|
||||
print_uint(PRINT_ANY, "vlan_id", " vlan_id %u",
|
||||
rta_getattr_u16(attr));
|
||||
}
|
||||
|
||||
if (tb[TCA_FLOWER_KEY_VLAN_PRIO]) {
|
||||
struct rtattr *attr = tb[TCA_FLOWER_KEY_VLAN_PRIO];
|
||||
|
||||
print_uint(PRINT_ANY, "vlan_prio", "\n vlan_prio %d",
|
||||
print_nl();
|
||||
print_uint(PRINT_ANY, "vlan_prio", " vlan_prio %d",
|
||||
rta_getattr_u8(attr));
|
||||
}
|
||||
|
||||
|
|
@ -2101,7 +2112,8 @@ static int flower_print_opt(struct filter_util *qu, FILE *f,
|
|||
SPRINT_BUF(buf);
|
||||
struct rtattr *attr = tb[TCA_FLOWER_KEY_VLAN_ETH_TYPE];
|
||||
|
||||
print_string(PRINT_ANY, "vlan_ethtype", "\n vlan_ethtype %s",
|
||||
print_nl();
|
||||
print_string(PRINT_ANY, "vlan_ethtype", " vlan_ethtype %s",
|
||||
ll_proto_n2a(rta_getattr_u16(attr),
|
||||
buf, sizeof(buf)));
|
||||
}
|
||||
|
|
@ -2109,14 +2121,16 @@ static int flower_print_opt(struct filter_util *qu, FILE *f,
|
|||
if (tb[TCA_FLOWER_KEY_CVLAN_ID]) {
|
||||
struct rtattr *attr = tb[TCA_FLOWER_KEY_CVLAN_ID];
|
||||
|
||||
print_uint(PRINT_ANY, "cvlan_id", "\n cvlan_id %u",
|
||||
print_nl();
|
||||
print_uint(PRINT_ANY, "cvlan_id", " cvlan_id %u",
|
||||
rta_getattr_u16(attr));
|
||||
}
|
||||
|
||||
if (tb[TCA_FLOWER_KEY_CVLAN_PRIO]) {
|
||||
struct rtattr *attr = tb[TCA_FLOWER_KEY_CVLAN_PRIO];
|
||||
|
||||
print_uint(PRINT_ANY, "cvlan_prio", "\n cvlan_prio %d",
|
||||
print_nl();
|
||||
print_uint(PRINT_ANY, "cvlan_prio", " cvlan_prio %d",
|
||||
rta_getattr_u8(attr));
|
||||
}
|
||||
|
||||
|
|
@ -2124,7 +2138,8 @@ static int flower_print_opt(struct filter_util *qu, FILE *f,
|
|||
SPRINT_BUF(buf);
|
||||
struct rtattr *attr = tb[TCA_FLOWER_KEY_CVLAN_ETH_TYPE];
|
||||
|
||||
print_string(PRINT_ANY, "cvlan_ethtype", "\n cvlan_ethtype %s",
|
||||
print_nl();
|
||||
print_string(PRINT_ANY, "cvlan_ethtype", " cvlan_ethtype %s",
|
||||
ll_proto_n2a(rta_getattr_u16(attr),
|
||||
buf, sizeof(buf)));
|
||||
}
|
||||
|
|
@ -2254,13 +2269,18 @@ static int flower_print_opt(struct filter_util *qu, FILE *f,
|
|||
if (tb[TCA_FLOWER_FLAGS]) {
|
||||
__u32 flags = rta_getattr_u32(tb[TCA_FLOWER_FLAGS]);
|
||||
|
||||
if (flags & TCA_CLS_FLAGS_SKIP_HW)
|
||||
print_bool(PRINT_ANY, "skip_hw", "\n skip_hw", true);
|
||||
if (flags & TCA_CLS_FLAGS_SKIP_SW)
|
||||
print_bool(PRINT_ANY, "skip_sw", "\n skip_sw", true);
|
||||
if (flags & TCA_CLS_FLAGS_SKIP_HW) {
|
||||
print_nl();
|
||||
print_bool(PRINT_ANY, "skip_hw", " skip_hw", true);
|
||||
}
|
||||
if (flags & TCA_CLS_FLAGS_SKIP_SW) {
|
||||
print_nl();
|
||||
print_bool(PRINT_ANY, "skip_sw", " skip_sw", true);
|
||||
}
|
||||
|
||||
if (flags & TCA_CLS_FLAGS_IN_HW) {
|
||||
print_bool(PRINT_ANY, "in_hw", "\n in_hw", true);
|
||||
print_nl();
|
||||
print_bool(PRINT_ANY, "in_hw", " in_hw", true);
|
||||
|
||||
if (tb[TCA_FLOWER_IN_HW_COUNT]) {
|
||||
__u32 count = rta_getattr_u32(tb[TCA_FLOWER_IN_HW_COUNT]);
|
||||
|
|
@ -2269,8 +2289,10 @@ static int flower_print_opt(struct filter_util *qu, FILE *f,
|
|||
" in_hw_count %u", count);
|
||||
}
|
||||
}
|
||||
else if (flags & TCA_CLS_FLAGS_NOT_IN_HW)
|
||||
print_bool(PRINT_ANY, "not_in_hw", "\n not_in_hw", true);
|
||||
else if (flags & TCA_CLS_FLAGS_NOT_IN_HW) {
|
||||
print_nl();
|
||||
print_bool(PRINT_ANY, "not_in_hw", " not_in_hw", true);
|
||||
}
|
||||
}
|
||||
|
||||
if (tb[TCA_FLOWER_ACT])
|
||||
|
|
|
|||
|
|
@ -205,7 +205,7 @@ print_csum(struct action_util *au, FILE *f, struct rtattr *arg)
|
|||
uflag_4, uflag_5, uflag_6, uflag_7);
|
||||
print_string(PRINT_ANY, "csum", "(%s) ", buf);
|
||||
|
||||
print_action_control(f, "action ", sel->action, "\n");
|
||||
print_action_control(f, "action ", sel->action, _SL_);
|
||||
print_uint(PRINT_ANY, "index", "\tindex %u", sel->index);
|
||||
print_int(PRINT_ANY, "ref", " ref %d", sel->refcnt);
|
||||
print_int(PRINT_ANY, "bind", " bind %d", sel->bindcnt);
|
||||
|
|
@ -217,7 +217,7 @@ print_csum(struct action_util *au, FILE *f, struct rtattr *arg)
|
|||
print_tm(f, tm);
|
||||
}
|
||||
}
|
||||
print_string(PRINT_FP, NULL, "%s", "\n");
|
||||
print_nl();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -473,7 +473,8 @@ static int print_ct(struct action_util *au, FILE *f, struct rtattr *arg)
|
|||
|
||||
print_action_control(f, " ", p->action, "");
|
||||
|
||||
print_uint(PRINT_ANY, "index", "\n\t index %u", p->index);
|
||||
print_nl();
|
||||
print_uint(PRINT_ANY, "index", "\t index %u", p->index);
|
||||
print_int(PRINT_ANY, "ref", " ref %d", p->refcnt);
|
||||
print_int(PRINT_ANY, "bind", " bind %d", p->bindcnt);
|
||||
|
||||
|
|
@ -484,7 +485,7 @@ static int print_ct(struct action_util *au, FILE *f, struct rtattr *arg)
|
|||
print_tm(f, tm);
|
||||
}
|
||||
}
|
||||
print_string(PRINT_FP, NULL, "%s", "\n ");
|
||||
print_nl();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -193,13 +193,15 @@ print_gact(struct action_util *au, FILE *f, struct rtattr *arg)
|
|||
pp = &pp_dummy;
|
||||
}
|
||||
open_json_object("prob");
|
||||
print_string(PRINT_ANY, "random_type", "\n\t random type %s",
|
||||
print_nl();
|
||||
print_string(PRINT_ANY, "random_type", "\t random type %s",
|
||||
prob_n2a(pp->ptype));
|
||||
print_action_control(f, " ", pp->paction, " ");
|
||||
print_int(PRINT_ANY, "val", "val %d", pp->pval);
|
||||
close_json_object();
|
||||
#endif
|
||||
print_uint(PRINT_ANY, "index", "\n\t index %u", p->index);
|
||||
print_nl();
|
||||
print_uint(PRINT_ANY, "index", "\t index %u", p->index);
|
||||
print_int(PRINT_ANY, "ref", " ref %d", p->refcnt);
|
||||
print_int(PRINT_ANY, "bind", " bind %d", p->bindcnt);
|
||||
if (show_stats) {
|
||||
|
|
@ -209,7 +211,7 @@ print_gact(struct action_util *au, FILE *f, struct rtattr *arg)
|
|||
print_tm(f, tm);
|
||||
}
|
||||
}
|
||||
print_string(PRINT_FP, NULL, "%s", "\n");
|
||||
print_nl();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -307,7 +307,8 @@ print_mirred(struct action_util *au, FILE *f, struct rtattr *arg)
|
|||
print_string(PRINT_ANY, "to_dev", " to device %s)", dev);
|
||||
print_action_control(f, " ", p->action, "");
|
||||
|
||||
print_uint(PRINT_ANY, "index", "\n \tindex %u", p->index);
|
||||
print_nl();
|
||||
print_uint(PRINT_ANY, "index", "\tindex %u", p->index);
|
||||
print_int(PRINT_ANY, "ref", " ref %d", p->refcnt);
|
||||
print_int(PRINT_ANY, "bind", " bind %d", p->bindcnt);
|
||||
|
||||
|
|
@ -318,7 +319,7 @@ print_mirred(struct action_util *au, FILE *f, struct rtattr *arg)
|
|||
print_tm(f, tm);
|
||||
}
|
||||
}
|
||||
print_string(PRINT_FP, NULL, "%s", "\n ");
|
||||
print_nl();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -252,7 +252,8 @@ static int print_mpls(struct action_util *au, FILE *f, struct rtattr *arg)
|
|||
}
|
||||
print_action_control(f, " ", parm->action, "");
|
||||
|
||||
print_uint(PRINT_ANY, "index", "\n\t index %u", parm->index);
|
||||
print_nl();
|
||||
print_uint(PRINT_ANY, "index", "\t index %u", parm->index);
|
||||
print_int(PRINT_ANY, "ref", " ref %d", parm->refcnt);
|
||||
print_int(PRINT_ANY, "bind", " bind %d", parm->bindcnt);
|
||||
|
||||
|
|
|
|||
|
|
@ -820,7 +820,7 @@ static int print_pedit(struct action_util *au, FILE *f, struct rtattr *arg)
|
|||
sel->nkeys);
|
||||
}
|
||||
|
||||
fprintf(f, "\n ");
|
||||
print_nl();
|
||||
|
||||
free(keys_ex);
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -194,7 +194,7 @@ static int print_simple(struct action_util *au, FILE *f, struct rtattr *arg)
|
|||
print_tm(f, tm);
|
||||
}
|
||||
}
|
||||
fprintf(f, "\n");
|
||||
print_nl();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -420,7 +420,8 @@ static void tunnel_key_print_geneve_options(const char *name,
|
|||
uint8_t type;
|
||||
|
||||
open_json_array(PRINT_JSON, name);
|
||||
print_string(PRINT_FP, name, "\n\t%s ", "geneve_opt");
|
||||
print_nl();
|
||||
print_string(PRINT_FP, name, "\t%s ", "geneve_opt");
|
||||
|
||||
while (rem) {
|
||||
parse_rtattr(tb, TCA_TUNNEL_KEY_ENC_OPT_GENEVE_MAX, i, rem);
|
||||
|
|
|
|||
|
|
@ -219,7 +219,8 @@ static int print_vlan(struct action_util *au, FILE *f, struct rtattr *arg)
|
|||
}
|
||||
print_action_control(f, " ", parm->action, "");
|
||||
|
||||
print_uint(PRINT_ANY, "index", "\n\t index %u", parm->index);
|
||||
print_nl();
|
||||
print_uint(PRINT_ANY, "index", "\t index %u", parm->index);
|
||||
print_int(PRINT_ANY, "ref", " ref %d", parm->refcnt);
|
||||
print_int(PRINT_ANY, "bind", " bind %d", parm->bindcnt);
|
||||
|
||||
|
|
@ -231,7 +232,7 @@ static int print_vlan(struct action_util *au, FILE *f, struct rtattr *arg)
|
|||
}
|
||||
}
|
||||
|
||||
print_string(PRINT_FP, NULL, "%s", "\n");
|
||||
print_nl();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -391,7 +391,7 @@ print_ipt(struct action_util *au, FILE *f, struct rtattr *arg)
|
|||
print_tm(f, tm);
|
||||
}
|
||||
}
|
||||
fprintf(f, "\n");
|
||||
print_nl();
|
||||
|
||||
xtables_free_opts(1);
|
||||
|
||||
|
|
|
|||
|
|
@ -766,7 +766,7 @@ static int cake_print_xstats(struct qdisc_util *qu, FILE *f,
|
|||
fprintf(f, " ");
|
||||
for (i = 0; i < num_tins; i++)
|
||||
fprintf(f, " Tin %u", i);
|
||||
fprintf(f, "\n");
|
||||
fprintf(f, "%s", _SL_);
|
||||
};
|
||||
|
||||
#define GET_TSTAT(i, attr) (tstat[i][TCA_CAKE_TIN_STATS_ ## attr])
|
||||
|
|
@ -775,7 +775,7 @@ static int cake_print_xstats(struct qdisc_util *qu, FILE *f,
|
|||
fprintf(f, name); \
|
||||
for (i = 0; i < num_tins; i++) \
|
||||
fprintf(f, " %12" fmts, val); \
|
||||
fprintf(f, "\n"); \
|
||||
fprintf(f, "%s", _SL_); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
|
|
|||
|
|
@ -257,7 +257,8 @@ static int fq_codel_print_xstats(struct qdisc_util *qu, FILE *f,
|
|||
if (st->qdisc_stats.drop_overmemory)
|
||||
print_uint(PRINT_ANY, "drop_overmemory", " drop_overmemory %u",
|
||||
st->qdisc_stats.drop_overmemory);
|
||||
print_uint(PRINT_ANY, "new_flows_len", "\n new_flows_len %u",
|
||||
print_nl();
|
||||
print_uint(PRINT_ANY, "new_flows_len", " new_flows_len %u",
|
||||
st->qdisc_stats.new_flows_len);
|
||||
print_uint(PRINT_ANY, "old_flows_len", " old_flows_len %u",
|
||||
st->qdisc_stats.old_flows_len);
|
||||
|
|
|
|||
|
|
@ -364,11 +364,11 @@ int print_filter(struct nlmsghdr *n, void *arg)
|
|||
close_json_object();
|
||||
}
|
||||
}
|
||||
print_string(PRINT_FP, NULL, "\n", NULL);
|
||||
print_nl();
|
||||
|
||||
if (show_stats && (tb[TCA_STATS] || tb[TCA_STATS2])) {
|
||||
print_tcstats_attr(fp, tb, " ", NULL);
|
||||
print_string(PRINT_FP, NULL, "\n", NULL);
|
||||
print_nl();
|
||||
}
|
||||
|
||||
close_json_object();
|
||||
|
|
|
|||
|
|
@ -317,11 +317,11 @@ int print_qdisc(struct nlmsghdr *n, void *arg)
|
|||
}
|
||||
close_json_object();
|
||||
|
||||
print_string(PRINT_FP, NULL, "\n", NULL);
|
||||
print_nl();
|
||||
|
||||
if (show_details && tb[TCA_STAB]) {
|
||||
print_size_table(fp, " ", tb[TCA_STAB]);
|
||||
print_string(PRINT_FP, NULL, "\n", NULL);
|
||||
print_nl();
|
||||
}
|
||||
|
||||
if (show_stats) {
|
||||
|
|
@ -329,12 +329,12 @@ int print_qdisc(struct nlmsghdr *n, void *arg)
|
|||
|
||||
if (tb[TCA_STATS] || tb[TCA_STATS2] || tb[TCA_XSTATS]) {
|
||||
print_tcstats_attr(fp, tb, " ", &xstats);
|
||||
print_string(PRINT_FP, NULL, "\n", NULL);
|
||||
print_nl();
|
||||
}
|
||||
|
||||
if (q && xstats && q->print_xstats) {
|
||||
q->print_xstats(q, fp, xstats);
|
||||
print_string(PRINT_FP, NULL, "\n", NULL);
|
||||
print_nl();
|
||||
}
|
||||
}
|
||||
close_json_object();
|
||||
|
|
|
|||
|
|
@ -869,7 +869,7 @@ void print_tcstats2_attr(FILE *fp, struct rtattr *rta, char *prefix, struct rtat
|
|||
memcpy(&q, RTA_DATA(tbs[TCA_STATS_QUEUE]),
|
||||
MIN(RTA_PAYLOAD(tbs[TCA_STATS_QUEUE]), sizeof(q)));
|
||||
if (!tbs[TCA_STATS_RATE_EST])
|
||||
print_string(PRINT_FP, NULL, "\n", "");
|
||||
print_nl();
|
||||
print_uint(PRINT_JSON, "backlog", NULL, q.backlog);
|
||||
print_string(PRINT_FP, NULL, "%s", prefix);
|
||||
print_string(PRINT_FP, NULL, "backlog %s",
|
||||
|
|
|
|||
Loading…
Reference in New Issue