* [PATCH net] xfrm: Delete hold_timer when destroy policy
@ 2013-08-01 10:08 Fan Du
2013-08-01 12:01 ` Steffen Klassert
0 siblings, 1 reply; 4+ messages in thread
From: Fan Du @ 2013-08-01 10:08 UTC (permalink / raw)
To: steffen.klassert; +Cc: davem, netdev
Both policy timer and hold_timer need to be deleted when destroy policy
Bad mood today, maybe I'm wrong about this...
Signed-off-by: Fan Du <fan.du@windriver.com>
---
net/xfrm/xfrm_policy.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index d8da6b8..f7078eb 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -308,7 +308,7 @@ void xfrm_policy_destroy(struct xfrm_policy *policy)
{
BUG_ON(!policy->walk.dead);
- if (del_timer(&policy->timer))
+ if (del_timer(&policy->timer) || del_timer(&policy->polq.hold_timer))
BUG();
security_xfrm_policy_free(policy->security);
--
1.7.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH net] xfrm: Delete hold_timer when destroy policy
2013-08-01 10:08 [PATCH net] xfrm: Delete hold_timer when destroy policy Fan Du
@ 2013-08-01 12:01 ` Steffen Klassert
2013-08-02 1:22 ` Fan Du
0 siblings, 1 reply; 4+ messages in thread
From: Steffen Klassert @ 2013-08-01 12:01 UTC (permalink / raw)
To: Fan Du; +Cc: davem, netdev
On Thu, Aug 01, 2013 at 06:08:36PM +0800, Fan Du wrote:
> Both policy timer and hold_timer need to be deleted when destroy policy
> Bad mood today, maybe I'm wrong about this...
>
> Signed-off-by: Fan Du <fan.du@windriver.com>
> ---
> net/xfrm/xfrm_policy.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
> index d8da6b8..f7078eb 100644
> --- a/net/xfrm/xfrm_policy.c
> +++ b/net/xfrm/xfrm_policy.c
> @@ -308,7 +308,7 @@ void xfrm_policy_destroy(struct xfrm_policy *policy)
> {
> BUG_ON(!policy->walk.dead);
>
> - if (del_timer(&policy->timer))
> + if (del_timer(&policy->timer) || del_timer(&policy->polq.hold_timer))
> BUG();
>
The timers should be already deleted when xfrm_policy_destroy() is
called. This is just to check if that really happened and to
catch this bug if not. So it's not a bug fix, it just helps to
catch a potential bug. I'll consider to take this into ipsec-next
after some testing.
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH net] xfrm: Delete hold_timer when destroy policy
2013-08-01 12:01 ` Steffen Klassert
@ 2013-08-02 1:22 ` Fan Du
2013-08-06 8:05 ` Steffen Klassert
0 siblings, 1 reply; 4+ messages in thread
From: Fan Du @ 2013-08-02 1:22 UTC (permalink / raw)
To: Steffen Klassert; +Cc: davem, netdev
On 2013年08月01日 20:01, Steffen Klassert wrote:
> On Thu, Aug 01, 2013 at 06:08:36PM +0800, Fan Du wrote:
>> Both policy timer and hold_timer need to be deleted when destroy policy
>> Bad mood today, maybe I'm wrong about this...
>>
>> Signed-off-by: Fan Du<fan.du@windriver.com>
>> ---
>> net/xfrm/xfrm_policy.c | 2 +-
>> 1 files changed, 1 insertions(+), 1 deletions(-)
>>
>> diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
>> index d8da6b8..f7078eb 100644
>> --- a/net/xfrm/xfrm_policy.c
>> +++ b/net/xfrm/xfrm_policy.c
>> @@ -308,7 +308,7 @@ void xfrm_policy_destroy(struct xfrm_policy *policy)
>> {
>> BUG_ON(!policy->walk.dead);
>>
>> - if (del_timer(&policy->timer))
>> + if (del_timer(&policy->timer) || del_timer(&policy->polq.hold_timer))
>> BUG();
>>
>
> The timers should be already deleted when xfrm_policy_destroy() is
> called. This is just to check if that really happened and to
> catch this bug if not. So it's not a bug fix, it just helps to
> catch a potential bug. I'll consider to take this into ipsec-next
> after some testing.
>
On the contrary, please take a look at callers of xfrm_policy_destroy.
Code flow is as below:
xfrm_policy_alloc() /* setup timer/hold_timer here */ (1)
/* do something with this policy, insert or something else */
goto err; /* bail out if bad things happens */
return ok
err:
xfrm_policy_destroy() /*So both timers in (1) need to be deleted */
--
浮沉随浪只记今朝笑
--fan
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH net] xfrm: Delete hold_timer when destroy policy
2013-08-02 1:22 ` Fan Du
@ 2013-08-06 8:05 ` Steffen Klassert
0 siblings, 0 replies; 4+ messages in thread
From: Steffen Klassert @ 2013-08-06 8:05 UTC (permalink / raw)
To: Fan Du; +Cc: davem, netdev
On Fri, Aug 02, 2013 at 09:22:08AM +0800, Fan Du wrote:
>
>
> On 2013年08月01日 20:01, Steffen Klassert wrote:
> >On Thu, Aug 01, 2013 at 06:08:36PM +0800, Fan Du wrote:
> >>Both policy timer and hold_timer need to be deleted when destroy policy
> >>Bad mood today, maybe I'm wrong about this...
> >>
> >>Signed-off-by: Fan Du<fan.du@windriver.com>
> >>---
> >> net/xfrm/xfrm_policy.c | 2 +-
> >> 1 files changed, 1 insertions(+), 1 deletions(-)
> >>
> >>diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
> >>index d8da6b8..f7078eb 100644
> >>--- a/net/xfrm/xfrm_policy.c
> >>+++ b/net/xfrm/xfrm_policy.c
> >>@@ -308,7 +308,7 @@ void xfrm_policy_destroy(struct xfrm_policy *policy)
> >> {
> >> BUG_ON(!policy->walk.dead);
> >>
> >>- if (del_timer(&policy->timer))
> >>+ if (del_timer(&policy->timer) || del_timer(&policy->polq.hold_timer))
> >> BUG();
> >>
> >
> >The timers should be already deleted when xfrm_policy_destroy() is
> >called. This is just to check if that really happened and to
> >catch this bug if not. So it's not a bug fix, it just helps to
> >catch a potential bug. I'll consider to take this into ipsec-next
> >after some testing.
> >
>
> On the contrary, please take a look at callers of xfrm_policy_destroy.
> Code flow is as below:
>
> xfrm_policy_alloc() /* setup timer/hold_timer here */ (1)
>
> /* do something with this policy, insert or something else */
>
> goto err; /* bail out if bad things happens */
>
> return ok
>
> err:
> xfrm_policy_destroy() /*So both timers in (1) need to be deleted */
>
setup_timer() does not arm the timer, it just initializes the timer.
So the timer is not pending when xfrm_policy_destroy() is called
on error. The del_timer() in xfrm_policy_destroy() is really just
to catch a bug. That's also the reason why we call BUG() if we
delete a pending timer.
Anyway, applied to ipsec-next.
Thanks!
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-08-06 8:05 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-01 10:08 [PATCH net] xfrm: Delete hold_timer when destroy policy Fan Du
2013-08-01 12:01 ` Steffen Klassert
2013-08-02 1:22 ` Fan Du
2013-08-06 8:05 ` Steffen Klassert
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).