* [PATCH][NET_SCHED] cls_u32: refcounting fix for u32_delete()
@ 2008-04-11 12:45 Jarek Poplawski
2008-04-11 12:55 ` Patrick McHardy
0 siblings, 1 reply; 8+ messages in thread
From: Jarek Poplawski @ 2008-04-11 12:45 UTC (permalink / raw)
To: David Miller; +Cc: Jamal Hadi Salim, netdev
[NET_SCHED] cls_u32: refcounting fix for u32_delete()
Deleting of nonroot hnodes mostly doesn't work in u32_delete():
refcnt == 1 is expected, but such hnodes' refcnts are initialized
with 0 and charged only with "link" nodes. Now they'll start with
1 like usual.
Signed-off-by: Jarek Poplawski <jarkao2@gmail.com>
Cc: Jamal Hadi Salim <hadi@cyberus.ca>
---
net/sched/cls_u32.c | 10 +++++++---
1 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c
index c5c16b4..4f150b9 100644
--- a/net/sched/cls_u32.c
+++ b/net/sched/cls_u32.c
@@ -411,8 +411,10 @@ static void u32_destroy(struct tcf_proto *tp)
}
}
- for (ht=tp_c->hlist; ht; ht = ht->next)
+ for (ht = tp_c->hlist; ht; ht = ht->next) {
+ ht->refcnt--;
u32_clear_hnode(tp, ht);
+ }
while ((ht = tp_c->hlist) != NULL) {
tp_c->hlist = ht->next;
@@ -441,8 +443,10 @@ static int u32_delete(struct tcf_proto *tp, unsigned long arg)
if (tp->root == ht)
return -EINVAL;
- if (--ht->refcnt == 0)
+ if (ht->refcnt == 1) {
+ ht->refcnt--;
u32_destroy_hnode(tp, ht);
+ }
return 0;
}
@@ -568,7 +572,7 @@ static int u32_change(struct tcf_proto *tp, unsigned long base, u32 handle,
if (ht == NULL)
return -ENOBUFS;
ht->tp_c = tp_c;
- ht->refcnt = 0;
+ ht->refcnt = 1;
ht->divisor = divisor;
ht->handle = handle;
ht->prio = tp->prio;
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH][NET_SCHED] cls_u32: refcounting fix for u32_delete()
2008-04-11 12:45 [PATCH][NET_SCHED] cls_u32: refcounting fix for u32_delete() Jarek Poplawski
@ 2008-04-11 12:55 ` Patrick McHardy
2008-04-11 13:23 ` Jarek Poplawski
0 siblings, 1 reply; 8+ messages in thread
From: Patrick McHardy @ 2008-04-11 12:55 UTC (permalink / raw)
To: Jarek Poplawski; +Cc: David Miller, Jamal Hadi Salim, netdev
Jarek Poplawski wrote:
> [NET_SCHED] cls_u32: refcounting fix for u32_delete()
>
> @@ -441,8 +443,10 @@ static int u32_delete(struct tcf_proto *tp, unsigned long arg)
> if (tp->root == ht)
> return -EINVAL;
>
> - if (--ht->refcnt == 0)
> + if (ht->refcnt == 1) {
> + ht->refcnt--;
> u32_destroy_hnode(tp, ht);
> + }
>
Shouldn't the refcount be decremented unconditionally?
Otherwise I'd suggest to reject the removal if refcnt > 1,
but silently doing nothing doesn't seem right.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH][NET_SCHED] cls_u32: refcounting fix for u32_delete()
2008-04-11 13:23 ` Jarek Poplawski
@ 2008-04-11 13:22 ` Patrick McHardy
2008-04-11 13:48 ` [PATCH take2][NET_SCHED] " Jarek Poplawski
0 siblings, 1 reply; 8+ messages in thread
From: Patrick McHardy @ 2008-04-11 13:22 UTC (permalink / raw)
To: Jarek Poplawski; +Cc: David Miller, Jamal Hadi Salim, netdev
Jarek Poplawski wrote:
> On Fri, Apr 11, 2008 at 02:55:27PM +0200, Patrick McHardy wrote:
>> Jarek Poplawski wrote:
>>> [NET_SCHED] cls_u32: refcounting fix for u32_delete()
>>>
>>> @@ -441,8 +443,10 @@ static int u32_delete(struct tcf_proto *tp, unsigned long arg)
>>> if (tp->root == ht)
>>> return -EINVAL;
>>> - if (--ht->refcnt == 0)
>>> + if (ht->refcnt == 1) {
>>> + ht->refcnt--;
>>> u32_destroy_hnode(tp, ht);
>>> + }
>>>
>> Shouldn't the refcount be decremented unconditionally?
>> Otherwise I'd suggest to reject the removal if refcnt > 1,
>> but silently doing nothing doesn't seem right.
>
> If someone tries deleting and the refcnt is e.g. 3 (2 links)
> unconditional deleting could decrease refcnt without deleting
> and then unlinking would make it below 0. I think it's OK now:
> we can't delete hnode until it's referenced, but I could add
> a warning if you like?
I'd suggest to behave similar to qdiscs when trying to
removing classes that are still referenced, return -EBUSY.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH][NET_SCHED] cls_u32: refcounting fix for u32_delete()
2008-04-11 12:55 ` Patrick McHardy
@ 2008-04-11 13:23 ` Jarek Poplawski
2008-04-11 13:22 ` Patrick McHardy
0 siblings, 1 reply; 8+ messages in thread
From: Jarek Poplawski @ 2008-04-11 13:23 UTC (permalink / raw)
To: Patrick McHardy; +Cc: David Miller, Jamal Hadi Salim, netdev
On Fri, Apr 11, 2008 at 02:55:27PM +0200, Patrick McHardy wrote:
> Jarek Poplawski wrote:
>> [NET_SCHED] cls_u32: refcounting fix for u32_delete()
>>
>> @@ -441,8 +443,10 @@ static int u32_delete(struct tcf_proto *tp, unsigned long arg)
>> if (tp->root == ht)
>> return -EINVAL;
>> - if (--ht->refcnt == 0)
>> + if (ht->refcnt == 1) {
>> + ht->refcnt--;
>> u32_destroy_hnode(tp, ht);
>> + }
>>
>
> Shouldn't the refcount be decremented unconditionally?
> Otherwise I'd suggest to reject the removal if refcnt > 1,
> but silently doing nothing doesn't seem right.
If someone tries deleting and the refcnt is e.g. 3 (2 links)
unconditional deleting could decrease refcnt without deleting
and then unlinking would make it below 0. I think it's OK now:
we can't delete hnode until it's referenced, but I could add
a warning if you like?
Thanks,
Jarek P.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH take2][NET_SCHED] cls_u32: refcounting fix for u32_delete()
2008-04-11 13:22 ` Patrick McHardy
@ 2008-04-11 13:48 ` Jarek Poplawski
2008-04-11 13:55 ` jamal
2008-04-11 14:00 ` Patrick McHardy
0 siblings, 2 replies; 8+ messages in thread
From: Jarek Poplawski @ 2008-04-11 13:48 UTC (permalink / raw)
To: Patrick McHardy; +Cc: David Miller, Jamal Hadi Salim, netdev
On Fri, Apr 11, 2008 at 03:22:51PM +0200, Patrick McHardy wrote:
...
> I'd suggest to behave similar to qdiscs when trying to
> removing classes that are still referenced, return -EBUSY.
Of course you are right!
Jarek P.
-------------------> (take 2)
[NET_SCHED] cls_u32: refcounting fix for u32_delete()
Deleting of nonroot hnodes mostly doesn't work in u32_delete():
refcnt == 1 is expected, but such hnodes' refcnts are initialized
with 0 and charged only with "link" nodes. Now they'll start with
1 like usual. Thanks to Patrick McHardy for an improving suggestion.
Signed-off-by: Jarek Poplawski <jarkao2@gmail.com>
Cc: Jamal Hadi Salim <hadi@cyberus.ca>
---
diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c
index c5c16b4..4d75544 100644
--- a/net/sched/cls_u32.c
+++ b/net/sched/cls_u32.c
@@ -411,8 +411,10 @@ static void u32_destroy(struct tcf_proto *tp)
}
}
- for (ht=tp_c->hlist; ht; ht = ht->next)
+ for (ht = tp_c->hlist; ht; ht = ht->next) {
+ ht->refcnt--;
u32_clear_hnode(tp, ht);
+ }
while ((ht = tp_c->hlist) != NULL) {
tp_c->hlist = ht->next;
@@ -441,8 +443,12 @@ static int u32_delete(struct tcf_proto *tp, unsigned long arg)
if (tp->root == ht)
return -EINVAL;
- if (--ht->refcnt == 0)
+ if (ht->refcnt == 1) {
+ ht->refcnt--;
u32_destroy_hnode(tp, ht);
+ } else {
+ return -EBUSY;
+ }
return 0;
}
@@ -568,7 +574,7 @@ static int u32_change(struct tcf_proto *tp, unsigned long base, u32 handle,
if (ht == NULL)
return -ENOBUFS;
ht->tp_c = tp_c;
- ht->refcnt = 0;
+ ht->refcnt = 1;
ht->divisor = divisor;
ht->handle = handle;
ht->prio = tp->prio;
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH take2][NET_SCHED] cls_u32: refcounting fix for u32_delete()
2008-04-11 13:48 ` [PATCH take2][NET_SCHED] " Jarek Poplawski
@ 2008-04-11 13:55 ` jamal
2008-04-13 1:37 ` David Miller
2008-04-11 14:00 ` Patrick McHardy
1 sibling, 1 reply; 8+ messages in thread
From: jamal @ 2008-04-11 13:55 UTC (permalink / raw)
To: Jarek Poplawski; +Cc: Patrick McHardy, David Miller, netdev
On Fri, 2008-11-04 at 13:48 +0000, Jarek Poplawski wrote:
> On Fri, Apr 11, 2008 at 03:22:51PM +0200, Patrick McHardy wrote:
> ...
> > I'd suggest to behave similar to qdiscs when trying to
> > removing classes that are still referenced, return -EBUSY.
>
> Of course you are right!
>
> Jarek P.
>
> -------------------> (take 2)
>
> [NET_SCHED] cls_u32: refcounting fix for u32_delete()
>
> Deleting of nonroot hnodes mostly doesn't work in u32_delete():
> refcnt == 1 is expected, but such hnodes' refcnts are initialized
> with 0 and charged only with "link" nodes. Now they'll start with
> 1 like usual. Thanks to Patrick McHardy for an improving suggestion.
>
>
> Signed-off-by: Jarek Poplawski <jarkao2@gmail.com>
> Cc: Jamal Hadi Salim <hadi@cyberus.ca>
Thanks as always Jarek.
Acked-by: Jamal Hadi Salim <hadi@cyberus.ca>
cheers,
jamal
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH take2][NET_SCHED] cls_u32: refcounting fix for u32_delete()
2008-04-11 13:48 ` [PATCH take2][NET_SCHED] " Jarek Poplawski
2008-04-11 13:55 ` jamal
@ 2008-04-11 14:00 ` Patrick McHardy
1 sibling, 0 replies; 8+ messages in thread
From: Patrick McHardy @ 2008-04-11 14:00 UTC (permalink / raw)
To: Jarek Poplawski; +Cc: David Miller, Jamal Hadi Salim, netdev
Jarek Poplawski wrote:
> [NET_SCHED] cls_u32: refcounting fix for u32_delete()
>
> Deleting of nonroot hnodes mostly doesn't work in u32_delete():
> refcnt == 1 is expected, but such hnodes' refcnts are initialized
> with 0 and charged only with "link" nodes. Now they'll start with
> 1 like usual. Thanks to Patrick McHardy for an improving suggestion.
Looks good, thanks Jarek.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH take2][NET_SCHED] cls_u32: refcounting fix for u32_delete()
2008-04-11 13:55 ` jamal
@ 2008-04-13 1:37 ` David Miller
0 siblings, 0 replies; 8+ messages in thread
From: David Miller @ 2008-04-13 1:37 UTC (permalink / raw)
To: hadi; +Cc: jarkao2, kaber, netdev
From: jamal <hadi@cyberus.ca>
Date: Fri, 11 Apr 2008 09:55:27 -0400
> On Fri, 2008-11-04 at 13:48 +0000, Jarek Poplawski wrote:
> > On Fri, Apr 11, 2008 at 03:22:51PM +0200, Patrick McHardy wrote:
> > ...
> > > I'd suggest to behave similar to qdiscs when trying to
> > > removing classes that are still referenced, return -EBUSY.
> >
> > Of course you are right!
> >
> > Jarek P.
> >
> > -------------------> (take 2)
> >
> > [NET_SCHED] cls_u32: refcounting fix for u32_delete()
> >
> > Deleting of nonroot hnodes mostly doesn't work in u32_delete():
> > refcnt == 1 is expected, but such hnodes' refcnts are initialized
> > with 0 and charged only with "link" nodes. Now they'll start with
> > 1 like usual. Thanks to Patrick McHardy for an improving suggestion.
> >
> >
> > Signed-off-by: Jarek Poplawski <jarkao2@gmail.com>
> > Cc: Jamal Hadi Salim <hadi@cyberus.ca>
>
> Thanks as always Jarek.
>
> Acked-by: Jamal Hadi Salim <hadi@cyberus.ca>
Applied, thanks everyone.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2008-04-13 1:37 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-11 12:45 [PATCH][NET_SCHED] cls_u32: refcounting fix for u32_delete() Jarek Poplawski
2008-04-11 12:55 ` Patrick McHardy
2008-04-11 13:23 ` Jarek Poplawski
2008-04-11 13:22 ` Patrick McHardy
2008-04-11 13:48 ` [PATCH take2][NET_SCHED] " Jarek Poplawski
2008-04-11 13:55 ` jamal
2008-04-13 1:37 ` David Miller
2008-04-11 14:00 ` Patrick McHardy
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).