[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20250520122600.30f3bd00@hermes.local>
Date: Tue, 20 May 2025 12:26:00 -0700
From: Stephen Hemminger <stephen@...workplumber.org>
To: Stanislav Fomichev <sdf@...ichev.me>
Cc: netdev@...r.kernel.org, dsahern@...il.com
Subject: Re: [PATCH iproute2] ip: support setting multiple features
On Tue, 6 May 2025 14:03:40 -0700
Stanislav Fomichev <sdf@...ichev.me> wrote:
> Commit a043bea75002 ("ip route: add support for TCP usec TS") added
> support for tcp_usec_ts but the existing code was not adjusted
> to handle multiple features in the same invocation:
>
> $ ip route add .. dev .. features tcp_usec_ts ecn
> Error: either "to" is duplicate, or "ecn" is garbage.
>
> The code exits the while loop as soon as it encounters any feature,
> make it more flexible. Tested with the following:
>
> $ ip route add .. dev .. features tcp_usec_ts ecn
> $ ip route add .. dev .. features tcp_usec_ts ecn quickack 1
>
> Fixes: a043bea75002 ("ip route: add support for TCP usec TS")
> Signed-off-by: Stanislav Fomichev <sdf@...ichev.me>
> ---
> ip/iproute.c | 17 ++++++++++++-----
> 1 file changed, 12 insertions(+), 5 deletions(-)
>
> diff --git a/ip/iproute.c b/ip/iproute.c
> index 0e2c171f4b8e..a692e7c47110 100644
> --- a/ip/iproute.c
> +++ b/ip/iproute.c
> @@ -1374,16 +1374,23 @@ static int iproute_modify(int cmd, unsigned int flags, int argc, char **argv)
> } else if (matches(*argv, "features") == 0) {
> unsigned int features = 0;
>
> - while (argc > 0) {
> + while (NEXT_ARG_OK()) {
> NEXT_ARG();
>
> - if (strcmp(*argv, "ecn") == 0)
> + if (strcmp(*argv, "ecn") == 0) {
> features |= RTAX_FEATURE_ECN;
> - else if (strcmp(*argv, "tcp_usec_ts") == 0)
> + } else if (strcmp(*argv, "tcp_usec_ts") == 0) {
> features |= RTAX_FEATURE_TCP_USEC_TS;
> - else
> + } else {
> + if (features) {
> + /* next arg possibly not a
> + * feature, try to rewind */
> + PREV_ARG();
> + break;
> + }
> +
> invarg("\"features\" value not valid\n", *argv);
> - break;
> + }
> }
>
> rta_addattr32(mxrta, sizeof(mxbuf),
> --
> 2.49.0
>
>
This really needs to be a function and handle them in any order.
Also then the unwind would be cleaner.
Powered by blists - more mailing lists