netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH iproute2/master] tc actions: store and dump correct length of user cookies
@ 2017-09-05 11:06 Simon Horman
  2017-09-05 16:27 ` Stephen Hemminger
  0 siblings, 1 reply; 2+ messages in thread
From: Simon Horman @ 2017-09-05 11:06 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: netdev, oss-drivers, Simon Horman, Jamal Hadi Salim

Correct two errors which cancel each other out:
* Do not send twice the length of the actual provided by the user to the kernel
* Do not dump half the length of the cookie provided by the kernel

As the cookie is now stored in the kernel at its correct length rather
than double the that length cookies of up to the maximum size of 16 bytes
may now be stored rather than a maximum of half that length.

Output of dump is the same before and after this change,
but the data stored in the kernel is now exactly the cookie
rather than the cookie + as many trailing zeros.

Before:
 # tc filter add dev eth0 protocol ip parent ffff: \
       flower ip_proto udp action drop \
       cookie 0123456789abcdef0123456789abcdef
 RTNETLINK answers: Invalid argument

After:
 # tc filter add dev eth0 protocol ip parent ffff: \
       flower ip_proto udp action drop \
       cookie 0123456789abcdef0123456789abcdef
 # tc filter show dev eth0 ingress
   eth_type ipv4
   ip_proto udp
   not_in_hw
	 action order 1: gact action drop
	  random type none pass val 0
	  index 1 ref 1 bind 1 installed 1 sec used 1 sec
	 Action statistics:
	 Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
	 backlog 0b 0p requeues 0
	 cookie len 16 0123456789abcdef0123456789abcdef

Fixes: fd8b3d2c1b9b ("actions: Add support for user cookies")
Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: Simon Horman <simon.horman@netronome.com>
---
 tc/m_action.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tc/m_action.c b/tc/m_action.c
index 6ebe85e1cbe3..397e9c5d4a7b 100644
--- a/tc/m_action.c
+++ b/tc/m_action.c
@@ -242,7 +242,7 @@ done0:
 					invarg("cookie must be a hex string\n",
 					       *argv);
 
-				act_ck_len = slen;
+				act_ck_len = slen / 2;
 				argc--;
 				argv++;
 			}
@@ -307,7 +307,7 @@ static int tc_print_one_action(FILE *f, struct rtattr *arg)
 		print_tcstats2_attr(f, tb[TCA_ACT_STATS], "\t", NULL);
 		if (tb[TCA_ACT_COOKIE]) {
 			int strsz = RTA_PAYLOAD(tb[TCA_ACT_COOKIE]);
-			char b1[strsz+1];
+			char b1[strsz * 2 + 1];
 
 			fprintf(f, "\n\tcookie len %d %s ", strsz,
 				hexstring_n2a(RTA_DATA(tb[TCA_ACT_COOKIE]),
-- 
2.1.4

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

* Re: [PATCH iproute2/master] tc actions: store and dump correct length of user cookies
  2017-09-05 11:06 [PATCH iproute2/master] tc actions: store and dump correct length of user cookies Simon Horman
@ 2017-09-05 16:27 ` Stephen Hemminger
  0 siblings, 0 replies; 2+ messages in thread
From: Stephen Hemminger @ 2017-09-05 16:27 UTC (permalink / raw)
  To: Simon Horman; +Cc: netdev, oss-drivers, Jamal Hadi Salim

On Tue,  5 Sep 2017 13:06:24 +0200
Simon Horman <simon.horman@netronome.com> wrote:

> Correct two errors which cancel each other out:
> * Do not send twice the length of the actual provided by the user to the kernel
> * Do not dump half the length of the cookie provided by the kernel
> 
> As the cookie is now stored in the kernel at its correct length rather
> than double the that length cookies of up to the maximum size of 16 bytes
> may now be stored rather than a maximum of half that length.
> 
> Output of dump is the same before and after this change,
> but the data stored in the kernel is now exactly the cookie
> rather than the cookie + as many trailing zeros.
> 
> Before:
>  # tc filter add dev eth0 protocol ip parent ffff: \
>        flower ip_proto udp action drop \
>        cookie 0123456789abcdef0123456789abcdef
>  RTNETLINK answers: Invalid argument
> 
> After:
>  # tc filter add dev eth0 protocol ip parent ffff: \
>        flower ip_proto udp action drop \
>        cookie 0123456789abcdef0123456789abcdef
>  # tc filter show dev eth0 ingress
>    eth_type ipv4
>    ip_proto udp
>    not_in_hw
> 	 action order 1: gact action drop
> 	  random type none pass val 0
> 	  index 1 ref 1 bind 1 installed 1 sec used 1 sec
> 	 Action statistics:
> 	 Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
> 	 backlog 0b 0p requeues 0
> 	 cookie len 16 0123456789abcdef0123456789abcdef
> 
> Fixes: fd8b3d2c1b9b ("actions: Add support for user cookies")
> Cc: Jamal Hadi Salim <jhs@mojatatu.com>
> Signed-off-by: Simon Horman <simon.horman@netronome.com>

Applied thanks

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

end of thread, other threads:[~2017-09-05 16:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-05 11:06 [PATCH iproute2/master] tc actions: store and dump correct length of user cookies Simon Horman
2017-09-05 16:27 ` Stephen Hemminger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).