diff options
Diffstat (limited to 'net/xfrm/xfrm_policy.c')
-rw-r--r-- | net/xfrm/xfrm_policy.c | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c index ed38d5d81f9e..76e1873811d4 100644 --- a/net/xfrm/xfrm_policy.c +++ b/net/xfrm/xfrm_policy.c | |||
@@ -334,7 +334,8 @@ static void xfrm_policy_kill(struct xfrm_policy *policy) | |||
334 | 334 | ||
335 | atomic_inc(&policy->genid); | 335 | atomic_inc(&policy->genid); |
336 | 336 | ||
337 | del_timer(&policy->polq.hold_timer); | 337 | if (del_timer(&policy->polq.hold_timer)) |
338 | xfrm_pol_put(policy); | ||
338 | xfrm_queue_purge(&policy->polq.hold_queue); | 339 | xfrm_queue_purge(&policy->polq.hold_queue); |
339 | 340 | ||
340 | if (del_timer(&policy->timer)) | 341 | if (del_timer(&policy->timer)) |
@@ -589,7 +590,8 @@ static void xfrm_policy_requeue(struct xfrm_policy *old, | |||
589 | 590 | ||
590 | spin_lock_bh(&pq->hold_queue.lock); | 591 | spin_lock_bh(&pq->hold_queue.lock); |
591 | skb_queue_splice_init(&pq->hold_queue, &list); | 592 | skb_queue_splice_init(&pq->hold_queue, &list); |
592 | del_timer(&pq->hold_timer); | 593 | if (del_timer(&pq->hold_timer)) |
594 | xfrm_pol_put(old); | ||
593 | spin_unlock_bh(&pq->hold_queue.lock); | 595 | spin_unlock_bh(&pq->hold_queue.lock); |
594 | 596 | ||
595 | if (skb_queue_empty(&list)) | 597 | if (skb_queue_empty(&list)) |
@@ -600,7 +602,8 @@ static void xfrm_policy_requeue(struct xfrm_policy *old, | |||
600 | spin_lock_bh(&pq->hold_queue.lock); | 602 | spin_lock_bh(&pq->hold_queue.lock); |
601 | skb_queue_splice(&list, &pq->hold_queue); | 603 | skb_queue_splice(&list, &pq->hold_queue); |
602 | pq->timeout = XFRM_QUEUE_TMO_MIN; | 604 | pq->timeout = XFRM_QUEUE_TMO_MIN; |
603 | mod_timer(&pq->hold_timer, jiffies); | 605 | if (!mod_timer(&pq->hold_timer, jiffies)) |
606 | xfrm_pol_hold(new); | ||
604 | spin_unlock_bh(&pq->hold_queue.lock); | 607 | spin_unlock_bh(&pq->hold_queue.lock); |
605 | } | 608 | } |
606 | 609 | ||
@@ -1769,6 +1772,10 @@ static void xfrm_policy_queue_process(unsigned long arg) | |||
1769 | 1772 | ||
1770 | spin_lock(&pq->hold_queue.lock); | 1773 | spin_lock(&pq->hold_queue.lock); |
1771 | skb = skb_peek(&pq->hold_queue); | 1774 | skb = skb_peek(&pq->hold_queue); |
1775 | if (!skb) { | ||
1776 | spin_unlock(&pq->hold_queue.lock); | ||
1777 | goto out; | ||
1778 | } | ||
1772 | dst = skb_dst(skb); | 1779 | dst = skb_dst(skb); |
1773 | sk = skb->sk; | 1780 | sk = skb->sk; |
1774 | xfrm_decode_session(skb, &fl, dst->ops->family); | 1781 | xfrm_decode_session(skb, &fl, dst->ops->family); |
@@ -1787,8 +1794,9 @@ static void xfrm_policy_queue_process(unsigned long arg) | |||
1787 | goto purge_queue; | 1794 | goto purge_queue; |
1788 | 1795 | ||
1789 | pq->timeout = pq->timeout << 1; | 1796 | pq->timeout = pq->timeout << 1; |
1790 | mod_timer(&pq->hold_timer, jiffies + pq->timeout); | 1797 | if (!mod_timer(&pq->hold_timer, jiffies + pq->timeout)) |
1791 | return; | 1798 | xfrm_pol_hold(pol); |
1799 | goto out; | ||
1792 | } | 1800 | } |
1793 | 1801 | ||
1794 | dst_release(dst); | 1802 | dst_release(dst); |
@@ -1819,11 +1827,14 @@ static void xfrm_policy_queue_process(unsigned long arg) | |||
1819 | err = dst_output(skb); | 1827 | err = dst_output(skb); |
1820 | } | 1828 | } |
1821 | 1829 | ||
1830 | out: | ||
1831 | xfrm_pol_put(pol); | ||
1822 | return; | 1832 | return; |
1823 | 1833 | ||
1824 | purge_queue: | 1834 | purge_queue: |
1825 | pq->timeout = 0; | 1835 | pq->timeout = 0; |
1826 | xfrm_queue_purge(&pq->hold_queue); | 1836 | xfrm_queue_purge(&pq->hold_queue); |
1837 | xfrm_pol_put(pol); | ||
1827 | } | 1838 | } |
1828 | 1839 | ||
1829 | static int xdst_queue_output(struct sk_buff *skb) | 1840 | static int xdst_queue_output(struct sk_buff *skb) |
@@ -1831,7 +1842,8 @@ static int xdst_queue_output(struct sk_buff *skb) | |||
1831 | unsigned long sched_next; | 1842 | unsigned long sched_next; |
1832 | struct dst_entry *dst = skb_dst(skb); | 1843 | struct dst_entry *dst = skb_dst(skb); |
1833 | struct xfrm_dst *xdst = (struct xfrm_dst *) dst; | 1844 | struct xfrm_dst *xdst = (struct xfrm_dst *) dst; |
1834 | struct xfrm_policy_queue *pq = &xdst->pols[0]->polq; | 1845 | struct xfrm_policy *pol = xdst->pols[0]; |
1846 | struct xfrm_policy_queue *pq = &pol->polq; | ||
1835 | 1847 | ||
1836 | if (pq->hold_queue.qlen > XFRM_MAX_QUEUE_LEN) { | 1848 | if (pq->hold_queue.qlen > XFRM_MAX_QUEUE_LEN) { |
1837 | kfree_skb(skb); | 1849 | kfree_skb(skb); |
@@ -1850,10 +1862,12 @@ static int xdst_queue_output(struct sk_buff *skb) | |||
1850 | if (del_timer(&pq->hold_timer)) { | 1862 | if (del_timer(&pq->hold_timer)) { |
1851 | if (time_before(pq->hold_timer.expires, sched_next)) | 1863 | if (time_before(pq->hold_timer.expires, sched_next)) |
1852 | sched_next = pq->hold_timer.expires; | 1864 | sched_next = pq->hold_timer.expires; |
1865 | xfrm_pol_put(pol); | ||
1853 | } | 1866 | } |
1854 | 1867 | ||
1855 | __skb_queue_tail(&pq->hold_queue, skb); | 1868 | __skb_queue_tail(&pq->hold_queue, skb); |
1856 | mod_timer(&pq->hold_timer, sched_next); | 1869 | if (!mod_timer(&pq->hold_timer, sched_next)) |
1870 | xfrm_pol_hold(pol); | ||
1857 | 1871 | ||
1858 | spin_unlock_bh(&pq->hold_queue.lock); | 1872 | spin_unlock_bh(&pq->hold_queue.lock); |
1859 | 1873 | ||