netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* iproute2: Behavioural Bug?
@ 2015-08-24  8:30 Akshat Kakkar
  2015-08-24 19:17 ` Vadim Kochan
  2015-08-24 23:22 ` Florian Westphal
  0 siblings, 2 replies; 7+ messages in thread
From: Akshat Kakkar @ 2015-08-24  8:30 UTC (permalink / raw)
  To: netdev; +Cc: stephen

When I am trying to delete a single tc filter (i.e. specifying its
handle), it is deleting all the
filters with the same priority/preference. i.e. it is ignoring the
handle specified.

But, When I am doing similar activity in hashtable 800: it is deleting only the
specified filter, i.e. it is behaving as expected.

I am unable to comprehend the reason for this difference in behaviour.

Infact, in kernel 2.6.32 all is working as expected. However, in
kernel 3.1 and 4.1 it is having the behaviour as mentioned above.

For example, following set of commands  create a hashtable 15: and add
2 filters to it.

tc filter add dev eth0 parent 1:0 prio 5 handle 15: protocol ip u32 divisor 256
tc filter add dev eth0 protocol ip parent 1: prio 5 handle 15:2:2 u32
ht 15:2: match ip src 10.0.0.2 flowid 1:10
tc filter add dev eth0 protocol ip parent 1: prio 5 handle 15:2:3 u32
ht 15:2: match ip src 10.0.0.3 flowid 1:10

Now following command DELETES ALL THE FILTERS, though it should only
delete FILTER 15:2:3 !
tc filter del dev eth0 protocol ip parent 1: prio 5 handle 15:2:3 u32

O/p of tc filter show eth0 is this case is blank. As all filters are deleted.


However, similar commands when executed for hashtable 800: is deleting
only the specified filter
tc filter add dev eth0 protocol ip parent 1: prio 5 handle 800:0:2 u32
ht 800:0: match ip src 10.0.0.2 flowid 1:10
tc filter add dev eth0 protocol ip parent 1: prio 5 handle 800:0:3 u32
ht 800:0: match ip src 10.0.0.3 flowid 1:10

tc filter del dev eth0 protocol ip parent 1: prio 5 handle 800:0:2 u32

Above mentioned command only deletes single filter.
O/p of tc filter show eth0 is 2nd case is

filter parent 1: protocol ip pref 5 u32
filter parent 1: protocol ip pref 5 u32 fh 800: ht divisor 1
filter parent 1: protocol ip pref 5 u32 fh 800::3 order 3 key ht 800
bkt 0 flowid 1:10
  match 0a000003/ffffffff at 12

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

* Re: iproute2: Behavioural Bug?
  2015-08-24  8:30 iproute2: Behavioural Bug? Akshat Kakkar
@ 2015-08-24 19:17 ` Vadim Kochan
  2015-08-24 23:22 ` Florian Westphal
  1 sibling, 0 replies; 7+ messages in thread
From: Vadim Kochan @ 2015-08-24 19:17 UTC (permalink / raw)
  To: Akshat Kakkar; +Cc: netdev, stephen

On Mon, Aug 24, 2015 at 02:00:29PM +0530, Akshat Kakkar wrote:
> When I am trying to delete a single tc filter (i.e. specifying its
> handle), it is deleting all the
> filters with the same priority/preference. i.e. it is ignoring the
> handle specified.
> 
> But, When I am doing similar activity in hashtable 800: it is deleting only the
> specified filter, i.e. it is behaving as expected.
> 
> I am unable to comprehend the reason for this difference in behaviour.
> 
> Infact, in kernel 2.6.32 all is working as expected. However, in
> kernel 3.1 and 4.1 it is having the behaviour as mentioned above.
> 
> For example, following set of commands  create a hashtable 15: and add
> 2 filters to it.
> 
> tc filter add dev eth0 parent 1:0 prio 5 handle 15: protocol ip u32 divisor 256
> tc filter add dev eth0 protocol ip parent 1: prio 5 handle 15:2:2 u32
> ht 15:2: match ip src 10.0.0.2 flowid 1:10
> tc filter add dev eth0 protocol ip parent 1: prio 5 handle 15:2:3 u32
> ht 15:2: match ip src 10.0.0.3 flowid 1:10
> 
> Now following command DELETES ALL THE FILTERS, though it should only
> delete FILTER 15:2:3 !
> tc filter del dev eth0 protocol ip parent 1: prio 5 handle 15:2:3 u32
> 
> O/p of tc filter show eth0 is this case is blank. As all filters are deleted.
> 
> 
> However, similar commands when executed for hashtable 800: is deleting
> only the specified filter
> tc filter add dev eth0 protocol ip parent 1: prio 5 handle 800:0:2 u32
> ht 800:0: match ip src 10.0.0.2 flowid 1:10
> tc filter add dev eth0 protocol ip parent 1: prio 5 handle 800:0:3 u32
> ht 800:0: match ip src 10.0.0.3 flowid 1:10
> 
> tc filter del dev eth0 protocol ip parent 1: prio 5 handle 800:0:2 u32
> 
> Above mentioned command only deletes single filter.
> O/p of tc filter show eth0 is 2nd case is
> 
> filter parent 1: protocol ip pref 5 u32
> filter parent 1: protocol ip pref 5 u32 fh 800: ht divisor 1
> filter parent 1: protocol ip pref 5 u32 fh 800::3 order 3 key ht 800
> bkt 0 flowid 1:10
>   match 0a000003/ffffffff at 12
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

Hi,

Thats what I got using this script where I copied your commands:

----------------------------------
#!/bin/bash

DEV=dummy0

ip link del $DEV 2> /dev/null

ip link add dev $DEV type dummy

tc qdisc add dev $DEV root handle 1: htb

tc filter add dev $DEV parent 1:0 prio 5 handle 15: protocol ip u32 divisor 256
tc filter add dev $DEV protocol ip parent 1: prio 5 handle 15:2:2 u32 ht 15:2: match ip src 10.0.0.2 flowid 1:10
tc filter add dev $DEV protocol ip parent 1: prio 5 handle 15:2:3 u32 ht 15:2: match ip src 10.0.0.3 flowid 1:10

tc filter del dev $DEV protocol ip parent 1: prio 5 handle 15:2:3 u32

tc filter show dev $DEV
# ---------------------------------

Result is:

filter parent 1: protocol ip pref 5 u32 
filter parent 1: protocol ip pref 5 u32 fh 15: ht divisor 256 
filter parent 1: protocol ip pref 5 u32 fh 15:2:2 order 2 key ht 15 bkt 2 flowid 1:10 
  match 0a000002/ffffffff at 12
filter parent 1: protocol ip pref 5 u32 fh 800: ht divisor 1 

Some additional info:

# tc -V
tc utility, iproute2-ss150413

# uname -a
Linux angus-think 4.0.4-2-ARCH #1 SMP PREEMPT Fri May 22 03:05:23 UTC 2015 x86_64 GNU/Linux

Regards,
Vadim Kochan

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

* Re: iproute2: Behavioural Bug?
  2015-08-24  8:30 iproute2: Behavioural Bug? Akshat Kakkar
  2015-08-24 19:17 ` Vadim Kochan
@ 2015-08-24 23:22 ` Florian Westphal
  2015-08-25  5:14   ` Akshat Kakkar
  1 sibling, 1 reply; 7+ messages in thread
From: Florian Westphal @ 2015-08-24 23:22 UTC (permalink / raw)
  To: Akshat Kakkar; +Cc: netdev, stephen, xiyou.wangcong

Akshat Kakkar <akshat.1984@gmail.com> wrote:

[ CC Cong ]

> When I am trying to delete a single tc filter (i.e. specifying its
> handle), it is deleting all the
> filters with the same priority/preference. i.e. it is ignoring the
> handle specified.
> 
> But, When I am doing similar activity in hashtable 800: it is deleting only the
> specified filter, i.e. it is behaving as expected.
> 
> I am unable to comprehend the reason for this difference in behaviour.
> 
> Infact, in kernel 2.6.32 all is working as expected. However, in
> kernel 3.1 and 4.1 it is having the behaviour as mentioned above.
> 
> For example, following set of commands  create a hashtable 15: and add
> 2 filters to it.
> 
> tc filter add dev eth0 parent 1:0 prio 5 handle 15: protocol ip u32 divisor 256
> tc filter add dev eth0 protocol ip parent 1: prio 5 handle 15:2:2 u32
> ht 15:2: match ip src 10.0.0.2 flowid 1:10
> tc filter add dev eth0 protocol ip parent 1: prio 5 handle 15:2:3 u32
> ht 15:2: match ip src 10.0.0.3 flowid 1:10
> 
> Now following command DELETES ALL THE FILTERS, though it should only
> delete FILTER 15:2:3 !
> tc filter del dev eth0 protocol ip parent 1: prio 5 handle 15:2:3 u32
> 
> O/p of tc filter show eth0 is this case is blank. As all filters are deleted.

Happens since

1e052be69d045c8d0f82ff1116fd3e5a79661745
("net_sched: destroy proto tp when all filters are gone").

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

* Re: iproute2: Behavioural Bug?
  2015-08-24 23:22 ` Florian Westphal
@ 2015-08-25  5:14   ` Akshat Kakkar
  2015-08-25  6:08     ` Cong Wang
  0 siblings, 1 reply; 7+ messages in thread
From: Akshat Kakkar @ 2015-08-25  5:14 UTC (permalink / raw)
  To: Florian Westphal; +Cc: netdev, stephen, xiyou.wangcong

Dear Florian,

There are two filters 15:2:2 and 15:2:3 and I have deleted only
15:2:3, so 15:2:2 will still be there and hence this condition
"destroy proto tp when all filters are gone" should not be applicable
over here.

On Tue, Aug 25, 2015 at 4:52 AM, Florian Westphal <fw@strlen.de> wrote:
> Akshat Kakkar <akshat.1984@gmail.com> wrote:
>
> [ CC Cong ]
>
>> When I am trying to delete a single tc filter (i.e. specifying its
>> handle), it is deleting all the
>> filters with the same priority/preference. i.e. it is ignoring the
>> handle specified.
>>
>> But, When I am doing similar activity in hashtable 800: it is deleting only the
>> specified filter, i.e. it is behaving as expected.
>>
>> I am unable to comprehend the reason for this difference in behaviour.
>>
>> Infact, in kernel 2.6.32 all is working as expected. However, in
>> kernel 3.1 and 4.1 it is having the behaviour as mentioned above.
>>
>> For example, following set of commands  create a hashtable 15: and add
>> 2 filters to it.
>>
>> tc filter add dev eth0 parent 1:0 prio 5 handle 15: protocol ip u32 divisor 256
>> tc filter add dev eth0 protocol ip parent 1: prio 5 handle 15:2:2 u32
>> ht 15:2: match ip src 10.0.0.2 flowid 1:10
>> tc filter add dev eth0 protocol ip parent 1: prio 5 handle 15:2:3 u32
>> ht 15:2: match ip src 10.0.0.3 flowid 1:10
>>
>> Now following command DELETES ALL THE FILTERS, though it should only
>> delete FILTER 15:2:3 !
>> tc filter del dev eth0 protocol ip parent 1: prio 5 handle 15:2:3 u32
>>
>> O/p of tc filter show eth0 is this case is blank. As all filters are deleted.
>
> Happens since
>
> 1e052be69d045c8d0f82ff1116fd3e5a79661745
> ("net_sched: destroy proto tp when all filters are gone").

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

* Re: iproute2: Behavioural Bug?
  2015-08-25  5:14   ` Akshat Kakkar
@ 2015-08-25  6:08     ` Cong Wang
  2015-08-25  7:18       ` Akshat Kakkar
  0 siblings, 1 reply; 7+ messages in thread
From: Cong Wang @ 2015-08-25  6:08 UTC (permalink / raw)
  To: Akshat Kakkar; +Cc: Florian Westphal, netdev, Stephen Hemminger, Cong Wang

On Mon, Aug 24, 2015 at 10:14 PM, Akshat Kakkar <akshat.1984@gmail.com> wrote:
> Dear Florian,
>
> There are two filters 15:2:2 and 15:2:3 and I have deleted only
> 15:2:3, so 15:2:2 will still be there and hence this condition
> "destroy proto tp when all filters are gone" should not be applicable
> over here.
>

Florian is correct, it _does_ look like this is caused by my patch,
I guess some check in u32_destroy() isn't correct.

It's late here, I will look into this tomorrow.

Thanks for the report anyway!

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

* Re: iproute2: Behavioural Bug?
  2015-08-25  6:08     ` Cong Wang
@ 2015-08-25  7:18       ` Akshat Kakkar
  2015-08-25 21:00         ` Cong Wang
  0 siblings, 1 reply; 7+ messages in thread
From: Akshat Kakkar @ 2015-08-25  7:18 UTC (permalink / raw)
  To: Cong Wang; +Cc: Florian Westphal, netdev, Stephen Hemminger, Cong Wang

Well if that is the case, then just an additional information (which I
have initially mentioned though), if hashtable is 800, then behaviour
is correct i.e. deleting only a single filter but for hash tables
other than 800, the bug (if any) gets triggered.

On Tue, Aug 25, 2015 at 11:38 AM, Cong Wang <cwang@twopensource.com> wrote:
> On Mon, Aug 24, 2015 at 10:14 PM, Akshat Kakkar <akshat.1984@gmail.com> wrote:
>> Dear Florian,
>>
>> There are two filters 15:2:2 and 15:2:3 and I have deleted only
>> 15:2:3, so 15:2:2 will still be there and hence this condition
>> "destroy proto tp when all filters are gone" should not be applicable
>> over here.
>>
>
> Florian is correct, it _does_ look like this is caused by my patch,
> I guess some check in u32_destroy() isn't correct.
>
> It's late here, I will look into this tomorrow.
>
> Thanks for the report anyway!

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

* Re: iproute2: Behavioural Bug?
  2015-08-25  7:18       ` Akshat Kakkar
@ 2015-08-25 21:00         ` Cong Wang
  0 siblings, 0 replies; 7+ messages in thread
From: Cong Wang @ 2015-08-25 21:00 UTC (permalink / raw)
  To: Akshat Kakkar
  Cc: Florian Westphal, netdev, Stephen Hemminger, Cong Wang,
	Jamal Hadi Salim

[-- Attachment #1: Type: text/plain, Size: 724 bytes --]

(Cc'ing Jamal)

On Tue, Aug 25, 2015 at 12:18 AM, Akshat Kakkar <akshat.1984@gmail.com> wrote:
> Well if that is the case, then just an additional information (which I
> have initially mentioned though), if hashtable is 800, then behaviour
> is correct i.e. deleting only a single filter but for hash tables
> other than 800, the bug (if any) gets triggered.
>

Hmm, I didn't read your initial email before my previous reply.

But I bet you deleted the 800: filter _after_ deleting the 15: one?
u32 hashtables are stateful, try the reverse order, I don't see
any reason why 800: could be any special here, expect it is the
default handle picked by kernel.

The attached patch works for me, let me know if it works for you..

[-- Attachment #2: u32.diff --]
[-- Type: text/plain, Size: 621 bytes --]

diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c
index cab9e9b..ac5e0ad 100644
--- a/net/sched/cls_u32.c
+++ b/net/sched/cls_u32.c
@@ -495,6 +495,20 @@ static bool u32_destroy(struct tcf_proto *tp, bool force)
 	if (root_ht && --root_ht->refcnt == 0)
 		u32_destroy_hnode(tp, root_ht);
 
+	if (!force) {
+		struct tc_u_hnode *ht;
+
+		if (tp_c->refcnt > 1)
+			return false;
+		if (tp_c->refcnt == 1) {
+			for (ht = rtnl_dereference(tp_c->hlist);
+			     ht;
+			     ht = rtnl_dereference(ht->next))
+				if (!ht_empty(ht))
+					return false;
+		}
+	}
+
 	if (--tp_c->refcnt == 0) {
 		struct tc_u_hnode *ht;
 

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

end of thread, other threads:[~2015-08-25 21:00 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-24  8:30 iproute2: Behavioural Bug? Akshat Kakkar
2015-08-24 19:17 ` Vadim Kochan
2015-08-24 23:22 ` Florian Westphal
2015-08-25  5:14   ` Akshat Kakkar
2015-08-25  6:08     ` Cong Wang
2015-08-25  7:18       ` Akshat Kakkar
2015-08-25 21:00         ` Cong Wang

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).