From: Ido Schimmel <idosch@idosch•org>
To: Zahari Doychev <zahari.doychev@linux•com>
Cc: netdev@vger•kernel.org, dsahern@gmail•com,
stephen@networkplumber•org, hmehrtens@maxlinear•com,
aleksander.lobakin@intel•com, simon.horman@corigine•com,
Zahari Doychev <zdoychev@maxlinear•com>
Subject: Re: [PATCH iproute2-next] f_flower: add cfm support
Date: Tue, 20 Jun 2023 09:58:35 +0300 [thread overview]
Message-ID: <ZJFOGws2EcmGxLHZ@shredder> (raw)
In-Reply-To: <20230619213523.520800-1-zahari.doychev@linux.com>
On Mon, Jun 19, 2023 at 11:35:23PM +0200, Zahari Doychev wrote:
> +static int flower_parse_cfm(int *argc_p, char ***argv_p, __be16 eth_type,
> + struct nlmsghdr *n)
> +{
> + struct rtattr *cfm_attr;
> + char **argv = *argv_p;
> + int argc = *argc_p;
> + int ret;
> +
> + if (eth_type != htons(ETH_P_CFM)) {
> + fprintf(stderr,
> + "Can't set attribute if ethertype isn't CFM\n");
> + return -1;
> + }
> +
> + cfm_attr = addattr_nest(n, MAX_MSG, TCA_FLOWER_KEY_CFM | NLA_F_NESTED);
> +
> + while (argc > 0) {
> + if (matches(*argv, "mdl") == 0) {
New code is expected to use strcmp() instead of matches(). Looks good
otherwise.
> + __u8 val;
> +
> + NEXT_ARG();
> + ret = get_u8(&val, *argv, 10);
> + if (ret < 0) {
> + fprintf(stderr, "Illegal \"cfm md level\"\n");
> + return -1;
> + }
> + addattr8(n, MAX_MSG, TCA_FLOWER_KEY_CFM_MD_LEVEL, val);
> + } else if (matches(*argv, "op") == 0) {
Likewise.
> + __u8 val;
> +
> + NEXT_ARG();
> + ret = get_u8(&val, *argv, 10);
> + if (ret < 0) {
> + fprintf(stderr, "Illegal \"cfm opcode\"\n");
> + return -1;
> + }
> + addattr8(n, MAX_MSG, TCA_FLOWER_KEY_CFM_OPCODE, val);
> + } else {
> + break;
> + }
> + argc--; argv++;
> + }
> +
> + addattr_nest_end(n, cfm_attr);
> +
> + *argc_p = argc;
> + *argv_p = argv;
> +
> + return 0;
> +}
> +
> static int flower_parse_opt(struct filter_util *qu, char *handle,
> int argc, char **argv, struct nlmsghdr *n)
> {
> @@ -2065,6 +2118,12 @@ static int flower_parse_opt(struct filter_util *qu, char *handle,
> return -1;
> }
> continue;
> + } else if (matches(*argv, "cfm") == 0) {
Likewise.
> + NEXT_ARG();
> + ret = flower_parse_cfm(&argc, &argv, eth_type, n);
> + if (ret < 0)
> + return -1;
> + continue;
> } else {
> if (strcmp(*argv, "help") != 0)
> fprintf(stderr, "What is \"%s\"?\n", *argv);
next prev parent reply other threads:[~2023-06-20 6:58 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-19 21:35 [PATCH iproute2-next] f_flower: add cfm support Zahari Doychev
2023-06-20 6:58 ` Ido Schimmel [this message]
2023-06-25 18:54 ` Stephen Hemminger
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=ZJFOGws2EcmGxLHZ@shredder \
--to=idosch@idosch$(echo .)org \
--cc=aleksander.lobakin@intel$(echo .)com \
--cc=dsahern@gmail$(echo .)com \
--cc=hmehrtens@maxlinear$(echo .)com \
--cc=netdev@vger$(echo .)kernel.org \
--cc=simon.horman@corigine$(echo .)com \
--cc=stephen@networkplumber$(echo .)org \
--cc=zahari.doychev@linux$(echo .)com \
--cc=zdoychev@maxlinear$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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