Commit 7e184235 authored by James Morris's avatar James Morris Committed by David S. Miller

[XFRM]: Use xfrm_pol_hold().

parent 4ebb54ba
...@@ -336,7 +336,7 @@ extern struct xfrm_policy *xfrm_policy_list[XFRM_POLICY_MAX*2]; ...@@ -336,7 +336,7 @@ extern struct xfrm_policy *xfrm_policy_list[XFRM_POLICY_MAX*2];
static inline void xfrm_pol_hold(struct xfrm_policy *policy) static inline void xfrm_pol_hold(struct xfrm_policy *policy)
{ {
if (policy) if (likely(policy))
atomic_inc(&policy->refcnt); atomic_inc(&policy->refcnt);
} }
......
...@@ -100,7 +100,7 @@ struct xfrm_policy *flow_lookup(int dir, struct flowi *fl, ...@@ -100,7 +100,7 @@ struct xfrm_policy *flow_lookup(int dir, struct flowi *fl,
fle->dir == dir) { fle->dir == dir) {
if (fle->genid == xfrm_policy_genid) { if (fle->genid == xfrm_policy_genid) {
if ((pol = fle->pol) != NULL) if ((pol = fle->pol) != NULL)
atomic_inc(&pol->refcnt); xfrm_pol_hold(pol);
local_bh_enable(); local_bh_enable();
return pol; return pol;
} }
...@@ -118,7 +118,7 @@ struct xfrm_policy *flow_lookup(int dir, struct flowi *fl, ...@@ -118,7 +118,7 @@ struct xfrm_policy *flow_lookup(int dir, struct flowi *fl,
xfrm_pol_put(fle->pol); xfrm_pol_put(fle->pol);
fle->pol = pol; fle->pol = pol;
if (pol) if (pol)
atomic_inc(&pol->refcnt); xfrm_pol_hold(pol);
} else { } else {
if (flow_count(cpu) > flow_hwm) if (flow_count(cpu) > flow_hwm)
flow_cache_shrink(cpu); flow_cache_shrink(cpu);
...@@ -131,7 +131,7 @@ struct xfrm_policy *flow_lookup(int dir, struct flowi *fl, ...@@ -131,7 +131,7 @@ struct xfrm_policy *flow_lookup(int dir, struct flowi *fl,
fle->dir = dir; fle->dir = dir;
fle->pol = pol; fle->pol = pol;
if (pol) if (pol)
atomic_inc(&pol->refcnt); xfrm_pol_hold(pol);
fle->next = flow_table[cpu*XFRM_FLOWCACHE_HASH_SIZE+hash]; fle->next = flow_table[cpu*XFRM_FLOWCACHE_HASH_SIZE+hash];
flow_table[cpu*XFRM_FLOWCACHE_HASH_SIZE+hash] = fle; flow_table[cpu*XFRM_FLOWCACHE_HASH_SIZE+hash] = fle;
} }
...@@ -274,7 +274,7 @@ static void xfrm_policy_timer(unsigned long data) ...@@ -274,7 +274,7 @@ static void xfrm_policy_timer(unsigned long data)
} }
if (next != LONG_MAX && if (next != LONG_MAX &&
!mod_timer(&xp->timer, jiffies + make_jiffies(next))) !mod_timer(&xp->timer, jiffies + make_jiffies(next)))
atomic_inc(&xp->refcnt); xfrm_pol_hold(xp);
out: out:
xfrm_pol_put(xp); xfrm_pol_put(xp);
...@@ -392,7 +392,7 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl) ...@@ -392,7 +392,7 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl)
break; break;
} }
} }
atomic_inc(&policy->refcnt); xfrm_pol_hold(policy);
policy->next = pol ? pol->next : NULL; policy->next = pol ? pol->next : NULL;
*p = policy; *p = policy;
xfrm_policy_genid++; xfrm_policy_genid++;
...@@ -401,7 +401,7 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl) ...@@ -401,7 +401,7 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl)
policy->curlft.use_time = 0; policy->curlft.use_time = 0;
if (policy->lft.hard_add_expires_seconds && if (policy->lft.hard_add_expires_seconds &&
!mod_timer(&policy->timer, jiffies + HZ)) !mod_timer(&policy->timer, jiffies + HZ))
atomic_inc(&policy->refcnt); xfrm_pol_hold(policy);
write_unlock_bh(&xfrm_policy_lock); write_unlock_bh(&xfrm_policy_lock);
if (pol) { if (pol) {
...@@ -445,7 +445,7 @@ struct xfrm_policy *xfrm_policy_byid(int dir, u32 id, int delete) ...@@ -445,7 +445,7 @@ struct xfrm_policy *xfrm_policy_byid(int dir, u32 id, int delete)
if (delete) if (delete)
xfrm_policy_genid++; xfrm_policy_genid++;
else else
atomic_inc(&pol->refcnt); xfrm_pol_hold(pol);
} }
write_unlock_bh(&xfrm_policy_lock); write_unlock_bh(&xfrm_policy_lock);
return pol; return pol;
...@@ -522,7 +522,7 @@ struct xfrm_policy *xfrm_policy_lookup(int dir, struct flowi *fl, ...@@ -522,7 +522,7 @@ struct xfrm_policy *xfrm_policy_lookup(int dir, struct flowi *fl,
match = xfrm_selector_match(sel, fl, family); match = xfrm_selector_match(sel, fl, family);
if (match) { if (match) {
atomic_inc(&pol->refcnt); xfrm_pol_hold(pol);
break; break;
} }
} }
...@@ -540,7 +540,7 @@ struct xfrm_policy *xfrm_sk_policy_lookup(struct sock *sk, int dir, struct flowi ...@@ -540,7 +540,7 @@ struct xfrm_policy *xfrm_sk_policy_lookup(struct sock *sk, int dir, struct flowi
match = xfrm_selector_match(&pol->selector, fl, sk->family); match = xfrm_selector_match(&pol->selector, fl, sk->family);
if (match) if (match)
atomic_inc(&pol->refcnt); xfrm_pol_hold(pol);
else else
pol = NULL; pol = NULL;
} }
...@@ -552,7 +552,7 @@ void xfrm_sk_policy_link(struct xfrm_policy *pol, int dir) ...@@ -552,7 +552,7 @@ void xfrm_sk_policy_link(struct xfrm_policy *pol, int dir)
{ {
pol->next = xfrm_policy_list[XFRM_POLICY_MAX+dir]; pol->next = xfrm_policy_list[XFRM_POLICY_MAX+dir];
xfrm_policy_list[XFRM_POLICY_MAX+dir] = pol; xfrm_policy_list[XFRM_POLICY_MAX+dir] = pol;
atomic_inc(&pol->refcnt); xfrm_pol_hold(pol);
} }
void xfrm_sk_policy_unlink(struct xfrm_policy *pol, int dir) void xfrm_sk_policy_unlink(struct xfrm_policy *pol, int dir)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment