diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2010-05-21 00:04:44 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-05-21 00:04:44 -0400 |
commit | f8965467f366fd18f01feafb5db10512d7b4422c (patch) | |
tree | 3706a9cd779859271ca61b85c63a1bc3f82d626e /net/core/sock.c | |
parent | a26272e5200765691e67d6780e52b32498fdb659 (diff) | |
parent | 2ec8c6bb5d8f3a62a79f463525054bae1e3d4487 (diff) |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next-2.6: (1674 commits)
qlcnic: adding co maintainer
ixgbe: add support for active DA cables
ixgbe: dcb, do not tag tc_prio_control frames
ixgbe: fix ixgbe_tx_is_paused logic
ixgbe: always enable vlan strip/insert when DCB is enabled
ixgbe: remove some redundant code in setting FCoE FIP filter
ixgbe: fix wrong offset to fc_frame_header in ixgbe_fcoe_ddp
ixgbe: fix header len when unsplit packet overflows to data buffer
ipv6: Never schedule DAD timer on dead address
ipv6: Use POSTDAD state
ipv6: Use state_lock to protect ifa state
ipv6: Replace inet6_ifaddr->dead with state
cxgb4: notify upper drivers if the device is already up when they load
cxgb4: keep interrupts available when the ports are brought down
cxgb4: fix initial addition of MAC address
cnic: Return SPQ credit to bnx2x after ring setup and shutdown.
cnic: Convert cnic_local_flags to atomic ops.
can: Fix SJA1000 command register writes on SMP systems
bridge: fix build for CONFIG_SYSFS disabled
ARCNET: Limit com20020 PCI ID matches for SOHARD cards
...
Fix up various conflicts with pcmcia tree drivers/net/
{pcmcia/3c589_cs.c, wireless/orinoco/orinoco_cs.c and
wireless/orinoco/spectrum_cs.c} and feature removal
(Documentation/feature-removal-schedule.txt).
Also fix a non-content conflict due to pm_qos_requirement getting
renamed in the PM tree (now pm_qos_request) in net/mac80211/scan.c
Diffstat (limited to 'net/core/sock.c')
-rw-r--r-- | net/core/sock.c | 78 |
1 files changed, 50 insertions, 28 deletions
diff --git a/net/core/sock.c b/net/core/sock.c index c5812bbc2cc9..bf88a167c8f2 100644 --- a/net/core/sock.c +++ b/net/core/sock.c | |||
@@ -307,6 +307,11 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) | |||
307 | */ | 307 | */ |
308 | skb_len = skb->len; | 308 | skb_len = skb->len; |
309 | 309 | ||
310 | /* we escape from rcu protected region, make sure we dont leak | ||
311 | * a norefcounted dst | ||
312 | */ | ||
313 | skb_dst_force(skb); | ||
314 | |||
310 | spin_lock_irqsave(&list->lock, flags); | 315 | spin_lock_irqsave(&list->lock, flags); |
311 | skb->dropcount = atomic_read(&sk->sk_drops); | 316 | skb->dropcount = atomic_read(&sk->sk_drops); |
312 | __skb_queue_tail(list, skb); | 317 | __skb_queue_tail(list, skb); |
@@ -327,6 +332,10 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested) | |||
327 | 332 | ||
328 | skb->dev = NULL; | 333 | skb->dev = NULL; |
329 | 334 | ||
335 | if (sk_rcvqueues_full(sk, skb)) { | ||
336 | atomic_inc(&sk->sk_drops); | ||
337 | goto discard_and_relse; | ||
338 | } | ||
330 | if (nested) | 339 | if (nested) |
331 | bh_lock_sock_nested(sk); | 340 | bh_lock_sock_nested(sk); |
332 | else | 341 | else |
@@ -364,11 +373,11 @@ EXPORT_SYMBOL(sk_reset_txq); | |||
364 | 373 | ||
365 | struct dst_entry *__sk_dst_check(struct sock *sk, u32 cookie) | 374 | struct dst_entry *__sk_dst_check(struct sock *sk, u32 cookie) |
366 | { | 375 | { |
367 | struct dst_entry *dst = sk->sk_dst_cache; | 376 | struct dst_entry *dst = __sk_dst_get(sk); |
368 | 377 | ||
369 | if (dst && dst->obsolete && dst->ops->check(dst, cookie) == NULL) { | 378 | if (dst && dst->obsolete && dst->ops->check(dst, cookie) == NULL) { |
370 | sk_tx_queue_clear(sk); | 379 | sk_tx_queue_clear(sk); |
371 | sk->sk_dst_cache = NULL; | 380 | rcu_assign_pointer(sk->sk_dst_cache, NULL); |
372 | dst_release(dst); | 381 | dst_release(dst); |
373 | return NULL; | 382 | return NULL; |
374 | } | 383 | } |
@@ -1157,7 +1166,7 @@ struct sock *sk_clone(const struct sock *sk, const gfp_t priority) | |||
1157 | skb_queue_head_init(&newsk->sk_async_wait_queue); | 1166 | skb_queue_head_init(&newsk->sk_async_wait_queue); |
1158 | #endif | 1167 | #endif |
1159 | 1168 | ||
1160 | rwlock_init(&newsk->sk_dst_lock); | 1169 | spin_lock_init(&newsk->sk_dst_lock); |
1161 | rwlock_init(&newsk->sk_callback_lock); | 1170 | rwlock_init(&newsk->sk_callback_lock); |
1162 | lockdep_set_class_and_name(&newsk->sk_callback_lock, | 1171 | lockdep_set_class_and_name(&newsk->sk_callback_lock, |
1163 | af_callback_keys + newsk->sk_family, | 1172 | af_callback_keys + newsk->sk_family, |
@@ -1207,7 +1216,7 @@ struct sock *sk_clone(const struct sock *sk, const gfp_t priority) | |||
1207 | */ | 1216 | */ |
1208 | sk_refcnt_debug_inc(newsk); | 1217 | sk_refcnt_debug_inc(newsk); |
1209 | sk_set_socket(newsk, NULL); | 1218 | sk_set_socket(newsk, NULL); |
1210 | newsk->sk_sleep = NULL; | 1219 | newsk->sk_wq = NULL; |
1211 | 1220 | ||
1212 | if (newsk->sk_prot->sockets_allocated) | 1221 | if (newsk->sk_prot->sockets_allocated) |
1213 | percpu_counter_inc(newsk->sk_prot->sockets_allocated); | 1222 | percpu_counter_inc(newsk->sk_prot->sockets_allocated); |
@@ -1227,6 +1236,7 @@ void sk_setup_caps(struct sock *sk, struct dst_entry *dst) | |||
1227 | sk->sk_route_caps = dst->dev->features; | 1236 | sk->sk_route_caps = dst->dev->features; |
1228 | if (sk->sk_route_caps & NETIF_F_GSO) | 1237 | if (sk->sk_route_caps & NETIF_F_GSO) |
1229 | sk->sk_route_caps |= NETIF_F_GSO_SOFTWARE; | 1238 | sk->sk_route_caps |= NETIF_F_GSO_SOFTWARE; |
1239 | sk->sk_route_caps &= ~sk->sk_route_nocaps; | ||
1230 | if (sk_can_gso(sk)) { | 1240 | if (sk_can_gso(sk)) { |
1231 | if (dst->header_len) { | 1241 | if (dst->header_len) { |
1232 | sk->sk_route_caps &= ~NETIF_F_GSO_MASK; | 1242 | sk->sk_route_caps &= ~NETIF_F_GSO_MASK; |
@@ -1395,7 +1405,7 @@ static long sock_wait_for_wmem(struct sock *sk, long timeo) | |||
1395 | if (signal_pending(current)) | 1405 | if (signal_pending(current)) |
1396 | break; | 1406 | break; |
1397 | set_bit(SOCK_NOSPACE, &sk->sk_socket->flags); | 1407 | set_bit(SOCK_NOSPACE, &sk->sk_socket->flags); |
1398 | prepare_to_wait(sk->sk_sleep, &wait, TASK_INTERRUPTIBLE); | 1408 | prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE); |
1399 | if (atomic_read(&sk->sk_wmem_alloc) < sk->sk_sndbuf) | 1409 | if (atomic_read(&sk->sk_wmem_alloc) < sk->sk_sndbuf) |
1400 | break; | 1410 | break; |
1401 | if (sk->sk_shutdown & SEND_SHUTDOWN) | 1411 | if (sk->sk_shutdown & SEND_SHUTDOWN) |
@@ -1404,7 +1414,7 @@ static long sock_wait_for_wmem(struct sock *sk, long timeo) | |||
1404 | break; | 1414 | break; |
1405 | timeo = schedule_timeout(timeo); | 1415 | timeo = schedule_timeout(timeo); |
1406 | } | 1416 | } |
1407 | finish_wait(sk->sk_sleep, &wait); | 1417 | finish_wait(sk_sleep(sk), &wait); |
1408 | return timeo; | 1418 | return timeo; |
1409 | } | 1419 | } |
1410 | 1420 | ||
@@ -1531,6 +1541,7 @@ static void __release_sock(struct sock *sk) | |||
1531 | do { | 1541 | do { |
1532 | struct sk_buff *next = skb->next; | 1542 | struct sk_buff *next = skb->next; |
1533 | 1543 | ||
1544 | WARN_ON_ONCE(skb_dst_is_noref(skb)); | ||
1534 | skb->next = NULL; | 1545 | skb->next = NULL; |
1535 | sk_backlog_rcv(sk, skb); | 1546 | sk_backlog_rcv(sk, skb); |
1536 | 1547 | ||
@@ -1570,11 +1581,11 @@ int sk_wait_data(struct sock *sk, long *timeo) | |||
1570 | int rc; | 1581 | int rc; |
1571 | DEFINE_WAIT(wait); | 1582 | DEFINE_WAIT(wait); |
1572 | 1583 | ||
1573 | prepare_to_wait(sk->sk_sleep, &wait, TASK_INTERRUPTIBLE); | 1584 | prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE); |
1574 | set_bit(SOCK_ASYNC_WAITDATA, &sk->sk_socket->flags); | 1585 | set_bit(SOCK_ASYNC_WAITDATA, &sk->sk_socket->flags); |
1575 | rc = sk_wait_event(sk, timeo, !skb_queue_empty(&sk->sk_receive_queue)); | 1586 | rc = sk_wait_event(sk, timeo, !skb_queue_empty(&sk->sk_receive_queue)); |
1576 | clear_bit(SOCK_ASYNC_WAITDATA, &sk->sk_socket->flags); | 1587 | clear_bit(SOCK_ASYNC_WAITDATA, &sk->sk_socket->flags); |
1577 | finish_wait(sk->sk_sleep, &wait); | 1588 | finish_wait(sk_sleep(sk), &wait); |
1578 | return rc; | 1589 | return rc; |
1579 | } | 1590 | } |
1580 | EXPORT_SYMBOL(sk_wait_data); | 1591 | EXPORT_SYMBOL(sk_wait_data); |
@@ -1796,41 +1807,53 @@ EXPORT_SYMBOL(sock_no_sendpage); | |||
1796 | 1807 | ||
1797 | static void sock_def_wakeup(struct sock *sk) | 1808 | static void sock_def_wakeup(struct sock *sk) |
1798 | { | 1809 | { |
1799 | read_lock(&sk->sk_callback_lock); | 1810 | struct socket_wq *wq; |
1800 | if (sk_has_sleeper(sk)) | 1811 | |
1801 | wake_up_interruptible_all(sk->sk_sleep); | 1812 | rcu_read_lock(); |
1802 | read_unlock(&sk->sk_callback_lock); | 1813 | wq = rcu_dereference(sk->sk_wq); |
1814 | if (wq_has_sleeper(wq)) | ||
1815 | wake_up_interruptible_all(&wq->wait); | ||
1816 | rcu_read_unlock(); | ||
1803 | } | 1817 | } |
1804 | 1818 | ||
1805 | static void sock_def_error_report(struct sock *sk) | 1819 | static void sock_def_error_report(struct sock *sk) |
1806 | { | 1820 | { |
1807 | read_lock(&sk->sk_callback_lock); | 1821 | struct socket_wq *wq; |
1808 | if (sk_has_sleeper(sk)) | 1822 | |
1809 | wake_up_interruptible_poll(sk->sk_sleep, POLLERR); | 1823 | rcu_read_lock(); |
1824 | wq = rcu_dereference(sk->sk_wq); | ||
1825 | if (wq_has_sleeper(wq)) | ||
1826 | wake_up_interruptible_poll(&wq->wait, POLLERR); | ||
1810 | sk_wake_async(sk, SOCK_WAKE_IO, POLL_ERR); | 1827 | sk_wake_async(sk, SOCK_WAKE_IO, POLL_ERR); |
1811 | read_unlock(&sk->sk_callback_lock); | 1828 | rcu_read_unlock(); |
1812 | } | 1829 | } |
1813 | 1830 | ||
1814 | static void sock_def_readable(struct sock *sk, int len) | 1831 | static void sock_def_readable(struct sock *sk, int len) |
1815 | { | 1832 | { |
1816 | read_lock(&sk->sk_callback_lock); | 1833 | struct socket_wq *wq; |
1817 | if (sk_has_sleeper(sk)) | 1834 | |
1818 | wake_up_interruptible_sync_poll(sk->sk_sleep, POLLIN | | 1835 | rcu_read_lock(); |
1836 | wq = rcu_dereference(sk->sk_wq); | ||
1837 | if (wq_has_sleeper(wq)) | ||
1838 | wake_up_interruptible_sync_poll(&wq->wait, POLLIN | | ||
1819 | POLLRDNORM | POLLRDBAND); | 1839 | POLLRDNORM | POLLRDBAND); |
1820 | sk_wake_async(sk, SOCK_WAKE_WAITD, POLL_IN); | 1840 | sk_wake_async(sk, SOCK_WAKE_WAITD, POLL_IN); |
1821 | read_unlock(&sk->sk_callback_lock); | 1841 | rcu_read_unlock(); |
1822 | } | 1842 | } |
1823 | 1843 | ||
1824 | static void sock_def_write_space(struct sock *sk) | 1844 | static void sock_def_write_space(struct sock *sk) |
1825 | { | 1845 | { |
1826 | read_lock(&sk->sk_callback_lock); | 1846 | struct socket_wq *wq; |
1847 | |||
1848 | rcu_read_lock(); | ||
1827 | 1849 | ||
1828 | /* Do not wake up a writer until he can make "significant" | 1850 | /* Do not wake up a writer until he can make "significant" |
1829 | * progress. --DaveM | 1851 | * progress. --DaveM |
1830 | */ | 1852 | */ |
1831 | if ((atomic_read(&sk->sk_wmem_alloc) << 1) <= sk->sk_sndbuf) { | 1853 | if ((atomic_read(&sk->sk_wmem_alloc) << 1) <= sk->sk_sndbuf) { |
1832 | if (sk_has_sleeper(sk)) | 1854 | wq = rcu_dereference(sk->sk_wq); |
1833 | wake_up_interruptible_sync_poll(sk->sk_sleep, POLLOUT | | 1855 | if (wq_has_sleeper(wq)) |
1856 | wake_up_interruptible_sync_poll(&wq->wait, POLLOUT | | ||
1834 | POLLWRNORM | POLLWRBAND); | 1857 | POLLWRNORM | POLLWRBAND); |
1835 | 1858 | ||
1836 | /* Should agree with poll, otherwise some programs break */ | 1859 | /* Should agree with poll, otherwise some programs break */ |
@@ -1838,7 +1861,7 @@ static void sock_def_write_space(struct sock *sk) | |||
1838 | sk_wake_async(sk, SOCK_WAKE_SPACE, POLL_OUT); | 1861 | sk_wake_async(sk, SOCK_WAKE_SPACE, POLL_OUT); |
1839 | } | 1862 | } |
1840 | 1863 | ||
1841 | read_unlock(&sk->sk_callback_lock); | 1864 | rcu_read_unlock(); |
1842 | } | 1865 | } |
1843 | 1866 | ||
1844 | static void sock_def_destruct(struct sock *sk) | 1867 | static void sock_def_destruct(struct sock *sk) |
@@ -1885,7 +1908,6 @@ void sock_init_data(struct socket *sock, struct sock *sk) | |||
1885 | sk->sk_allocation = GFP_KERNEL; | 1908 | sk->sk_allocation = GFP_KERNEL; |
1886 | sk->sk_rcvbuf = sysctl_rmem_default; | 1909 | sk->sk_rcvbuf = sysctl_rmem_default; |
1887 | sk->sk_sndbuf = sysctl_wmem_default; | 1910 | sk->sk_sndbuf = sysctl_wmem_default; |
1888 | sk->sk_backlog.limit = sk->sk_rcvbuf << 1; | ||
1889 | sk->sk_state = TCP_CLOSE; | 1911 | sk->sk_state = TCP_CLOSE; |
1890 | sk_set_socket(sk, sock); | 1912 | sk_set_socket(sk, sock); |
1891 | 1913 | ||
@@ -1893,12 +1915,12 @@ void sock_init_data(struct socket *sock, struct sock *sk) | |||
1893 | 1915 | ||
1894 | if (sock) { | 1916 | if (sock) { |
1895 | sk->sk_type = sock->type; | 1917 | sk->sk_type = sock->type; |
1896 | sk->sk_sleep = &sock->wait; | 1918 | sk->sk_wq = sock->wq; |
1897 | sock->sk = sk; | 1919 | sock->sk = sk; |
1898 | } else | 1920 | } else |
1899 | sk->sk_sleep = NULL; | 1921 | sk->sk_wq = NULL; |
1900 | 1922 | ||
1901 | rwlock_init(&sk->sk_dst_lock); | 1923 | spin_lock_init(&sk->sk_dst_lock); |
1902 | rwlock_init(&sk->sk_callback_lock); | 1924 | rwlock_init(&sk->sk_callback_lock); |
1903 | lockdep_set_class_and_name(&sk->sk_callback_lock, | 1925 | lockdep_set_class_and_name(&sk->sk_callback_lock, |
1904 | af_callback_keys + sk->sk_family, | 1926 | af_callback_keys + sk->sk_family, |