[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20200701100159.GA18417@pc-3.home>
Date: Wed, 1 Jul 2020 12:01:59 +0200
From: Guillaume Nault <gnault@...hat.com>
To: Andrea Claudi <aclaudi@...hat.com>
Cc: Stephen Hemminger <stephen@...workplumber.org>,
linux-netdev <netdev@...r.kernel.org>
Subject: Re: [PATCH iproute2] tc: flower: support multiple MPLS LSE match
On Wed, Jul 01, 2020 at 11:17:56AM +0200, Andrea Claudi wrote:
> On Fri, Jun 19, 2020 at 12:51 PM Guillaume Nault <gnault@...hat.com> wrote:
> >
> > +.BI depth " DEPTH"
> > +The depth of the Label Stack Entry to consider. Depth starts at 1 (the
> > +outermost Label Stack Entry). The maximum usable depth may be limitted by the
>
> limited
Looks like I forgot the spell-checking step before submitting :/
> > +static int flower_parse_mpls(int *argc_p, char ***argv_p, struct nlmsghdr *nlh)
> > +{
> > + struct rtattr *mpls_attr;
> > + char **argv = *argv_p;
> > + int argc = *argc_p;
> > +
> > + mpls_attr = addattr_nest(nlh, MAX_MSG,
> > + TCA_FLOWER_KEY_MPLS_OPTS | NLA_F_NESTED);
> > +
> > + while (argc > 0) {
> > + if (matches(*argv, "lse") == 0) {
> > + NEXT_ARG();
> > + if (flower_parse_mpls_lse(&argc, &argv, nlh) < 0)
> > + return -1;
> > + } else {
> > + break;
> > + }
> > + }
>
> This can probably be simplified to:
>
> while (argc > 0 && matches(*argv, "lse") == 0) {
> NEXT_ARG();
> if (flower_parse_mpls_lse(&argc, &argv, nlh) < 0)
> return -1;
> }
I wanted to use the same loop construct as is commonly used for parsing
options in iproute2. I find it easier to verify code correctness when
the same construct is used consistently.
Also this allows to easily add new keywords in the future, even though
I can't see a need for that at the moment.
I'll keep my original while() loop for the moment, unless more voices
speak against it.
Thanks a lot for the review!
Powered by blists - more mailing lists