On Mon, Oct 27, 2003 at 08:50:23PM +1100, herbert wrote: > On Mon, Oct 27, 2003 at 12:21:53AM -0800, David S. Miller wrote: > > > > The lists must hold a reference, as must socket sk_policy[] slots. > > It all comes down to what value you want to assign to a policy that's > only in a list and not being used by anything else. Perhaps you're objecting to the way the refcount is transfered from the caller of __xfrm_policy_link to the list. Here is patch which is technically equivalent to the previous one, but does it in a way more similar to how normal policies are inserted. Is this better? -- Debian GNU/Linux 3.0 is out! ( http://www.debian.org/ ) Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Index: kernel-source-2.5/net/xfrm/xfrm_policy.c =================================================================== RCS file: /home/gondolin/herbert/src/CVS/debian/kernel-source-2.5/net/xfrm/xfrm_policy.c,v retrieving revision 1.27 diff -u -r1.27 xfrm_policy.c --- kernel-source-2.5/net/xfrm/xfrm_policy.c 18 Oct 2003 03:09:04 -0000 1.27 +++ kernel-source-2.5/net/xfrm/xfrm_policy.c 27 Oct 2003 09:58:27 -0000 @@ -523,7 +523,6 @@ *polp != NULL; polp = &(*polp)->next) { if (*polp == pol) { *polp = pol->next; - atomic_dec(&pol->refcnt); return pol; } } @@ -579,6 +578,7 @@ write_lock_bh(&xfrm_policy_lock); __xfrm_policy_link(newp, XFRM_POLICY_MAX+dir); write_unlock_bh(&xfrm_policy_lock); + xfrm_pol_put(newp); } return newp; } Index: kernel-source-2.5/net/xfrm/xfrm_state.c =================================================================== RCS file: /home/gondolin/herbert/src/CVS/debian/kernel-source-2.5/net/xfrm/xfrm_state.c,v retrieving revision 1.10 diff -u -r1.10 xfrm_state.c --- kernel-source-2.5/net/xfrm/xfrm_state.c 3 Aug 2003 02:31:37 -0000 1.10 +++ kernel-source-2.5/net/xfrm/xfrm_state.c 27 Oct 2003 09:57:02 -0000 @@ -831,6 +831,7 @@ if (err >= 0) { xfrm_sk_policy_insert(sk, err, pol); + xfrm_pol_put(pol); err = 0; }