Lines Matching full:other
52 * other the moment one end closes.
516 static int unix_dgram_peer_wake_connect(struct sock *sk, struct sock *other) in unix_dgram_peer_wake_connect() argument
522 u_other = unix_sk(other); in unix_dgram_peer_wake_connect()
527 u->peer_wake.private = other; in unix_dgram_peer_wake_connect()
538 struct sock *other) in unix_dgram_peer_wake_disconnect() argument
543 u_other = unix_sk(other); in unix_dgram_peer_wake_disconnect()
546 if (u->peer_wake.private == other) { in unix_dgram_peer_wake_disconnect()
555 struct sock *other) in unix_dgram_peer_wake_disconnect_wakeup() argument
557 unix_dgram_peer_wake_disconnect(sk, other); in unix_dgram_peer_wake_disconnect_wakeup()
565 * - unix_peer(sk) == other
568 static int unix_dgram_peer_wake_me(struct sock *sk, struct sock *other) in unix_dgram_peer_wake_me() argument
572 connected = unix_dgram_peer_wake_connect(sk, other); in unix_dgram_peer_wake_me()
574 /* If other is SOCK_DEAD, we want to make sure we signal in unix_dgram_peer_wake_me()
577 * to other and its full, we will hang waiting for POLLOUT. in unix_dgram_peer_wake_me()
579 if (unix_recvq_full_lockless(other) && !sock_flag(other, SOCK_DEAD)) in unix_dgram_peer_wake_me()
583 unix_dgram_peer_wake_disconnect(sk, other); in unix_dgram_peer_wake_me()
613 static void unix_dgram_disconnected(struct sock *sk, struct sock *other) in unix_dgram_disconnected() argument
625 if (!sock_flag(other, SOCK_DEAD) && unix_peer(other) == sk) { in unix_dgram_disconnected()
626 WRITE_ONCE(other->sk_err, ECONNRESET); in unix_dgram_disconnected()
627 sk_error_report(other); in unix_dgram_disconnected()
1406 struct sock *other; in unix_dgram_connect() local
1431 other = unix_find_other(sock_net(sk), sunaddr, alen, sock->type); in unix_dgram_connect()
1432 if (IS_ERR(other)) { in unix_dgram_connect()
1433 err = PTR_ERR(other); in unix_dgram_connect()
1437 unix_state_double_lock(sk, other); in unix_dgram_connect()
1440 if (sock_flag(other, SOCK_DEAD)) { in unix_dgram_connect()
1441 unix_state_double_unlock(sk, other); in unix_dgram_connect()
1442 sock_put(other); in unix_dgram_connect()
1447 if (!unix_may_send(sk, other)) in unix_dgram_connect()
1450 err = security_unix_may_send(sk->sk_socket, other->sk_socket); in unix_dgram_connect()
1455 WRITE_ONCE(other->sk_state, TCP_ESTABLISHED); in unix_dgram_connect()
1460 other = NULL; in unix_dgram_connect()
1461 unix_state_double_lock(sk, other); in unix_dgram_connect()
1470 unix_peer(sk) = other; in unix_dgram_connect()
1471 if (!other) in unix_dgram_connect()
1475 unix_state_double_unlock(sk, other); in unix_dgram_connect()
1477 if (other != old_peer) { in unix_dgram_connect()
1488 unix_peer(sk) = other; in unix_dgram_connect()
1489 unix_state_double_unlock(sk, other); in unix_dgram_connect()
1495 unix_state_double_unlock(sk, other); in unix_dgram_connect()
1496 sock_put(other); in unix_dgram_connect()
1501 static long unix_wait_for_peer(struct sock *other, long timeo) in unix_wait_for_peer() argument
1503 struct unix_sock *u = unix_sk(other); in unix_wait_for_peer()
1509 sched = !sock_flag(other, SOCK_DEAD) && in unix_wait_for_peer()
1510 !(other->sk_shutdown & RCV_SHUTDOWN) && in unix_wait_for_peer()
1511 unix_recvq_full_lockless(other); in unix_wait_for_peer()
1513 unix_state_unlock(other); in unix_wait_for_peer()
1526 struct sock *sk = sock->sk, *newsk = NULL, *other = NULL; in unix_stream_connect() local
1573 other = unix_find_other(net, sunaddr, addr_len, sk->sk_type); in unix_stream_connect()
1574 if (IS_ERR(other)) { in unix_stream_connect()
1575 err = PTR_ERR(other); in unix_stream_connect()
1579 unix_state_lock(other); in unix_stream_connect()
1582 if (sock_flag(other, SOCK_DEAD)) { in unix_stream_connect()
1583 unix_state_unlock(other); in unix_stream_connect()
1584 sock_put(other); in unix_stream_connect()
1588 if (other->sk_state != TCP_LISTEN || in unix_stream_connect()
1589 other->sk_shutdown & RCV_SHUTDOWN) { in unix_stream_connect()
1594 if (unix_recvq_full_lockless(other)) { in unix_stream_connect()
1600 timeo = unix_wait_for_peer(other, timeo); in unix_stream_connect()
1601 sock_put(other); in unix_stream_connect()
1627 err = security_unix_stream_connect(sk, other, newsk); in unix_stream_connect()
1641 newu->listener = other; in unix_stream_connect()
1643 otheru = unix_sk(other); in unix_stream_connect()
1670 copy_peercred(sk, other); in unix_stream_connect()
1682 spin_lock(&other->sk_receive_queue.lock); in unix_stream_connect()
1683 __skb_queue_tail(&other->sk_receive_queue, skb); in unix_stream_connect()
1684 spin_unlock(&other->sk_receive_queue.lock); in unix_stream_connect()
1685 unix_state_unlock(other); in unix_stream_connect()
1686 other->sk_data_ready(other); in unix_stream_connect()
1687 sock_put(other); in unix_stream_connect()
1691 unix_state_unlock(other); in unix_stream_connect()
1692 sock_put(other); in unix_stream_connect()
1889 const struct sock *other) in unix_passcred_enabled() argument
1893 !other->sk_socket || in unix_passcred_enabled()
1894 test_bit(SOCK_PASSCRED, &other->sk_socket->flags) || in unix_passcred_enabled()
1895 test_bit(SOCK_PASSPIDFD, &other->sk_socket->flags); in unix_passcred_enabled()
1904 const struct sock *other) in maybe_add_creds() argument
1908 if (unix_passcred_enabled(sock, other)) { in maybe_add_creds()
1952 struct sock *sk = sock->sk, *other = NULL; in unix_dgram_sendmsg() local
2028 other = unix_find_other(sock_net(sk), msg->msg_name, in unix_dgram_sendmsg()
2030 if (IS_ERR(other)) { in unix_dgram_sendmsg()
2031 err = PTR_ERR(other); in unix_dgram_sendmsg()
2035 other = unix_peer_get(sk); in unix_dgram_sendmsg()
2036 if (!other) { in unix_dgram_sendmsg()
2042 if (sk_filter(other, skb) < 0) { in unix_dgram_sendmsg()
2050 unix_state_lock(other); in unix_dgram_sendmsg()
2053 if (!unix_may_send(sk, other)) { in unix_dgram_sendmsg()
2058 if (unlikely(sock_flag(other, SOCK_DEAD))) { in unix_dgram_sendmsg()
2061 unix_state_unlock(other); in unix_dgram_sendmsg()
2065 * is clearing @other. Never change state to TCP_CLOSE in unix_dgram_sendmsg()
2075 if (unix_peer(sk) == other) { in unix_dgram_sendmsg()
2077 unix_dgram_peer_wake_disconnect_wakeup(sk, other); in unix_dgram_sendmsg()
2082 unix_dgram_disconnected(sk, other); in unix_dgram_sendmsg()
2083 sock_put(other); in unix_dgram_sendmsg()
2095 sock_put(other); in unix_dgram_sendmsg()
2099 if (other->sk_shutdown & RCV_SHUTDOWN) { in unix_dgram_sendmsg()
2105 err = security_unix_may_send(sk->sk_socket, other->sk_socket); in unix_dgram_sendmsg()
2110 /* other == sk && unix_peer(other) != sk if in unix_dgram_sendmsg()
2114 if (other != sk && in unix_dgram_sendmsg()
2115 unlikely(unix_peer(other) != sk && in unix_dgram_sendmsg()
2116 unix_recvq_full_lockless(other))) { in unix_dgram_sendmsg()
2118 timeo = unix_wait_for_peer(other, timeo); in unix_dgram_sendmsg()
2128 unix_state_unlock(other); in unix_dgram_sendmsg()
2129 unix_state_double_lock(sk, other); in unix_dgram_sendmsg()
2132 if (unix_peer(sk) != other || in unix_dgram_sendmsg()
2133 unix_dgram_peer_wake_me(sk, other)) { in unix_dgram_sendmsg()
2148 if (sock_flag(other, SOCK_RCVTSTAMP)) in unix_dgram_sendmsg()
2150 maybe_add_creds(skb, sock, other); in unix_dgram_sendmsg()
2151 scm_stat_add(other, skb); in unix_dgram_sendmsg()
2152 skb_queue_tail(&other->sk_receive_queue, skb); in unix_dgram_sendmsg()
2153 unix_state_unlock(other); in unix_dgram_sendmsg()
2154 other->sk_data_ready(other); in unix_dgram_sendmsg()
2155 sock_put(other); in unix_dgram_sendmsg()
2162 unix_state_unlock(other); in unix_dgram_sendmsg()
2164 sock_put(other); in unix_dgram_sendmsg()
2178 static int queue_oob(struct socket *sock, struct msghdr *msg, struct sock *other, in queue_oob() argument
2181 struct unix_sock *ousk = unix_sk(other); in queue_oob()
2200 unix_state_lock(other); in queue_oob()
2202 if (sock_flag(other, SOCK_DEAD) || in queue_oob()
2203 (other->sk_shutdown & RCV_SHUTDOWN)) { in queue_oob()
2204 unix_state_unlock(other); in queue_oob()
2209 maybe_add_creds(skb, sock, other); in queue_oob()
2210 scm_stat_add(other, skb); in queue_oob()
2212 spin_lock(&other->sk_receive_queue.lock); in queue_oob()
2214 __skb_queue_tail(&other->sk_receive_queue, skb); in queue_oob()
2215 spin_unlock(&other->sk_receive_queue.lock); in queue_oob()
2217 sk_send_sigurg(other); in queue_oob()
2218 unix_state_unlock(other); in queue_oob()
2219 other->sk_data_ready(other); in queue_oob()
2233 struct sock *other = NULL; in unix_stream_sendmsg() local
2258 other = unix_peer(sk); in unix_stream_sendmsg()
2259 if (!other) { in unix_stream_sendmsg()
2319 unix_state_lock(other); in unix_stream_sendmsg()
2321 if (sock_flag(other, SOCK_DEAD) || in unix_stream_sendmsg()
2322 (other->sk_shutdown & RCV_SHUTDOWN)) in unix_stream_sendmsg()
2325 maybe_add_creds(skb, sock, other); in unix_stream_sendmsg()
2326 scm_stat_add(other, skb); in unix_stream_sendmsg()
2327 skb_queue_tail(&other->sk_receive_queue, skb); in unix_stream_sendmsg()
2328 unix_state_unlock(other); in unix_stream_sendmsg()
2329 other->sk_data_ready(other); in unix_stream_sendmsg()
2335 err = queue_oob(sock, msg, other, &scm, fds_sent); in unix_stream_sendmsg()
2347 unix_state_unlock(other); in unix_stream_sendmsg()
3019 struct sock *other; in unix_shutdown() local
3032 other = unix_peer(sk); in unix_shutdown()
3033 if (other) in unix_shutdown()
3034 sock_hold(other); in unix_shutdown()
3038 if (other && in unix_shutdown()
3042 const struct proto *prot = READ_ONCE(other->sk_prot); in unix_shutdown()
3045 prot->unhash(other); in unix_shutdown()
3050 unix_state_lock(other); in unix_shutdown()
3051 WRITE_ONCE(other->sk_shutdown, other->sk_shutdown | peer_mode); in unix_shutdown()
3052 unix_state_unlock(other); in unix_shutdown()
3053 other->sk_state_change(other); in unix_shutdown()
3055 sk_wake_async(other, SOCK_WAKE_WAITD, POLL_HUP); in unix_shutdown()
3057 sk_wake_async(other, SOCK_WAKE_WAITD, POLL_IN); in unix_shutdown()
3059 if (other) in unix_shutdown()
3060 sock_put(other); in unix_shutdown()
3230 * we set writable also when the other side has shut down the in unix_poll()
3242 struct sock *sk = sock->sk, *other; in unix_dgram_poll() local
3282 other = unix_peer(sk); in unix_dgram_poll()
3283 if (other && unix_peer(other) != sk && in unix_dgram_poll()
3284 unix_recvq_full_lockless(other) && in unix_dgram_poll()
3285 unix_dgram_peer_wake_me(sk, other)) in unix_dgram_poll()