From: David Ahern <dsahern@gmail.com>
To: William Tu <u9012063@gmail.com>, netdev@vger.kernel.org
Subject: Re: [PATCH v2 iproute2 net-next] erspan: add erspan version II support
Date: Tue, 19 Dec 2017 15:17:17 -0700 [thread overview]
Message-ID: <d7283b25-e7a2-76e3-3946-137bc5baf416@gmail.com> (raw)
In-Reply-To: <1513386366-38095-1-git-send-email-u9012063@gmail.com>
On 12/15/17 6:06 PM, William Tu wrote:
> @@ -343,6 +355,22 @@ get_failed:
> invarg("invalid erspan index\n", *argv);
> if (erspan_idx & ~((1<<20) - 1) || erspan_idx == 0)
> invarg("erspan index must be > 0 and <= 20-bit\n", *argv);
> + } else if (strcmp(*argv, "erspan_ver") == 0) {
> + NEXT_ARG();
> + if (get_u8(&erspan_ver, *argv, 0))
> + invarg("invalid erspan version\n", *argv);
> + if (erspan_ver != 1 && erspan_ver != 2)
> + invarg("erspan version must be 1 or 2\n", *argv);
> + } else if (strcmp(*argv, "erspan_dir") == 0) {
> + NEXT_ARG();
> + if (get_u8(&erspan_dir, *argv, 0))
> + invarg("invalid erspan direction\n", *argv);
> + if (erspan_dir != 0 && erspan_dir != 1)
> + invarg("erspan direction must be 0(Ingress) or 1(Egress)\n", *argv);
Why not allow ingress and egress as strings and using matches()?
e.g., '... erspan_dir in[gress] ...' or '... erspan_dir e[gress] ...'
Seems much more intuitive than remembering "0" = ingress and "1" = egress.
> @@ -374,8 +402,15 @@ get_failed:
> addattr_l(n, 1024, IFLA_GRE_TTL, &ttl, 1);
> addattr_l(n, 1024, IFLA_GRE_TOS, &tos, 1);
> addattr32(n, 1024, IFLA_GRE_FWMARK, fwmark);
> - if (erspan_idx != 0)
> - addattr32(n, 1024, IFLA_GRE_ERSPAN_INDEX, erspan_idx);
> + if (erspan_ver) {
> + addattr8(n, 1024, IFLA_GRE_ERSPAN_VER, erspan_ver);
> + if (erspan_ver == 1 && erspan_idx != 0) {
> + addattr32(n, 1024, IFLA_GRE_ERSPAN_INDEX, erspan_idx);
> + } else if (erspan_ver == 2) {
> + addattr8(n, 1024, IFLA_GRE_ERSPAN_DIR, erspan_dir);
> + addattr16(n, 1024, IFLA_GRE_ERSPAN_HWID, erspan_hwid);
> + }
> + }
> } else {
> addattr_l(n, 1024, IFLA_GRE_COLLECT_METADATA, NULL, 0);
> }
> @@ -514,7 +549,25 @@ static void gre_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
> if (tb[IFLA_GRE_ERSPAN_INDEX]) {
> __u32 erspan_idx = rta_getattr_u32(tb[IFLA_GRE_ERSPAN_INDEX]);
>
> - fprintf(f, "erspan_index %u ", erspan_idx);
> + print_uint(PRINT_ANY, "erspan_index", "erspan_index %u", erspan_idx);
> + }
> +
> + if (tb[IFLA_GRE_ERSPAN_VER]) {
> + __u8 erspan_ver = rta_getattr_u8(tb[IFLA_GRE_ERSPAN_VER]);
> +
> + print_uint(PRINT_ANY, "erspan_ver", "erspan_ver %u", erspan_ver);
> + }
> +
> + if (tb[IFLA_GRE_ERSPAN_DIR]) {
> + __u8 erspan_dir = rta_getattr_u8(tb[IFLA_GRE_ERSPAN_DIR]);
> +
> + print_uint(PRINT_ANY, "erspan_dir", "erspan_dir %u", erspan_dir);
similarly, here can convert the 0/1 to a human string.
Same comments for the changes to link_gre6.c
next prev parent reply other threads:[~2017-12-19 22:17 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-16 1:06 [PATCH v2 iproute2 net-next] erspan: add erspan version II support William Tu
2017-12-19 22:17 ` David Ahern [this message]
2017-12-19 23:15 ` William Tu
-- strict thread matches above, loose matches on Subject: below --
2017-12-15 21:42 William Tu
2017-12-15 23:58 ` Roman Mashak
2017-12-16 0:55 ` William Tu
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=d7283b25-e7a2-76e3-3946-137bc5baf416@gmail.com \
--to=dsahern@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=u9012063@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).