提交 7976a11b 编写于 作者: E Eric Dumazet 提交者: David S. Miller

net: use helpers to change sk_ack_backlog

Writers are holding a lock, but many readers do not.

Following patch will add appropriate barriers in
sk_acceptq_removed() and sk_acceptq_added().
Signed-off-by: NEric Dumazet <edumazet@google.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 25c7a6d1
...@@ -109,7 +109,7 @@ static int sigd_send(struct atm_vcc *vcc, struct sk_buff *skb) ...@@ -109,7 +109,7 @@ static int sigd_send(struct atm_vcc *vcc, struct sk_buff *skb)
dev_kfree_skb(skb); dev_kfree_skb(skb);
goto as_indicate_complete; goto as_indicate_complete;
} }
sk->sk_ack_backlog++; sk_acceptq_added(sk);
skb_queue_tail(&sk->sk_receive_queue, skb); skb_queue_tail(&sk->sk_receive_queue, skb);
pr_debug("waking sk_sleep(sk) 0x%p\n", sk_sleep(sk)); pr_debug("waking sk_sleep(sk) 0x%p\n", sk_sleep(sk));
sk->sk_state_change(sk); sk->sk_state_change(sk);
......
...@@ -381,7 +381,7 @@ static int svc_accept(struct socket *sock, struct socket *newsock, int flags, ...@@ -381,7 +381,7 @@ static int svc_accept(struct socket *sock, struct socket *newsock, int flags,
msg->pvc.sap_addr.vpi, msg->pvc.sap_addr.vpi,
msg->pvc.sap_addr.vci); msg->pvc.sap_addr.vci);
dev_kfree_skb(skb); dev_kfree_skb(skb);
sk->sk_ack_backlog--; sk_acceptq_removed(sk);
if (error) { if (error) {
sigd_enq2(NULL, as_reject, old_vcc, NULL, NULL, sigd_enq2(NULL, as_reject, old_vcc, NULL, NULL,
&old_vcc->qos, error); &old_vcc->qos, error);
......
...@@ -1384,7 +1384,7 @@ static int ax25_accept(struct socket *sock, struct socket *newsock, int flags, ...@@ -1384,7 +1384,7 @@ static int ax25_accept(struct socket *sock, struct socket *newsock, int flags,
/* Now attach up the new socket */ /* Now attach up the new socket */
kfree_skb(skb); kfree_skb(skb);
sk->sk_ack_backlog--; sk_acceptq_removed(sk);
newsock->state = SS_CONNECTED; newsock->state = SS_CONNECTED;
out: out:
......
...@@ -356,7 +356,7 @@ static int ax25_rcv(struct sk_buff *skb, struct net_device *dev, ...@@ -356,7 +356,7 @@ static int ax25_rcv(struct sk_buff *skb, struct net_device *dev,
make->sk_state = TCP_ESTABLISHED; make->sk_state = TCP_ESTABLISHED;
sk->sk_ack_backlog++; sk_acceptq_added(sk);
bh_unlock_sock(sk); bh_unlock_sock(sk);
} else { } else {
if (!mine) if (!mine)
......
...@@ -173,7 +173,7 @@ void bt_accept_enqueue(struct sock *parent, struct sock *sk, bool bh) ...@@ -173,7 +173,7 @@ void bt_accept_enqueue(struct sock *parent, struct sock *sk, bool bh)
else else
release_sock(sk); release_sock(sk);
parent->sk_ack_backlog++; sk_acceptq_added(parent);
} }
EXPORT_SYMBOL(bt_accept_enqueue); EXPORT_SYMBOL(bt_accept_enqueue);
...@@ -185,7 +185,7 @@ void bt_accept_unlink(struct sock *sk) ...@@ -185,7 +185,7 @@ void bt_accept_unlink(struct sock *sk)
BT_DBG("sk %p state %d", sk, sk->sk_state); BT_DBG("sk %p state %d", sk, sk->sk_state);
list_del_init(&bt_sk(sk)->accept_q); list_del_init(&bt_sk(sk)->accept_q);
bt_sk(sk)->parent->sk_ack_backlog--; sk_acceptq_removed(bt_sk(sk)->parent);
bt_sk(sk)->parent = NULL; bt_sk(sk)->parent = NULL;
sock_put(sk); sock_put(sk);
} }
......
...@@ -1091,7 +1091,7 @@ static int dn_accept(struct socket *sock, struct socket *newsock, int flags, ...@@ -1091,7 +1091,7 @@ static int dn_accept(struct socket *sock, struct socket *newsock, int flags,
} }
cb = DN_SKB_CB(skb); cb = DN_SKB_CB(skb);
sk->sk_ack_backlog--; sk_acceptq_removed(sk);
newsk = dn_alloc_sock(sock_net(sk), newsock, sk->sk_allocation, kern); newsk = dn_alloc_sock(sock_net(sk), newsock, sk->sk_allocation, kern);
if (newsk == NULL) { if (newsk == NULL) {
release_sock(sk); release_sock(sk);
......
...@@ -328,7 +328,7 @@ static void dn_nsp_conn_init(struct sock *sk, struct sk_buff *skb) ...@@ -328,7 +328,7 @@ static void dn_nsp_conn_init(struct sock *sk, struct sk_buff *skb)
return; return;
} }
sk->sk_ack_backlog++; sk_acceptq_added(sk);
skb_queue_tail(&sk->sk_receive_queue, skb); skb_queue_tail(&sk->sk_receive_queue, skb);
sk->sk_state_change(sk); sk->sk_state_change(sk);
} }
......
...@@ -705,7 +705,7 @@ static int llc_ui_accept(struct socket *sock, struct socket *newsock, int flags, ...@@ -705,7 +705,7 @@ static int llc_ui_accept(struct socket *sock, struct socket *newsock, int flags,
/* put original socket back into a clean listen state. */ /* put original socket back into a clean listen state. */
sk->sk_state = TCP_LISTEN; sk->sk_state = TCP_LISTEN;
sk->sk_ack_backlog--; sk_acceptq_removed(sk);
dprintk("%s: ok success on %02X, client on %02X\n", __func__, dprintk("%s: ok success on %02X, client on %02X\n", __func__,
llc_sk(sk)->addr.sllc_sap, newllc->daddr.lsap); llc_sk(sk)->addr.sllc_sap, newllc->daddr.lsap);
frees: frees:
......
...@@ -906,7 +906,7 @@ static int rose_accept(struct socket *sock, struct socket *newsock, int flags, ...@@ -906,7 +906,7 @@ static int rose_accept(struct socket *sock, struct socket *newsock, int flags,
/* Now attach up the new socket */ /* Now attach up the new socket */
skb->sk = NULL; skb->sk = NULL;
kfree_skb(skb); kfree_skb(skb);
sk->sk_ack_backlog--; sk_acceptq_removed(sk);
out_release: out_release:
release_sock(sk); release_sock(sk);
...@@ -1011,7 +1011,7 @@ int rose_rx_call_request(struct sk_buff *skb, struct net_device *dev, struct ros ...@@ -1011,7 +1011,7 @@ int rose_rx_call_request(struct sk_buff *skb, struct net_device *dev, struct ros
make_rose->va = 0; make_rose->va = 0;
make_rose->vr = 0; make_rose->vr = 0;
make_rose->vl = 0; make_rose->vl = 0;
sk->sk_ack_backlog++; sk_acceptq_added(sk);
rose_insert_socket(make); rose_insert_socket(make);
......
...@@ -324,7 +324,7 @@ void sctp_association_free(struct sctp_association *asoc) ...@@ -324,7 +324,7 @@ void sctp_association_free(struct sctp_association *asoc)
* socket. * socket.
*/ */
if (sctp_style(sk, TCP) && sctp_sstate(sk, LISTENING)) if (sctp_style(sk, TCP) && sctp_sstate(sk, LISTENING))
sk->sk_ack_backlog--; sk_acceptq_removed(sk);
} }
/* Mark as dead, so other users can know this structure is /* Mark as dead, so other users can know this structure is
...@@ -1073,7 +1073,7 @@ void sctp_assoc_migrate(struct sctp_association *assoc, struct sock *newsk) ...@@ -1073,7 +1073,7 @@ void sctp_assoc_migrate(struct sctp_association *assoc, struct sock *newsk)
/* Decrement the backlog value for a TCP-style socket. */ /* Decrement the backlog value for a TCP-style socket. */
if (sctp_style(oldsk, TCP)) if (sctp_style(oldsk, TCP))
oldsk->sk_ack_backlog--; sk_acceptq_removed(oldsk);
/* Release references to the old endpoint and the sock. */ /* Release references to the old endpoint and the sock. */
sctp_endpoint_put(assoc->ep); sctp_endpoint_put(assoc->ep);
......
...@@ -164,7 +164,7 @@ void sctp_endpoint_add_asoc(struct sctp_endpoint *ep, ...@@ -164,7 +164,7 @@ void sctp_endpoint_add_asoc(struct sctp_endpoint *ep,
/* Increment the backlog value for a TCP-style listening socket. */ /* Increment the backlog value for a TCP-style listening socket. */
if (sctp_style(sk, TCP) && sctp_sstate(sk, LISTENING)) if (sctp_style(sk, TCP) && sctp_sstate(sk, LISTENING))
sk->sk_ack_backlog++; sk_acceptq_added(sk);
} }
/* Free the endpoint structure. Delay cleanup until /* Free the endpoint structure. Delay cleanup until
......
...@@ -439,7 +439,7 @@ static void vsock_pending_work(struct work_struct *work) ...@@ -439,7 +439,7 @@ static void vsock_pending_work(struct work_struct *work)
if (vsock_is_pending(sk)) { if (vsock_is_pending(sk)) {
vsock_remove_pending(listener, sk); vsock_remove_pending(listener, sk);
listener->sk_ack_backlog--; sk_acceptq_removed(listener);
} else if (!vsk->rejected) { } else if (!vsk->rejected) {
/* We are not on the pending list and accept() did not reject /* We are not on the pending list and accept() did not reject
* us, so we must have been accepted by our user process. We * us, so we must have been accepted by our user process. We
...@@ -1299,7 +1299,7 @@ static int vsock_accept(struct socket *sock, struct socket *newsock, int flags, ...@@ -1299,7 +1299,7 @@ static int vsock_accept(struct socket *sock, struct socket *newsock, int flags,
err = -listener->sk_err; err = -listener->sk_err;
if (connected) { if (connected) {
listener->sk_ack_backlog--; sk_acceptq_removed(listener);
lock_sock_nested(connected, SINGLE_DEPTH_NESTING); lock_sock_nested(connected, SINGLE_DEPTH_NESTING);
vconnected = vsock_sk(connected); vconnected = vsock_sk(connected);
......
...@@ -428,7 +428,7 @@ static void hvs_open_connection(struct vmbus_channel *chan) ...@@ -428,7 +428,7 @@ static void hvs_open_connection(struct vmbus_channel *chan)
if (conn_from_host) { if (conn_from_host) {
new->sk_state = TCP_ESTABLISHED; new->sk_state = TCP_ESTABLISHED;
sk->sk_ack_backlog++; sk_acceptq_added(sk);
hvs_addr_init(&vnew->local_addr, if_type); hvs_addr_init(&vnew->local_addr, if_type);
hvs_remote_addr_init(&vnew->remote_addr, &vnew->local_addr); hvs_remote_addr_init(&vnew->remote_addr, &vnew->local_addr);
......
...@@ -1066,7 +1066,7 @@ virtio_transport_recv_listen(struct sock *sk, struct virtio_vsock_pkt *pkt) ...@@ -1066,7 +1066,7 @@ virtio_transport_recv_listen(struct sock *sk, struct virtio_vsock_pkt *pkt)
return -ENOMEM; return -ENOMEM;
} }
sk->sk_ack_backlog++; sk_acceptq_added(sk);
lock_sock_nested(child, SINGLE_DEPTH_NESTING); lock_sock_nested(child, SINGLE_DEPTH_NESTING);
......
...@@ -1098,7 +1098,7 @@ static int vmci_transport_recv_listen(struct sock *sk, ...@@ -1098,7 +1098,7 @@ static int vmci_transport_recv_listen(struct sock *sk,
} }
vsock_add_pending(sk, pending); vsock_add_pending(sk, pending);
sk->sk_ack_backlog++; sk_acceptq_added(sk);
pending->sk_state = TCP_SYN_SENT; pending->sk_state = TCP_SYN_SENT;
vmci_trans(vpending)->produce_size = vmci_trans(vpending)->produce_size =
......
...@@ -891,7 +891,7 @@ static int x25_accept(struct socket *sock, struct socket *newsock, int flags, ...@@ -891,7 +891,7 @@ static int x25_accept(struct socket *sock, struct socket *newsock, int flags,
/* Now attach up the new socket */ /* Now attach up the new socket */
skb->sk = NULL; skb->sk = NULL;
kfree_skb(skb); kfree_skb(skb);
sk->sk_ack_backlog--; sk_acceptq_removed(sk);
newsock->state = SS_CONNECTED; newsock->state = SS_CONNECTED;
rc = 0; rc = 0;
out2: out2:
...@@ -1062,7 +1062,7 @@ int x25_rx_call_request(struct sk_buff *skb, struct x25_neigh *nb, ...@@ -1062,7 +1062,7 @@ int x25_rx_call_request(struct sk_buff *skb, struct x25_neigh *nb,
skb_copy_from_linear_data(skb, makex25->calluserdata.cuddata, skb->len); skb_copy_from_linear_data(skb, makex25->calluserdata.cuddata, skb->len);
makex25->calluserdata.cudlength = skb->len; makex25->calluserdata.cudlength = skb->len;
sk->sk_ack_backlog++; sk_acceptq_added(sk);
x25_insert_socket(make); x25_insert_socket(make);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册