[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <feace2e1ac81af7dfbce514727229a5b2767d5a1.1746565372.git.sdf@fomichev.me>
Date: Tue, 6 May 2025 14:03:40 -0700
From: Stanislav Fomichev <sdf@...ichev.me>
To: netdev@...r.kernel.org
Cc: dsahern@...il.com
Subject: [PATCH iproute2] ip: support setting multiple features
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
Powered by blists - more mailing lists