Lines Matching full:other

52  *		other the moment one end closes.
519 static int unix_dgram_peer_wake_connect(struct sock *sk, struct sock *other) in unix_dgram_peer_wake_connect() argument
525 u_other = unix_sk(other); in unix_dgram_peer_wake_connect()
530 u->peer_wake.private = other; in unix_dgram_peer_wake_connect()
541 struct sock *other) in unix_dgram_peer_wake_disconnect() argument
546 u_other = unix_sk(other); in unix_dgram_peer_wake_disconnect()
549 if (u->peer_wake.private == other) { in unix_dgram_peer_wake_disconnect()
558 struct sock *other) in unix_dgram_peer_wake_disconnect_wakeup() argument
560 unix_dgram_peer_wake_disconnect(sk, other); in unix_dgram_peer_wake_disconnect_wakeup()
568 * - unix_peer(sk) == other
571 static int unix_dgram_peer_wake_me(struct sock *sk, struct sock *other) in unix_dgram_peer_wake_me() argument
575 connected = unix_dgram_peer_wake_connect(sk, other); in unix_dgram_peer_wake_me()
577 /* If other is SOCK_DEAD, we want to make sure we signal in unix_dgram_peer_wake_me()
580 * to other and its full, we will hang waiting for POLLOUT. in unix_dgram_peer_wake_me()
582 if (unix_recvq_full_lockless(other) && !sock_flag(other, SOCK_DEAD)) in unix_dgram_peer_wake_me()
586 unix_dgram_peer_wake_disconnect(sk, other); in unix_dgram_peer_wake_me()
616 static void unix_dgram_disconnected(struct sock *sk, struct sock *other) in unix_dgram_disconnected() argument
628 if (!sock_flag(other, SOCK_DEAD) && unix_peer(other) == sk) { in unix_dgram_disconnected()
629 WRITE_ONCE(other->sk_err, ECONNRESET); in unix_dgram_disconnected()
630 sk_error_report(other); in unix_dgram_disconnected()
1531 struct sock *other; in unix_dgram_connect() local
1554 other = unix_find_other(sock_net(sk), sunaddr, alen, sock->type, 0); in unix_dgram_connect()
1555 if (IS_ERR(other)) { in unix_dgram_connect()
1556 err = PTR_ERR(other); in unix_dgram_connect()
1560 unix_state_double_lock(sk, other); in unix_dgram_connect()
1563 if (sock_flag(other, SOCK_DEAD)) { in unix_dgram_connect()
1564 unix_state_double_unlock(sk, other); in unix_dgram_connect()
1565 sock_put(other); in unix_dgram_connect()
1570 if (!unix_may_send(sk, other)) in unix_dgram_connect()
1573 err = security_unix_may_send(sk->sk_socket, other->sk_socket); in unix_dgram_connect()
1578 WRITE_ONCE(other->sk_state, TCP_ESTABLISHED); in unix_dgram_connect()
1583 other = NULL; in unix_dgram_connect()
1584 unix_state_double_lock(sk, other); in unix_dgram_connect()
1593 unix_peer(sk) = other; in unix_dgram_connect()
1594 if (!other) in unix_dgram_connect()
1598 unix_state_double_unlock(sk, other); in unix_dgram_connect()
1600 if (other != old_peer) { in unix_dgram_connect()
1611 unix_peer(sk) = other; in unix_dgram_connect()
1612 unix_state_double_unlock(sk, other); in unix_dgram_connect()
1618 unix_state_double_unlock(sk, other); in unix_dgram_connect()
1619 sock_put(other); in unix_dgram_connect()
1624 static long unix_wait_for_peer(struct sock *other, long timeo) in unix_wait_for_peer() argument
1626 struct unix_sock *u = unix_sk(other); in unix_wait_for_peer()
1632 sched = !sock_flag(other, SOCK_DEAD) && in unix_wait_for_peer()
1633 !(other->sk_shutdown & RCV_SHUTDOWN) && in unix_wait_for_peer()
1634 unix_recvq_full_lockless(other); in unix_wait_for_peer()
1636 unix_state_unlock(other); in unix_wait_for_peer()
1649 struct sock *sk = sock->sk, *newsk = NULL, *other = NULL; in unix_stream_connect() local
1699 other = unix_find_other(net, sunaddr, addr_len, sk->sk_type, flags); in unix_stream_connect()
1700 if (IS_ERR(other)) { in unix_stream_connect()
1701 err = PTR_ERR(other); in unix_stream_connect()
1705 unix_state_lock(other); in unix_stream_connect()
1708 if (sock_flag(other, SOCK_DEAD)) { in unix_stream_connect()
1709 unix_state_unlock(other); in unix_stream_connect()
1710 sock_put(other); in unix_stream_connect()
1714 if (other->sk_state != TCP_LISTEN || in unix_stream_connect()
1715 other->sk_shutdown & RCV_SHUTDOWN) { in unix_stream_connect()
1720 if (unix_recvq_full_lockless(other)) { in unix_stream_connect()
1726 timeo = unix_wait_for_peer(other, timeo); in unix_stream_connect()
1727 sock_put(other); in unix_stream_connect()
1753 err = security_unix_stream_connect(sk, other, newsk); in unix_stream_connect()
1765 newsk->sk_scm_recv_flags = other->sk_scm_recv_flags; in unix_stream_connect()
1769 newu->listener = other; in unix_stream_connect()
1771 otheru = unix_sk(other); in unix_stream_connect()
1798 copy_peercred(sk, other); in unix_stream_connect()
1810 spin_lock(&other->sk_receive_queue.lock); in unix_stream_connect()
1811 __skb_queue_tail(&other->sk_receive_queue, skb); in unix_stream_connect()
1812 spin_unlock(&other->sk_receive_queue.lock); in unix_stream_connect()
1813 unix_state_unlock(other); in unix_stream_connect()
1814 other->sk_data_ready(other); in unix_stream_connect()
1815 sock_put(other); in unix_stream_connect()
1819 unix_state_unlock(other); in unix_stream_connect()
1820 sock_put(other); in unix_stream_connect()
2030 * @other: Receiver sock.
2040 const struct sock *other) in unix_maybe_add_creds() argument
2045 if (unix_may_passcred(sk) || unix_may_passcred(other) || in unix_maybe_add_creds()
2046 !other->sk_socket) { in unix_maybe_add_creds()
2100 struct sock *sk = sock->sk, *other = NULL; in unix_dgram_sendmsg() local
2174 other = unix_find_other(sock_net(sk), msg->msg_name, in unix_dgram_sendmsg()
2176 if (IS_ERR(other)) { in unix_dgram_sendmsg()
2177 err = PTR_ERR(other); in unix_dgram_sendmsg()
2181 other = unix_peer_get(sk); in unix_dgram_sendmsg()
2182 if (!other) { in unix_dgram_sendmsg()
2188 if (sk_filter(other, skb) < 0) { in unix_dgram_sendmsg()
2194 err = unix_maybe_add_creds(skb, sk, other); in unix_dgram_sendmsg()
2200 unix_state_lock(other); in unix_dgram_sendmsg()
2203 if (!unix_may_send(sk, other)) { in unix_dgram_sendmsg()
2208 if (unlikely(sock_flag(other, SOCK_DEAD))) { in unix_dgram_sendmsg()
2211 unix_state_unlock(other); in unix_dgram_sendmsg()
2215 * is clearing @other. Never change state to TCP_CLOSE in unix_dgram_sendmsg()
2225 if (unix_peer(sk) == other) { in unix_dgram_sendmsg()
2227 unix_dgram_peer_wake_disconnect_wakeup(sk, other); in unix_dgram_sendmsg()
2232 unix_dgram_disconnected(sk, other); in unix_dgram_sendmsg()
2233 sock_put(other); in unix_dgram_sendmsg()
2245 sock_put(other); in unix_dgram_sendmsg()
2249 if (other->sk_shutdown & RCV_SHUTDOWN) { in unix_dgram_sendmsg()
2254 if (UNIXCB(skb).fp && !other->sk_scm_rights) { in unix_dgram_sendmsg()
2260 err = security_unix_may_send(sk->sk_socket, other->sk_socket); in unix_dgram_sendmsg()
2265 /* other == sk && unix_peer(other) != sk if in unix_dgram_sendmsg()
2269 if (other != sk && in unix_dgram_sendmsg()
2270 unlikely(unix_peer(other) != sk && in unix_dgram_sendmsg()
2271 unix_recvq_full_lockless(other))) { in unix_dgram_sendmsg()
2273 timeo = unix_wait_for_peer(other, timeo); in unix_dgram_sendmsg()
2283 unix_state_unlock(other); in unix_dgram_sendmsg()
2284 unix_state_double_lock(sk, other); in unix_dgram_sendmsg()
2287 if (unix_peer(sk) != other || in unix_dgram_sendmsg()
2288 unix_dgram_peer_wake_me(sk, other)) { in unix_dgram_sendmsg()
2303 if (sock_flag(other, SOCK_RCVTSTAMP)) in unix_dgram_sendmsg()
2306 scm_stat_add(other, skb); in unix_dgram_sendmsg()
2307 skb_queue_tail(&other->sk_receive_queue, skb); in unix_dgram_sendmsg()
2308 unix_state_unlock(other); in unix_dgram_sendmsg()
2309 other->sk_data_ready(other); in unix_dgram_sendmsg()
2310 sock_put(other); in unix_dgram_sendmsg()
2317 unix_state_unlock(other); in unix_dgram_sendmsg()
2319 sock_put(other); in unix_dgram_sendmsg()
2333 static int queue_oob(struct sock *sk, struct msghdr *msg, struct sock *other, in queue_oob() argument
2336 struct unix_sock *ousk = unix_sk(other); in queue_oob()
2349 err = unix_maybe_add_creds(skb, sk, other); in queue_oob()
2359 unix_state_lock(other); in queue_oob()
2361 if (sock_flag(other, SOCK_DEAD) || in queue_oob()
2362 (other->sk_shutdown & RCV_SHUTDOWN)) { in queue_oob()
2367 if (UNIXCB(skb).fp && !other->sk_scm_rights) { in queue_oob()
2372 scm_stat_add(other, skb); in queue_oob()
2374 spin_lock(&other->sk_receive_queue.lock); in queue_oob()
2377 __skb_queue_tail(&other->sk_receive_queue, skb); in queue_oob()
2378 spin_unlock(&other->sk_receive_queue.lock); in queue_oob()
2380 sk_send_sigurg(other); in queue_oob()
2381 unix_state_unlock(other); in queue_oob()
2382 other->sk_data_ready(other); in queue_oob()
2386 unix_state_unlock(other); in queue_oob()
2398 struct sock *other = NULL; in unix_stream_sendmsg() local
2425 other = unix_peer(sk); in unix_stream_sendmsg()
2426 if (!other) { in unix_stream_sendmsg()
2431 otheru = unix_sk(other); in unix_stream_sendmsg()
2469 err = unix_maybe_add_creds(skb, sk, other); in unix_stream_sendmsg()
2490 unix_state_lock(other); in unix_stream_sendmsg()
2492 if (sock_flag(other, SOCK_DEAD) || in unix_stream_sendmsg()
2493 (other->sk_shutdown & RCV_SHUTDOWN)) in unix_stream_sendmsg()
2496 if (UNIXCB(skb).fp && !other->sk_scm_rights) { in unix_stream_sendmsg()
2497 unix_state_unlock(other); in unix_stream_sendmsg()
2502 scm_stat_add(other, skb); in unix_stream_sendmsg()
2504 spin_lock(&other->sk_receive_queue.lock); in unix_stream_sendmsg()
2506 __skb_queue_tail(&other->sk_receive_queue, skb); in unix_stream_sendmsg()
2507 spin_unlock(&other->sk_receive_queue.lock); in unix_stream_sendmsg()
2509 unix_state_unlock(other); in unix_stream_sendmsg()
2510 other->sk_data_ready(other); in unix_stream_sendmsg()
2516 err = queue_oob(sk, msg, other, &scm, fds_sent); in unix_stream_sendmsg()
2528 unix_state_unlock(other); in unix_stream_sendmsg()
3209 struct sock *other; in unix_shutdown() local
3222 other = unix_peer(sk); in unix_shutdown()
3223 if (other) in unix_shutdown()
3224 sock_hold(other); in unix_shutdown()
3228 if (other && in unix_shutdown()
3232 const struct proto *prot = READ_ONCE(other->sk_prot); in unix_shutdown()
3235 prot->unhash(other); in unix_shutdown()
3240 unix_state_lock(other); in unix_shutdown()
3241 WRITE_ONCE(other->sk_shutdown, other->sk_shutdown | peer_mode); in unix_shutdown()
3242 unix_state_unlock(other); in unix_shutdown()
3243 other->sk_state_change(other); in unix_shutdown()
3245 sk_wake_async(other, SOCK_WAKE_WAITD, POLL_HUP); in unix_shutdown()
3247 sk_wake_async(other, SOCK_WAKE_WAITD, POLL_IN); in unix_shutdown()
3249 if (other) in unix_shutdown()
3250 sock_put(other); in unix_shutdown()
3414 * we set writable also when the other side has shut down the in unix_poll()
3426 struct sock *sk = sock->sk, *other; in unix_dgram_poll() local
3466 other = unix_peer(sk); in unix_dgram_poll()
3467 if (other && unix_peer(other) != sk && in unix_dgram_poll()
3468 unix_recvq_full_lockless(other) && in unix_dgram_poll()
3469 unix_dgram_peer_wake_me(sk, other)) in unix_dgram_poll()