All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH iproute2] tc: f_u32: allow skip_hw and skip_sw flags to be last
@ 2018-11-06  3:23 Jakub Kicinski
  2018-11-09 16:13 ` Stephen Hemminger
  0 siblings, 1 reply; 2+ messages in thread
From: Jakub Kicinski @ 2018-11-06  3:23 UTC (permalink / raw)
  To: stephen, dsahern; +Cc: netdev, oss-drivers, Jakub Kicinski

u32 uses NEXT_ARG() incorrectly when parsing skip_hw and skip_sw
flags.  NEXT_ARG() ensures there is another argument on the command
line, and is used in handling <keyword> <value> syntax to move past
<keyword> and ensure there is a <value> to read.

Commit 5e5b3008d1fb ("tc: f_u32: Add support for skip_hw and skip_sw
flags") seems to have copy pasted the handling from the previous
command - "police", which needs an extra parameter and is kind of
special due to the use of parse_police() helper.

The combination of NEXT_ARG() and continue worked fine as long as
skip_sw/skip_hw wasn't last, e.g.:

$ tc filter add dev dummy0 ingress prio 101 protocol ipv6 \
    u32 match ip6 priority 0xa0 0xe0 skip_hw action pass

But would fail if it was last:

$ tc filter add dev dummy0 ingress prio 101 protocol ipv6 \
    u32 match ip6 priority 0xa0 0xe0 flowid :1 skip_hw
Command line is not complete. Try option "help"

Remove the NEXT_ARG()s and the continues, and let the argc--; argv++;
at the end of the loop do its job.

Fixes: 5e5b3008d1fb ("tc: f_u32: Add support for skip_hw and skip_sw flags")
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
---
 tc/f_u32.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/tc/f_u32.c b/tc/f_u32.c
index bff4be637728..e0a322d5a11c 100644
--- a/tc/f_u32.c
+++ b/tc/f_u32.c
@@ -1147,13 +1147,9 @@ static int u32_parse_opt(struct filter_util *qu, char *handle,
 			terminal_ok++;
 			continue;
 		} else if (strcmp(*argv, "skip_hw") == 0) {
-			NEXT_ARG();
 			flags |= TCA_CLS_FLAGS_SKIP_HW;
-			continue;
 		} else if (strcmp(*argv, "skip_sw") == 0) {
-			NEXT_ARG();
 			flags |= TCA_CLS_FLAGS_SKIP_SW;
-			continue;
 		} else if (strcmp(*argv, "help") == 0) {
 			explain();
 			return -1;
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH iproute2] tc: f_u32: allow skip_hw and skip_sw flags to be last
  2018-11-06  3:23 [PATCH iproute2] tc: f_u32: allow skip_hw and skip_sw flags to be last Jakub Kicinski
@ 2018-11-09 16:13 ` Stephen Hemminger
  0 siblings, 0 replies; 2+ messages in thread
From: Stephen Hemminger @ 2018-11-09 16:13 UTC (permalink / raw)
  To: Jakub Kicinski; +Cc: dsahern, netdev, oss-drivers

On Mon,  5 Nov 2018 19:23:27 -0800
Jakub Kicinski <jakub.kicinski@netronome.com> wrote:

> u32 uses NEXT_ARG() incorrectly when parsing skip_hw and skip_sw
> flags.  NEXT_ARG() ensures there is another argument on the command
> line, and is used in handling <keyword> <value> syntax to move past
> <keyword> and ensure there is a <value> to read.
> 
> Commit 5e5b3008d1fb ("tc: f_u32: Add support for skip_hw and skip_sw
> flags") seems to have copy pasted the handling from the previous
> command - "police", which needs an extra parameter and is kind of
> special due to the use of parse_police() helper.
> 
> The combination of NEXT_ARG() and continue worked fine as long as
> skip_sw/skip_hw wasn't last, e.g.:
> 
> $ tc filter add dev dummy0 ingress prio 101 protocol ipv6 \
>     u32 match ip6 priority 0xa0 0xe0 skip_hw action pass
> 
> But would fail if it was last:
> 
> $ tc filter add dev dummy0 ingress prio 101 protocol ipv6 \
>     u32 match ip6 priority 0xa0 0xe0 flowid :1 skip_hw
> Command line is not complete. Try option "help"
> 
> Remove the NEXT_ARG()s and the continues, and let the argc--; argv++;
> at the end of the loop do its job.
> 
> Fixes: 5e5b3008d1fb ("tc: f_u32: Add support for skip_hw and skip_sw flags")
> Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>

Applied

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-11-10  1:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-06  3:23 [PATCH iproute2] tc: f_u32: allow skip_hw and skip_sw flags to be last Jakub Kicinski
2018-11-09 16:13 ` Stephen Hemminger

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.