Skip to contentSkip to conversation

net_sched: cls_*: couple of fixes

PATCH In review Jiri Pirko 6 participants 26 messages Dec 2, 2014 – Dec 9, 2014

Subsystems (5)
lore
Share & tools
lore

Jiri Pirko

author maintainer
#0 lore raw

cover net_sched: cls_*: couple of fixes

Jiri Pirko (6):
net_sched: cls_basic: remove unnecessary iteration and use passed arg
net_sched: cls_bpf: remove unnecessary iteration and use passed arg
net_sched: cls_bpf: remove faulty use of list_for_each_entry_rcu
net_sched: cls_flow: remove faulty use of list_for_each_entry_rcu
net_sched: cls_flow: remove duplicate assignments
net_sched: cls_cgroup: remove unnecessary if

 net/sched/cls_basic.c  | 16 +++++-----------
 net/sched/cls_bpf.c    | 21 +++++++--------------
 net/sched/cls_cgroup.c |  6 +-----
 net/sched/cls_flow.c   |  7 ++-----
 4 files changed, 15 insertions(+), 35 deletions(-)
Signature · 1 line
1.9.3
author maintainer
#1 lore raw

PATCH 1/6 net_sched: cls_basic: remove unnecessary iteration and use passed arg

---
 net/sched/cls_basic.c | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)
net/sched/cls_basic.c +5 -11
index cd61280..1c122c7 100644
@@ -113,18 +113,12 @@ static void basic_destroy(struct tcf_proto *tp)
 
 static int basic_delete(struct tcf_proto *tp, unsigned long arg)
 {
-	struct basic_head *head = rtnl_dereference(tp->root);
-	struct basic_filter *t, *f = (struct basic_filter *) arg;
-
-	list_for_each_entry(t, &head->flist, link)
-		if (t == f) {
-			list_del_rcu(&t->link);
-			tcf_unbind_filter(tp, &t->res);
-			call_rcu(&t->rcu, basic_delete_filter);
-			return 0;
-		}
+	struct basic_filter *f = (struct basic_filter *) arg;
 
-	return -ENOENT;
+	list_del_rcu(&f->link);
+	tcf_unbind_filter(tp, &f->res);
+	call_rcu(&f->rcu, basic_delete_filter);
+	return 0;
 }
 
 static const struct nla_policy basic_policy[TCA_BASIC_MAX + 1] = {
Signature · 1 line
1.9.3
author maintainer
#16 lore raw

PATCH 4/6 net_sched: cls_flow: remove faulty use of list_for_each_entry_rcu

In reply to Jiri Pirko

rcu variant is not correct here. The code is called by updater (rtnl lock is held), not by reader (no rcu_read_lock is held).

---
 net/sched/cls_flow.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/sched/cls_flow.c +2 -2
index 4ac515f..a605739 100644
@@ -578,7 +578,7 @@ static unsigned long flow_get(struct tcf_proto *tp, u32 handle)
 	struct flow_head *head = rtnl_dereference(tp->root);
 	struct flow_filter *f;
 
-	list_for_each_entry_rcu(f, &head->filters, list)
+	list_for_each_entry(f, &head->filters, list)
 		if (f->handle == handle)
 			return (unsigned long)f;
 	return 0;
@@ -654,7 +654,7 @@ static void flow_walk(struct tcf_proto *tp, struct tcf_walker *arg)
 	struct flow_head *head = rtnl_dereference(tp->root);
 	struct flow_filter *f;
 
-	list_for_each_entry_rcu(f, &head->filters, list) {
+	list_for_each_entry(f, &head->filters, list) {
 		if (arg->count < arg->skip)
 			goto skip;
 		if (arg->fn(tp, (unsigned long)f, arg) < 0) {
Signature · 1 line
1.9.3
author maintainer
#6 lore raw

PATCH 3/6 net_sched: cls_bpf: remove faulty use of list_for_each_entry_rcu

In reply to Jiri Pirko

rcu variant is not correct here. The code is called by updater (rtnl lock is held), not by reader (no rcu_read_lock is held).

---
 net/sched/cls_bpf.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/sched/cls_bpf.c +2 -2
index cbfaf6f..d0de979 100644
@@ -141,7 +141,7 @@ static unsigned long cls_bpf_get(struct tcf_proto *tp, u32 handle)
 	if (head == NULL)
 		return 0UL;
 
-	list_for_each_entry_rcu(prog, &head->plist, link) {
+	list_for_each_entry(prog, &head->plist, link) {
 		if (prog->handle == handle) {
 			ret = (unsigned long) prog;
 			break;
@@ -337,7 +337,7 @@ static void cls_bpf_walk(struct tcf_proto *tp, struct tcf_walker *arg)
 	struct cls_bpf_head *head = rtnl_dereference(tp->root);
 	struct cls_bpf_prog *prog;
 
-	list_for_each_entry_rcu(prog, &head->plist, link) {
+	list_for_each_entry(prog, &head->plist, link) {
 		if (arg->count < arg->skip)
 			goto skip;
 		if (arg->fn(tp, (unsigned long) prog, arg) < 0) {
Signature · 1 line
1.9.3
author maintainer
#19 lore raw

PATCH 6/6 net_sched: cls_cgroup: remove unnecessary if

In reply to Jiri Pirko

since head->handle == handle (checked before), just assign handle.

---
 net/sched/cls_cgroup.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
net/sched/cls_cgroup.c +1 -5
index d61a801..dbee65e 100644
@@ -117,11 +117,7 @@ static int cls_cgroup_change(struct net *net, struct sk_buff *in_skb,
 		return -ENOBUFS;
 
 	tcf_exts_init(&new->exts, TCA_CGROUP_ACT, TCA_CGROUP_POLICE);
-	if (head)
-		new->handle = head->handle;
-	else
-		new->handle = handle;
-
+	new->handle = handle;
 	new->tp = tp;
 	err = nla_parse_nested(tb, TCA_CGROUP_MAX, tca[TCA_OPTIONS],
 			       cgroup_policy);
Signature · 1 line
1.9.3
author maintainer
#3 lore raw

PATCH 2/6 net_sched: cls_bpf: remove unnecessary iteration and use passed arg

In reply to Jiri Pirko
---
 net/sched/cls_bpf.c | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)
net/sched/cls_bpf.c +5 -12
index eed49d1..cbfaf6f 100644
@@ -109,19 +109,12 @@ static void __cls_bpf_delete_prog(struct rcu_head *rcu)
 
 static int cls_bpf_delete(struct tcf_proto *tp, unsigned long arg)
 {
-	struct cls_bpf_head *head = rtnl_dereference(tp->root);
-	struct cls_bpf_prog *prog, *todel = (struct cls_bpf_prog *) arg;
-
-	list_for_each_entry(prog, &head->plist, link) {
-		if (prog == todel) {
-			list_del_rcu(&prog->link);
-			tcf_unbind_filter(tp, &prog->res);
-			call_rcu(&prog->rcu, __cls_bpf_delete_prog);
-			return 0;
-		}
-	}
+	struct cls_bpf_prog *prog = (struct cls_bpf_prog *) arg;
 
-	return -ENOENT;
+	list_del_rcu(&prog->link);
+	tcf_unbind_filter(tp, &prog->res);
+	call_rcu(&prog->rcu, __cls_bpf_delete_prog);
+	return 0;
 }
 
 static void cls_bpf_destroy(struct tcf_proto *tp)
Signature · 1 line
1.9.3
author maintainer
#18 lore raw

PATCH 5/6 net_sched: cls_flow: remove duplicate assignments

In reply to Jiri Pirko
---
 net/sched/cls_flow.c | 3 ---
 1 file changed, 3 deletions(-)
net/sched/cls_flow.c +0 -3
index a605739..819c230 100644
@@ -426,10 +426,7 @@ static int flow_change(struct net *net, struct sk_buff *in_skb,
 			goto err2;
 
 		/* Copy fold into fnew */
-		fnew->handle = fold->handle;
-		fnew->keymask = fold->keymask;
 		fnew->tp = fold->tp;
-
 		fnew->handle = fold->handle;
 		fnew->nkeys = fold->nkeys;
 		fnew->keymask = fold->keymask;
Signature · 1 line
1.9.3
#7 lore raw

Re: [patch net-next 3/6] net_sched: cls_bpf: remove faulty use of list_for_each_entry_rcu

In reply to Jiri Pirko
Quoted 22 lines · Jiri Pirko

rcu variant is not correct here. The code is called by updater (rtnl lock is held), not by reader (no rcu_read_lock is held).

---
 net/sched/cls_bpf.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/sched/cls_bpf.c +1 -1
index cbfaf6f..d0de979 100644
@@ -141,7 +141,7 @@ static unsigned long cls_bpf_get(struct tcf_proto *tp, u32 handle)
 	if (head == NULL)
 		return 0UL;
 
-	list_for_each_entry_rcu(prog, &head->plist, link) {
+	list_for_each_entry(prog, &head->plist, link) {
 		if (prog->handle == handle) {
 			ret = (unsigned long) prog;
 			break;

net/sched/cls_bpf.c static void cls_bpf_walk(struct tcf_proto *tp, struct tcf_walker *arg) · line 340

Quoted 5 lines
net/sched/cls_bpf.c +1 -1
@@ -337,7 +337,7 @@ static void cls_bpf_walk(struct tcf_proto *tp, struct tcf_walker *arg)
 	struct cls_bpf_head *head = rtnl_dereference(tp->root);
 	struct cls_bpf_prog *prog;
 
-	list_for_each_entry_rcu(prog, &head->plist, link) {
+	list_for_each_entry(prog, &head->plist, link) {

We still need the _rcu here in the walk path. IIRC, this is called from the dump path and we hold no rtnl_lock there.

Quoted 10 lines
net/sched/cls_bpf.c +0 -0
 		if (arg->count < arg->skip)
 			goto skip;
 		if (arg->fn(tp, (unsigned long) prog, arg) < 0) {
Signature · 6 lines
1.9.3

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
maintainer
#10 lore raw

Re: [patch net-next 3/6] net_sched: cls_bpf: remove faulty use of list_for_each_entry_rcu

In reply to Jiri Pirko
Quoted 13 lines · Jiri Pirko

rcu variant is not correct here. The code is called by updater (rtnl lock is held), not by reader (no rcu_read_lock is held).

---
  net/sched/cls_bpf.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
net/sched/cls_bpf.c +0 -0
index cbfaf6f..d0de979 100644

net/sched/cls_bpf.c static unsigned long cls_bpf_get(struct tcf_proto *tp, u32 handle) · line 146

Quoted 7 lines
net/sched/cls_bpf.c +1 -1
@@ -141,7 +141,7 @@ static unsigned long cls_bpf_get(struct tcf_proto *tp, u32 handle)
  	if (head == NULL)
  		return 0UL;
 
-	list_for_each_entry_rcu(prog, &head->plist, link) {
+	list_for_each_entry(prog, &head->plist, link) {
  		if (prog->handle == handle) {
  			ret = (unsigned long) prog;

The above is ok i think - only one user space entrant at a time and datapath is not affected because no modification is happening.

net/sched/cls_bpf.c static void cls_bpf_walk(struct tcf_proto *tp, struct tcf_walker *arg) · line 343

Quoted 11 lines
net/sched/cls_bpf.c +1 -1
  			break;
@@ -337,7 +337,7 @@ static void cls_bpf_walk(struct tcf_proto *tp, struct tcf_walker *arg)
  	struct cls_bpf_head *head = rtnl_dereference(tp->root);
  	struct cls_bpf_prog *prog;
 
-	list_for_each_entry_rcu(prog, &head->plist, link) {
+	list_for_each_entry(prog, &head->plist, link) {
  		if (arg->count < arg->skip)
  			goto skip;
  		if (arg->fn(tp, (unsigned long) prog, arg) < 0) {

I think this may be problematic. Doesnt a flush operation also use the walker?

cheers,
jamal

maintainer
#17 lore raw

Re: [patch net-next 4/6] net_sched: cls_flow: remove faulty use of list_for_each_entry_rcu

In reply to Jiri Pirko
Quoted 4 lines · Jiri Pirko

rcu variant is not correct here. The code is called by updater (rtnl lock is held), not by reader (no rcu_read_lock is held).

Same comment as other one..
I actually i am not so sure about the get_ either. The core may end up invoking that first before doing a del so for consistency we need rcu version.

cheers,
jamal

maintainer
#20 lore raw

Re: [patch net-next 6/6] net_sched: cls_cgroup: remove unnecessary if

In reply to Jiri Pirko
Quoted 12 lines · Jiri Pirko

since head->handle == handle (checked before), just assign handle.

---
  net/sched/cls_cgroup.c | 6 +-----
  1 file changed, 1 insertion(+), 5 deletions(-)
net/sched/cls_cgroup.c +0 -0
index d61a801..dbee65e 100644

net/sched/cls_cgroup.c static int cls_cgroup_change(struct net *net, struct sk_buff *in_skb, · line 120

Quoted 9 lines
net/sched/cls_cgroup.c +1 -5
@@ -117,11 +117,7 @@ static int cls_cgroup_change(struct net *net, struct sk_buff *in_skb,
  		return -ENOBUFS;
 
  	tcf_exts_init(&new->exts, TCA_CGROUP_ACT, TCA_CGROUP_POLICE);
-	if (head)
-		new->handle = head->handle;
-	else
-		new->handle = handle;
-
+	new->handle = handle;

Hrm. head could be NULL, no?

cheers,
jamal

author maintainer
#21 lore raw

Re: [patch net-next 6/6] net_sched: cls_cgroup: remove unnecessary if

Quoted 15 lines · Wed, Dec 03, 2014 at 02:07:06PM CET, [email protected] wrote:
Quoted 14 lines · Jiri Pirko

since head->handle == handle (checked before), just assign handle.

---
 net/sched/cls_cgroup.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
net/sched/cls_cgroup.c +0 -0
index d61a801..dbee65e 100644
@@ -117,11 +117,7 @@ static int cls_cgroup_change(struct net *net, struct sk_buff *in_skb,
 		return -ENOBUFS;
 
Quoted 10 lines

net/sched/cls_cgroup.c static int cls_cgroup_change(struct net *net, struct sk_buff *in_skb, · line 120

Quoted 7 lines
net/sched/cls_cgroup.c +1 -5
 	tcf_exts_init(&new->exts, TCA_CGROUP_ACT, TCA_CGROUP_POLICE);
-	if (head)
-		new->handle = head->handle;
-	else
-		new->handle = handle;
-
+	new->handle = handle;

Hrm. head could be NULL, no?

Sure it can. But that is not a problem. Not sure what you are trying to point at...

Quoted 4 lines

cheers,
jamal

author maintainer
#8 lore raw

Re: [patch net-next 3/6] net_sched: cls_bpf: remove faulty use of list_for_each_entry_rcu

In reply to Pablo Neira Ayuso
Quoted 26 lines · Wed, Dec 03, 2014 at 01:19:49PM CET, [email protected] wrote:
Quoted 25 lines · Jiri Pirko

rcu variant is not correct here. The code is called by updater (rtnl lock is held), not by reader (no rcu_read_lock is held).

---
 net/sched/cls_bpf.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/sched/cls_bpf.c +1 -1
index cbfaf6f..d0de979 100644
@@ -141,7 +141,7 @@ static unsigned long cls_bpf_get(struct tcf_proto *tp, u32 handle)
 	if (head == NULL)
 		return 0UL;
 
-	list_for_each_entry_rcu(prog, &head->plist, link) {
+	list_for_each_entry(prog, &head->plist, link) {
 		if (prog->handle == handle) {
 			ret = (unsigned long) prog;
 			break;
@@ -337,7 +337,7 @@ static void cls_bpf_walk(struct tcf_proto *tp, struct tcf_walker *arg)
 	struct cls_bpf_head *head = rtnl_dereference(tp->root);
 	struct cls_bpf_prog *prog;
 
Quoted 5 lines

net/sched/cls_bpf.c static void cls_bpf_walk(struct tcf_proto *tp, struct tcf_walker *arg) · line 340

Quoted 2 lines
net/sched/cls_bpf.c +1 -1
-	list_for_each_entry_rcu(prog, &head->plist, link) {
+	list_for_each_entry(prog, &head->plist, link) {

We still need the _rcu here in the walk path. IIRC, this is called from the dump path and we hold no rtnl_lock there.

It is called from tc_dump_tfilter only. And tc_dump_tfilter is always called with rtnl_lock

Quoted 11 lines
Quoted 11 lines
net/sched/cls_bpf.c +0 -0
 		if (arg->count < arg->skip)
 			goto skip;
 		if (arg->fn(tp, (unsigned long) prog, arg) < 0) {
Signature · 6 lines
1.9.3

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
author maintainer
#11 lore raw

Re: [patch net-next 3/6] net_sched: cls_bpf: remove faulty use of list_for_each_entry_rcu

In reply to Jamal Hadi Salim
Quoted 30 lines · Wed, Dec 03, 2014 at 01:51:15PM CET, [email protected] wrote:
Quoted 13 lines · Jiri Pirko

rcu variant is not correct here. The code is called by updater (rtnl lock is held), not by reader (no rcu_read_lock is held).

---
 net/sched/cls_bpf.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/sched/cls_bpf.c +0 -0
index cbfaf6f..d0de979 100644

net/sched/cls_bpf.c static unsigned long cls_bpf_get(struct tcf_proto *tp, u32 handle) · line 146

Quoted 7 lines
net/sched/cls_bpf.c +1 -1
@@ -141,7 +141,7 @@ static unsigned long cls_bpf_get(struct tcf_proto *tp, u32 handle)
 	if (head == NULL)
 		return 0UL;
 
-	list_for_each_entry_rcu(prog, &head->plist, link) {
+	list_for_each_entry(prog, &head->plist, link) {
 		if (prog->handle == handle) {
 			ret = (unsigned long) prog;

The above is ok i think - only one user space entrant at a time and datapath is not affected because no modification is happening.

Quoted 5 lines
net/sched/cls_bpf.c +0 -0
 			break;
@@ -337,7 +337,7 @@ static void cls_bpf_walk(struct tcf_proto *tp, struct tcf_walker *arg)
 	struct cls_bpf_head *head = rtnl_dereference(tp->root);
 	struct cls_bpf_prog *prog;
 
Quoted 9 lines

net/sched/cls_bpf.c static void cls_bpf_walk(struct tcf_proto *tp, struct tcf_walker *arg) · line 343

Quoted 6 lines
net/sched/cls_bpf.c +1 -1
-	list_for_each_entry_rcu(prog, &head->plist, link) {
+	list_for_each_entry(prog, &head->plist, link) {
 		if (arg->count < arg->skip)
 			goto skip;
 		if (arg->fn(tp, (unsigned long) prog, arg) < 0) {

I think this may be problematic. Doesnt a flush operation also use the walker?

I don't believe so. Just look at tc_dump_tfilter.

But even if that would the the case, _rcu variant is wrong (yep, it would have to be replaced by _safe variant then).

Quoted 5 lines

cheers,
jamal

#9 lore raw

Re: [patch net-next 3/6] net_sched: cls_bpf: remove faulty use of list_for_each_entry_rcu

In reply to Jiri Pirko
Quoted 27 lines · Jiri Pirko
Quoted 26 lines · Wed, Dec 03, 2014 at 01:19:49PM CET, [email protected] wrote:
Quoted 25 lines · Jiri Pirko

rcu variant is not correct here. The code is called by updater (rtnl lock is held), not by reader (no rcu_read_lock is held).

---
 net/sched/cls_bpf.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/sched/cls_bpf.c +1 -1
index cbfaf6f..d0de979 100644
@@ -141,7 +141,7 @@ static unsigned long cls_bpf_get(struct tcf_proto *tp, u32 handle)
 	if (head == NULL)
 		return 0UL;
 
-	list_for_each_entry_rcu(prog, &head->plist, link) {
+	list_for_each_entry(prog, &head->plist, link) {
 		if (prog->handle == handle) {
 			ret = (unsigned long) prog;
 			break;
@@ -337,7 +337,7 @@ static void cls_bpf_walk(struct tcf_proto *tp, struct tcf_walker *arg)
 	struct cls_bpf_head *head = rtnl_dereference(tp->root);
 	struct cls_bpf_prog *prog;
 
Quoted 8 lines
Quoted 5 lines

net/sched/cls_bpf.c static void cls_bpf_walk(struct tcf_proto *tp, struct tcf_walker *arg) · line 340

Quoted 2 lines
net/sched/cls_bpf.c +1 -1
-	list_for_each_entry_rcu(prog, &head->plist, link) {
+	list_for_each_entry(prog, &head->plist, link) {

We still need the _rcu here in the walk path. IIRC, this is called from the dump path and we hold no rtnl_lock there.

It is called from tc_dump_tfilter only. And tc_dump_tfilter is always called with rtnl_lock

Right, nlk->cb_mutex is set to rtnl_lock so netlink_dump() grabs it for each recvmsg() invocation.

Reviewed-by on the v1 series
#24 lore raw
In reply to Jiri Pirko
Quoted 7 lines · Jiri Pirko

Jiri Pirko (6):
net_sched: cls_basic: remove unnecessary iteration and use passed arg
net_sched: cls_bpf: remove unnecessary iteration and use passed arg
net_sched: cls_bpf: remove faulty use of list_for_each_entry_rcu
net_sched: cls_flow: remove faulty use of list_for_each_entry_rcu
net_sched: cls_flow: remove duplicate assignments
net_sched: cls_cgroup: remove unnecessary if

Looks sane. RCU is obviously not needed as all cls_api calls are holding RTNL by now.

maintainer Acked-by
#22 lore raw

Re: [patch net-next 6/6] net_sched: cls_cgroup: remove unnecessary if

In reply to Jiri Pirko
Quoted 6 lines · Jiri Pirko
Quoted 2 lines

Hrm. head could be NULL, no?

Sure it can. But that is not a problem. Not sure what you are trying to point at...

I suppose head->handle MUST always be equal to handle for the change to work. So doesnt matter if handle is null or not. Too clever for me.

cheers,
jamal

maintainer
#12 lore raw

Re: [patch net-next 3/6] net_sched: cls_bpf: remove faulty use of list_for_each_entry_rcu

In reply to Jiri Pirko
Quoted 7 lines · Jiri Pirko
Quoted 2 lines · Wed, Dec 03, 2014 at 01:51:15PM CET, [email protected] wrote:

I think this may be problematic. Doesnt a flush operation also use the walker?

I don't believe so. Just look at tc_dump_tfilter.

Actually we cant flush filters (we could actions).

Quoted 3 lines

But even if that would the the case, _rcu variant is wrong (yep, it would have to be replaced by _safe variant then).

Sorry, still humping on the get part:
that gets invoked for del for a filter that may be in use in the datapath. del uses rcu - should get not use rcu in such a case?

cheers,
jamal

author maintainer
#23 lore raw

Re: [patch net-next 6/6] net_sched: cls_cgroup: remove unnecessary if

In reply to Jamal Hadi Salim
Quoted 11 lines · Wed, Dec 03, 2014 at 03:30:48PM CET, [email protected] wrote:
Quoted 6 lines · Jiri Pirko
Quoted 2 lines

Hrm. head could be NULL, no?

Sure it can. But that is not a problem. Not sure what you are trying to point at...

I suppose head->handle MUST always be equal to handle for the change to work. So doesnt matter if handle is null or not. Too clever for me.

Exactly. That is what I tried to say in patch desc :)

Quoted 5 lines

cheers,
jamal

author maintainer
#13 lore raw

Re: [patch net-next 3/6] net_sched: cls_bpf: remove faulty use of list_for_each_entry_rcu

In reply to Jamal Hadi Salim
Quoted 11 lines · Wed, Dec 03, 2014 at 03:37:46PM CET, [email protected] wrote:
Quoted 7 lines · Jiri Pirko
Quoted 2 lines · Wed, Dec 03, 2014 at 01:51:15PM CET, [email protected] wrote:

I think this may be problematic. Doesnt a flush operation also use the walker?

I don't believe so. Just look at tc_dump_tfilter.

Actually we cant flush filters (we could actions).

Quoted 7 lines
Quoted 3 lines

But even if that would the the case, _rcu variant is wrong (yep, it would have to be replaced by _safe variant then).

Sorry, still humping on the get part:
that gets invoked for del for a filter that may be in use in the datapath. del uses rcu - should get not use rcu in such a case?

Yep, but this is updater, protected by rtnl. _rcu list travelsal variant should be used by reader only (classify callback in cls case).

get op is only called from tc_ctl_tfilter which is always called with rtnl held.

Quoted 3 lines

cheers,
jamal

maintainer Acked-by
#14 lore raw

Re: [patch net-next 3/6] net_sched: cls_bpf: remove faulty use of list_for_each_entry_rcu

Quoted 9 lines · Jiri Pirko

Wed, Dec 03, 2014 at 03:37:46PM CET, [email protected] wrote:

Yep, but this is updater, protected by rtnl. _rcu list travelsal variant should be used by reader only (classify callback in cls case).

get op is only called from tc_ctl_tfilter which is always called with rtnl held.

I am not an rcu officionado. So if the control path is doing a non-rcu get + rcu-del/change (update) then as long as the fastpath is (read) rcu locking we are fine and nothing will actually happen until the fastpath releases and rcu grace period ends, correct?
In which case please accept my:

cheers,
jamal

#15 lore raw

Re: [patch net-next 3/6] net_sched: cls_bpf: remove faulty use of list_for_each_entry_rcu

On 12/03/2014 10:15 PM, Jamal Hadi Salim wrote:
...

Quoted 4 lines

I am not an rcu officionado. So if the control path is doing a non-rcu get + rcu-del/change (update) then as long as the fastpath is (read) rcu locking we are fine and nothing will actually happen until the fastpath releases and rcu grace period ends, correct?

So if the control path does a list_del_rcu() and call_rcu() under lock and iterates over list_for_each_entry{,safe}() [which we do in cls_bpf_delete()], while the fast path [cls_bpf_classify()] uses a rcu_read_{un,}lock() with *_rcu list iterator, that's fine then, as it's still guaranteed to be deleted after the grace period. So Jiri's change looks good to me.

maintainer
#25 lore raw
In reply to Jiri Pirko

From: Jiri Pirko <[email protected]>
Date: Tue, 2 Dec 2014 18:00:30 +0100

Quoted 7 lines

Jiri Pirko (6):
net_sched: cls_basic: remove unnecessary iteration and use passed arg
net_sched: cls_bpf: remove unnecessary iteration and use passed arg
net_sched: cls_bpf: remove faulty use of list_for_each_entry_rcu
net_sched: cls_flow: remove faulty use of list_for_each_entry_rcu
net_sched: cls_flow: remove duplicate assignments
net_sched: cls_cgroup: remove unnecessary if

Series applied, thanks Jiri.