From: David Ahern <dsahern@gmail.com>
To: John Hurley <john.hurley@netronome.com>, netdev@vger.kernel.org
Cc: davem@davemloft.net, jiri@mellanox.com, xiyou.wangcong@gmail.com,
willemdebruijn.kernel@gmail.com, simon.horman@netronome.com,
jakub.kicinski@netronome.com, oss-drivers@netronome.com
Subject: Re: [PATCH iproute2-next 2/3] tc: add mpls actions
Date: Tue, 9 Jul 2019 14:39:43 -0600 [thread overview]
Message-ID: <d0b46840-9c9b-652d-c70b-d9dee538fd2a@gmail.com> (raw)
In-Reply-To: <1562687972-23549-3-git-send-email-john.hurley@netronome.com>
On 7/9/19 9:59 AM, John Hurley wrote:
> +static void explain(void)
> +{
> + fprintf(stderr,
> + "Usage: mpls pop [ protocol MPLS_PROTO ]\n"
> + " mpls push [ protocol MPLS_PROTO ] [ label MPLS_LABEL ] [ tc MPLS_TC ] [ ttl MPLS_TTL ] [ bos MPLS_BOS ] [CONTROL]\n"
that makes for a very long line to the user. Break at the ttl option and
make a newline:
mpls push [ protocol MPLS_PROTO ] [ label MPLS_LABEL ] [ tc MPLS_TC ]
[ ttl MPLS_TTL ] [ bos MPLS_BOS ] [CONTROL]
> + " mpls modify [ label MPLS_LABEL ] [ tc MPLS_TC ] [ ttl MPLS_TTL ] [CONTROL]\n"
> + " for pop MPLS_PROTO is next header of packet - e.g. ip or mpls_uc\n"
> + " for push MPLS_PROTO is one of mpls_uc or mpls_mc\n"
> + " with default: mpls_uc\n"
> + " CONTROL := reclassify | pipe | drop | continue | pass |\n"
> + " goto chain <CHAIN_INDEX>\n");
> +}
> +
...
> +static int print_mpls(struct action_util *au, FILE *f, struct rtattr *arg)
> +{
> + struct rtattr *tb[TCA_MPLS_MAX + 1];
> + struct tc_mpls *parm;
> + SPRINT_BUF(b1);
> + __u32 val;
> +
> + if (!arg)
> + return -1;
> +
> + parse_rtattr_nested(tb, TCA_MPLS_MAX, arg);
> +
> + if (!tb[TCA_MPLS_PARMS]) {
> + print_string(PRINT_FP, NULL, "%s", "[NULL mpls parameters]");
> + return -1;
> + }
> + parm = RTA_DATA(tb[TCA_MPLS_PARMS]);
> +
> + print_string(PRINT_ANY, "kind", "%s ", "mpls");
> + print_string(PRINT_ANY, "mpls_action", " %s",
> + action_names[parm->m_action]);
> +
> + switch (parm->m_action) {
> + case TCA_MPLS_ACT_POP:
> + if (tb[TCA_MPLS_PROTO]) {
> + __u16 proto;
> +
> + proto = rta_getattr_u16(tb[TCA_MPLS_PROTO]);
> + print_string(PRINT_ANY, "protocol", " protocol %s",
> + ll_proto_n2a(proto, b1, sizeof(b1)));
> + }
> + break;
> + case TCA_MPLS_ACT_PUSH:
> + if (tb[TCA_MPLS_PROTO]) {
> + __u16 proto;
> +
> + proto = rta_getattr_u16(tb[TCA_MPLS_PROTO]);
> + print_string(PRINT_ANY, "protocol", " protocol %s",
> + ll_proto_n2a(proto, b1, sizeof(b1)));
> + }
> + /* Fallthrough */
> + case TCA_MPLS_ACT_MODIFY:
> + if (tb[TCA_MPLS_LABEL]) {
> + val = rta_getattr_u32(tb[TCA_MPLS_LABEL]);
> + print_uint(PRINT_ANY, "label", " label %u", val);
> + }
> + if (tb[TCA_MPLS_TC]) {
> + val = rta_getattr_u8(tb[TCA_MPLS_TC]);
> + print_uint(PRINT_ANY, "tc", " tc %u", val);
> + }
> + if (tb[TCA_MPLS_BOS]) {
> + val = rta_getattr_u8(tb[TCA_MPLS_BOS]);
> + print_uint(PRINT_ANY, "bos", " bos %u", val);
> + }
> + if (tb[TCA_MPLS_TTL]) {
> + val = rta_getattr_u8(tb[TCA_MPLS_TTL]);
> + print_uint(PRINT_ANY, "ttl", " ttl %u", val);
> + }
> + break;
> + }
> + print_action_control(f, " ", parm->action, "");
> +
> + print_uint(PRINT_ANY, "index", "\n\t index %u", parm->index);
> + print_int(PRINT_ANY, "ref", " ref %d", parm->refcnt);
> + print_int(PRINT_ANY, "bind", " bind %d", parm->bindcnt);
> +
> + if (show_stats) {
> + if (tb[TCA_MPLS_TM]) {
> + struct tcf_t *tm = RTA_DATA(tb[TCA_MPLS_TM]);
> +
> + print_tm(f, tm);
> + }
> + }
> +
> + print_string(PRINT_FP, NULL, "%s", "\n");
s/"\n"/_SL_/ ?
next prev parent reply other threads:[~2019-07-09 20:39 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-09 15:59 [PATCH iproute2-next 0/3] add interface to TC MPLS actions John Hurley
2019-07-09 15:59 ` [PATCH iproute2-next 1/3] lib: add mpls_uc and mpls_mc as link layer protocol names John Hurley
2019-07-09 15:59 ` [PATCH iproute2-next 2/3] tc: add mpls actions John Hurley
2019-07-09 17:00 ` Stephen Hemminger
2019-07-09 20:36 ` David Ahern
2019-07-09 21:05 ` Stephen Hemminger
2019-07-09 20:39 ` David Ahern [this message]
2019-07-09 15:59 ` [PATCH iproute2-next 3/3] man: update man pages for TC MPLS actions John Hurley
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=d0b46840-9c9b-652d-c70b-d9dee538fd2a@gmail.com \
--to=dsahern@gmail.com \
--cc=davem@davemloft.net \
--cc=jakub.kicinski@netronome.com \
--cc=jiri@mellanox.com \
--cc=john.hurley@netronome.com \
--cc=netdev@vger.kernel.org \
--cc=oss-drivers@netronome.com \
--cc=simon.horman@netronome.com \
--cc=willemdebruijn.kernel@gmail.com \
--cc=xiyou.wangcong@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).