Lines Matching full:other

52  *		other the moment one end closes.
530 static int unix_dgram_peer_wake_connect(struct sock *sk, struct sock *other) in unix_dgram_peer_wake_connect() argument
536 u_other = unix_sk(other); in unix_dgram_peer_wake_connect()
541 u->peer_wake.private = other; in unix_dgram_peer_wake_connect()
552 struct sock *other) in unix_dgram_peer_wake_disconnect() argument
557 u_other = unix_sk(other); in unix_dgram_peer_wake_disconnect()
560 if (u->peer_wake.private == other) { in unix_dgram_peer_wake_disconnect()
569 struct sock *other) in unix_dgram_peer_wake_disconnect_wakeup() argument
571 unix_dgram_peer_wake_disconnect(sk, other); in unix_dgram_peer_wake_disconnect_wakeup()
579 * - unix_peer(sk) == other
582 static int unix_dgram_peer_wake_me(struct sock *sk, struct sock *other) in unix_dgram_peer_wake_me() argument
586 connected = unix_dgram_peer_wake_connect(sk, other); in unix_dgram_peer_wake_me()
588 /* If other is SOCK_DEAD, we want to make sure we signal in unix_dgram_peer_wake_me()
591 * to other and its full, we will hang waiting for POLLOUT. in unix_dgram_peer_wake_me()
593 if (unix_recvq_full_lockless(other) && !sock_flag(other, SOCK_DEAD)) in unix_dgram_peer_wake_me()
597 unix_dgram_peer_wake_disconnect(sk, other); in unix_dgram_peer_wake_me()
627 static void unix_dgram_disconnected(struct sock *sk, struct sock *other) in unix_dgram_disconnected() argument
637 if (!sock_flag(other, SOCK_DEAD) && unix_peer(other) == sk) { in unix_dgram_disconnected()
638 WRITE_ONCE(other->sk_err, ECONNRESET); in unix_dgram_disconnected()
639 sk_error_report(other); in unix_dgram_disconnected()
1418 struct sock *other; in unix_dgram_connect() local
1443 other = unix_find_other(sock_net(sk), sunaddr, alen, sock->type); in unix_dgram_connect()
1444 if (IS_ERR(other)) { in unix_dgram_connect()
1445 err = PTR_ERR(other); in unix_dgram_connect()
1449 unix_state_double_lock(sk, other); in unix_dgram_connect()
1452 if (sock_flag(other, SOCK_DEAD)) { in unix_dgram_connect()
1453 unix_state_double_unlock(sk, other); in unix_dgram_connect()
1454 sock_put(other); in unix_dgram_connect()
1459 if (!unix_may_send(sk, other)) in unix_dgram_connect()
1462 err = security_unix_may_send(sk->sk_socket, other->sk_socket); in unix_dgram_connect()
1467 WRITE_ONCE(other->sk_state, TCP_ESTABLISHED); in unix_dgram_connect()
1472 other = NULL; in unix_dgram_connect()
1473 unix_state_double_lock(sk, other); in unix_dgram_connect()
1482 unix_peer(sk) = other; in unix_dgram_connect()
1483 if (!other) in unix_dgram_connect()
1487 unix_state_double_unlock(sk, other); in unix_dgram_connect()
1489 if (other != old_peer) { in unix_dgram_connect()
1500 unix_peer(sk) = other; in unix_dgram_connect()
1501 unix_state_double_unlock(sk, other); in unix_dgram_connect()
1507 unix_state_double_unlock(sk, other); in unix_dgram_connect()
1508 sock_put(other); in unix_dgram_connect()
1513 static long unix_wait_for_peer(struct sock *other, long timeo) in unix_wait_for_peer() argument
1514 __releases(&unix_sk(other)->lock) in unix_wait_for_peer()
1516 struct unix_sock *u = unix_sk(other); in unix_wait_for_peer()
1522 sched = !sock_flag(other, SOCK_DEAD) && in unix_wait_for_peer()
1523 !(other->sk_shutdown & RCV_SHUTDOWN) && in unix_wait_for_peer()
1524 unix_recvq_full_lockless(other); in unix_wait_for_peer()
1526 unix_state_unlock(other); in unix_wait_for_peer()
1539 struct sock *sk = sock->sk, *newsk = NULL, *other = NULL; in unix_stream_connect() local
1587 other = unix_find_other(net, sunaddr, addr_len, sk->sk_type); in unix_stream_connect()
1588 if (IS_ERR(other)) { in unix_stream_connect()
1589 err = PTR_ERR(other); in unix_stream_connect()
1590 other = NULL; in unix_stream_connect()
1594 unix_state_lock(other); in unix_stream_connect()
1597 if (sock_flag(other, SOCK_DEAD)) { in unix_stream_connect()
1598 unix_state_unlock(other); in unix_stream_connect()
1599 sock_put(other); in unix_stream_connect()
1604 if (other->sk_state != TCP_LISTEN) in unix_stream_connect()
1606 if (other->sk_shutdown & RCV_SHUTDOWN) in unix_stream_connect()
1609 if (unix_recvq_full_lockless(other)) { in unix_stream_connect()
1614 timeo = unix_wait_for_peer(other, timeo); in unix_stream_connect()
1619 sock_put(other); in unix_stream_connect()
1640 err = security_unix_stream_connect(sk, other, newsk); in unix_stream_connect()
1654 newu->listener = other; in unix_stream_connect()
1656 otheru = unix_sk(other); in unix_stream_connect()
1683 copy_peercred(sk, other); in unix_stream_connect()
1695 spin_lock(&other->sk_receive_queue.lock); in unix_stream_connect()
1696 __skb_queue_tail(&other->sk_receive_queue, skb); in unix_stream_connect()
1697 spin_unlock(&other->sk_receive_queue.lock); in unix_stream_connect()
1698 unix_state_unlock(other); in unix_stream_connect()
1699 other->sk_data_ready(other); in unix_stream_connect()
1700 sock_put(other); in unix_stream_connect()
1704 if (other) in unix_stream_connect()
1705 unix_state_unlock(other); in unix_stream_connect()
1711 if (other) in unix_stream_connect()
1712 sock_put(other); in unix_stream_connect()
1904 const struct sock *other) in unix_passcred_enabled() argument
1908 !other->sk_socket || in unix_passcred_enabled()
1909 test_bit(SOCK_PASSCRED, &other->sk_socket->flags) || in unix_passcred_enabled()
1910 test_bit(SOCK_PASSPIDFD, &other->sk_socket->flags); in unix_passcred_enabled()
1919 const struct sock *other) in maybe_add_creds() argument
1923 if (unix_passcred_enabled(sock, other)) { in maybe_add_creds()
1968 struct sock *sk = sock->sk, *other = NULL; in unix_dgram_sendmsg() local
2001 other = unix_peer_get(sk); in unix_dgram_sendmsg()
2002 if (!other) in unix_dgram_sendmsg()
2047 if (!other) { in unix_dgram_sendmsg()
2052 other = unix_find_other(sock_net(sk), sunaddr, msg->msg_namelen, in unix_dgram_sendmsg()
2054 if (IS_ERR(other)) { in unix_dgram_sendmsg()
2055 err = PTR_ERR(other); in unix_dgram_sendmsg()
2056 other = NULL; in unix_dgram_sendmsg()
2061 if (sk_filter(other, skb) < 0) { in unix_dgram_sendmsg()
2068 unix_state_lock(other); in unix_dgram_sendmsg()
2071 if (!unix_may_send(sk, other)) in unix_dgram_sendmsg()
2074 if (unlikely(sock_flag(other, SOCK_DEAD))) { in unix_dgram_sendmsg()
2079 unix_state_unlock(other); in unix_dgram_sendmsg()
2080 sock_put(other); in unix_dgram_sendmsg()
2088 * is clearing @other. Never change state to TCP_CLOSE in unix_dgram_sendmsg()
2093 } else if (unix_peer(sk) == other) { in unix_dgram_sendmsg()
2095 unix_dgram_peer_wake_disconnect_wakeup(sk, other); in unix_dgram_sendmsg()
2100 unix_dgram_disconnected(sk, other); in unix_dgram_sendmsg()
2101 sock_put(other); in unix_dgram_sendmsg()
2107 other = NULL; in unix_dgram_sendmsg()
2114 if (other->sk_shutdown & RCV_SHUTDOWN) in unix_dgram_sendmsg()
2118 err = security_unix_may_send(sk->sk_socket, other->sk_socket); in unix_dgram_sendmsg()
2123 /* other == sk && unix_peer(other) != sk if in unix_dgram_sendmsg()
2127 if (other != sk && in unix_dgram_sendmsg()
2128 unlikely(unix_peer(other) != sk && in unix_dgram_sendmsg()
2129 unix_recvq_full_lockless(other))) { in unix_dgram_sendmsg()
2131 timeo = unix_wait_for_peer(other, timeo); in unix_dgram_sendmsg()
2141 unix_state_unlock(other); in unix_dgram_sendmsg()
2142 unix_state_double_lock(sk, other); in unix_dgram_sendmsg()
2145 if (unix_peer(sk) != other || in unix_dgram_sendmsg()
2146 unix_dgram_peer_wake_me(sk, other)) { in unix_dgram_sendmsg()
2161 if (sock_flag(other, SOCK_RCVTSTAMP)) in unix_dgram_sendmsg()
2163 maybe_add_creds(skb, sock, other); in unix_dgram_sendmsg()
2164 scm_stat_add(other, skb); in unix_dgram_sendmsg()
2165 skb_queue_tail(&other->sk_receive_queue, skb); in unix_dgram_sendmsg()
2166 unix_state_unlock(other); in unix_dgram_sendmsg()
2167 other->sk_data_ready(other); in unix_dgram_sendmsg()
2168 sock_put(other); in unix_dgram_sendmsg()
2175 unix_state_unlock(other); in unix_dgram_sendmsg()
2179 if (other) in unix_dgram_sendmsg()
2180 sock_put(other); in unix_dgram_sendmsg()
2191 static int queue_oob(struct socket *sock, struct msghdr *msg, struct sock *other, in queue_oob() argument
2194 struct unix_sock *ousk = unix_sk(other); in queue_oob()
2216 unix_state_lock(other); in queue_oob()
2218 if (sock_flag(other, SOCK_DEAD) || in queue_oob()
2219 (other->sk_shutdown & RCV_SHUTDOWN)) { in queue_oob()
2220 unix_state_unlock(other); in queue_oob()
2225 maybe_add_creds(skb, sock, other); in queue_oob()
2226 scm_stat_add(other, skb); in queue_oob()
2228 spin_lock(&other->sk_receive_queue.lock); in queue_oob()
2230 __skb_queue_tail(&other->sk_receive_queue, skb); in queue_oob()
2231 spin_unlock(&other->sk_receive_queue.lock); in queue_oob()
2233 sk_send_sigurg(other); in queue_oob()
2234 unix_state_unlock(other); in queue_oob()
2235 other->sk_data_ready(other); in queue_oob()
2245 struct sock *other = NULL; in unix_stream_sendmsg() local
2274 other = unix_peer(sk); in unix_stream_sendmsg()
2275 if (!other) in unix_stream_sendmsg()
2336 unix_state_lock(other); in unix_stream_sendmsg()
2338 if (sock_flag(other, SOCK_DEAD) || in unix_stream_sendmsg()
2339 (other->sk_shutdown & RCV_SHUTDOWN)) in unix_stream_sendmsg()
2342 maybe_add_creds(skb, sock, other); in unix_stream_sendmsg()
2343 scm_stat_add(other, skb); in unix_stream_sendmsg()
2344 skb_queue_tail(&other->sk_receive_queue, skb); in unix_stream_sendmsg()
2345 unix_state_unlock(other); in unix_stream_sendmsg()
2346 other->sk_data_ready(other); in unix_stream_sendmsg()
2352 err = queue_oob(sock, msg, other, &scm, fds_sent); in unix_stream_sendmsg()
2364 unix_state_unlock(other); in unix_stream_sendmsg()
3035 struct sock *other; in unix_shutdown() local
3048 other = unix_peer(sk); in unix_shutdown()
3049 if (other) in unix_shutdown()
3050 sock_hold(other); in unix_shutdown()
3054 if (other && in unix_shutdown()
3058 const struct proto *prot = READ_ONCE(other->sk_prot); in unix_shutdown()
3061 prot->unhash(other); in unix_shutdown()
3066 unix_state_lock(other); in unix_shutdown()
3067 WRITE_ONCE(other->sk_shutdown, other->sk_shutdown | peer_mode); in unix_shutdown()
3068 unix_state_unlock(other); in unix_shutdown()
3069 other->sk_state_change(other); in unix_shutdown()
3071 sk_wake_async(other, SOCK_WAKE_WAITD, POLL_HUP); in unix_shutdown()
3073 sk_wake_async(other, SOCK_WAKE_WAITD, POLL_IN); in unix_shutdown()
3075 if (other) in unix_shutdown()
3076 sock_put(other); in unix_shutdown()
3246 * we set writable also when the other side has shut down the in unix_poll()
3258 struct sock *sk = sock->sk, *other; in unix_dgram_poll() local
3298 other = unix_peer(sk); in unix_dgram_poll()
3299 if (other && unix_peer(other) != sk && in unix_dgram_poll()
3300 unix_recvq_full_lockless(other) && in unix_dgram_poll()
3301 unix_dgram_peer_wake_me(sk, other)) in unix_dgram_poll()