Lines Matching refs:other
456 static int unix_dgram_peer_wake_connect(struct sock *sk, struct sock *other) in unix_dgram_peer_wake_connect() argument
462 u_other = unix_sk(other); in unix_dgram_peer_wake_connect()
467 u->peer_wake.private = other; in unix_dgram_peer_wake_connect()
478 struct sock *other) in unix_dgram_peer_wake_disconnect() argument
483 u_other = unix_sk(other); in unix_dgram_peer_wake_disconnect()
486 if (u->peer_wake.private == other) { in unix_dgram_peer_wake_disconnect()
495 struct sock *other) in unix_dgram_peer_wake_disconnect_wakeup() argument
497 unix_dgram_peer_wake_disconnect(sk, other); in unix_dgram_peer_wake_disconnect_wakeup()
508 static int unix_dgram_peer_wake_me(struct sock *sk, struct sock *other) in unix_dgram_peer_wake_me() argument
512 connected = unix_dgram_peer_wake_connect(sk, other); in unix_dgram_peer_wake_me()
519 if (unix_recvq_full_lockless(other) && !sock_flag(other, SOCK_DEAD)) in unix_dgram_peer_wake_me()
523 unix_dgram_peer_wake_disconnect(sk, other); in unix_dgram_peer_wake_me()
553 static void unix_dgram_disconnected(struct sock *sk, struct sock *other) in unix_dgram_disconnected() argument
563 if (!sock_flag(other, SOCK_DEAD) && unix_peer(other) == sk) { in unix_dgram_disconnected()
564 WRITE_ONCE(other->sk_err, ECONNRESET); in unix_dgram_disconnected()
565 sk_error_report(other); in unix_dgram_disconnected()
1365 struct sock *other; in unix_dgram_connect() local
1386 other = unix_find_other(sock_net(sk), sunaddr, alen, sock->type); in unix_dgram_connect()
1387 if (IS_ERR(other)) { in unix_dgram_connect()
1388 err = PTR_ERR(other); in unix_dgram_connect()
1392 unix_state_double_lock(sk, other); in unix_dgram_connect()
1395 if (sock_flag(other, SOCK_DEAD)) { in unix_dgram_connect()
1396 unix_state_double_unlock(sk, other); in unix_dgram_connect()
1397 sock_put(other); in unix_dgram_connect()
1402 if (!unix_may_send(sk, other)) in unix_dgram_connect()
1405 err = security_unix_may_send(sk->sk_socket, other->sk_socket); in unix_dgram_connect()
1410 WRITE_ONCE(other->sk_state, TCP_ESTABLISHED); in unix_dgram_connect()
1415 other = NULL; in unix_dgram_connect()
1416 unix_state_double_lock(sk, other); in unix_dgram_connect()
1425 unix_peer(sk) = other; in unix_dgram_connect()
1426 if (!other) in unix_dgram_connect()
1430 unix_state_double_unlock(sk, other); in unix_dgram_connect()
1432 if (other != old_peer) { in unix_dgram_connect()
1443 unix_peer(sk) = other; in unix_dgram_connect()
1444 unix_state_double_unlock(sk, other); in unix_dgram_connect()
1450 unix_state_double_unlock(sk, other); in unix_dgram_connect()
1451 sock_put(other); in unix_dgram_connect()
1456 static long unix_wait_for_peer(struct sock *other, long timeo) in unix_wait_for_peer() argument
1457 __releases(&unix_sk(other)->lock) in unix_wait_for_peer()
1459 struct unix_sock *u = unix_sk(other); in unix_wait_for_peer()
1465 sched = !sock_flag(other, SOCK_DEAD) && in unix_wait_for_peer()
1466 !(other->sk_shutdown & RCV_SHUTDOWN) && in unix_wait_for_peer()
1467 unix_recvq_full_lockless(other); in unix_wait_for_peer()
1469 unix_state_unlock(other); in unix_wait_for_peer()
1482 struct sock *sk = sock->sk, *newsk = NULL, *other = NULL; in unix_stream_connect() local
1526 other = unix_find_other(net, sunaddr, addr_len, sk->sk_type); in unix_stream_connect()
1527 if (IS_ERR(other)) { in unix_stream_connect()
1528 err = PTR_ERR(other); in unix_stream_connect()
1529 other = NULL; in unix_stream_connect()
1533 unix_state_lock(other); in unix_stream_connect()
1536 if (sock_flag(other, SOCK_DEAD)) { in unix_stream_connect()
1537 unix_state_unlock(other); in unix_stream_connect()
1538 sock_put(other); in unix_stream_connect()
1543 if (other->sk_state != TCP_LISTEN) in unix_stream_connect()
1545 if (other->sk_shutdown & RCV_SHUTDOWN) in unix_stream_connect()
1548 if (unix_recvq_full_lockless(other)) { in unix_stream_connect()
1553 timeo = unix_wait_for_peer(other, timeo); in unix_stream_connect()
1558 sock_put(other); in unix_stream_connect()
1579 err = security_unix_stream_connect(sk, other, newsk); in unix_stream_connect()
1594 otheru = unix_sk(other); in unix_stream_connect()
1621 copy_peercred(sk, other); in unix_stream_connect()
1633 spin_lock(&other->sk_receive_queue.lock); in unix_stream_connect()
1634 __skb_queue_tail(&other->sk_receive_queue, skb); in unix_stream_connect()
1635 spin_unlock(&other->sk_receive_queue.lock); in unix_stream_connect()
1636 unix_state_unlock(other); in unix_stream_connect()
1637 other->sk_data_ready(other); in unix_stream_connect()
1638 sock_put(other); in unix_stream_connect()
1642 if (other) in unix_stream_connect()
1643 unix_state_unlock(other); in unix_stream_connect()
1649 if (other) in unix_stream_connect()
1650 sock_put(other); in unix_stream_connect()
1826 const struct sock *other) in unix_passcred_enabled() argument
1830 !other->sk_socket || in unix_passcred_enabled()
1831 test_bit(SOCK_PASSCRED, &other->sk_socket->flags) || in unix_passcred_enabled()
1832 test_bit(SOCK_PASSPIDFD, &other->sk_socket->flags); in unix_passcred_enabled()
1841 const struct sock *other) in maybe_add_creds() argument
1845 if (unix_passcred_enabled(sock, other)) { in maybe_add_creds()
1886 struct sock *sk = sock->sk, *other = NULL; in unix_dgram_sendmsg() local
1911 other = unix_peer_get(sk); in unix_dgram_sendmsg()
1912 if (!other) in unix_dgram_sendmsg()
1957 if (!other) { in unix_dgram_sendmsg()
1962 other = unix_find_other(sock_net(sk), sunaddr, msg->msg_namelen, in unix_dgram_sendmsg()
1964 if (IS_ERR(other)) { in unix_dgram_sendmsg()
1965 err = PTR_ERR(other); in unix_dgram_sendmsg()
1966 other = NULL; in unix_dgram_sendmsg()
1971 if (sk_filter(other, skb) < 0) { in unix_dgram_sendmsg()
1978 unix_state_lock(other); in unix_dgram_sendmsg()
1981 if (!unix_may_send(sk, other)) in unix_dgram_sendmsg()
1984 if (unlikely(sock_flag(other, SOCK_DEAD))) { in unix_dgram_sendmsg()
1989 unix_state_unlock(other); in unix_dgram_sendmsg()
1990 sock_put(other); in unix_dgram_sendmsg()
2003 } else if (unix_peer(sk) == other) { in unix_dgram_sendmsg()
2005 unix_dgram_peer_wake_disconnect_wakeup(sk, other); in unix_dgram_sendmsg()
2010 unix_dgram_disconnected(sk, other); in unix_dgram_sendmsg()
2011 sock_put(other); in unix_dgram_sendmsg()
2017 other = NULL; in unix_dgram_sendmsg()
2024 if (other->sk_shutdown & RCV_SHUTDOWN) in unix_dgram_sendmsg()
2028 err = security_unix_may_send(sk->sk_socket, other->sk_socket); in unix_dgram_sendmsg()
2037 if (other != sk && in unix_dgram_sendmsg()
2038 unlikely(unix_peer(other) != sk && in unix_dgram_sendmsg()
2039 unix_recvq_full_lockless(other))) { in unix_dgram_sendmsg()
2041 timeo = unix_wait_for_peer(other, timeo); in unix_dgram_sendmsg()
2051 unix_state_unlock(other); in unix_dgram_sendmsg()
2052 unix_state_double_lock(sk, other); in unix_dgram_sendmsg()
2055 if (unix_peer(sk) != other || in unix_dgram_sendmsg()
2056 unix_dgram_peer_wake_me(sk, other)) { in unix_dgram_sendmsg()
2071 if (sock_flag(other, SOCK_RCVTSTAMP)) in unix_dgram_sendmsg()
2073 maybe_add_creds(skb, sock, other); in unix_dgram_sendmsg()
2074 scm_stat_add(other, skb); in unix_dgram_sendmsg()
2075 skb_queue_tail(&other->sk_receive_queue, skb); in unix_dgram_sendmsg()
2076 unix_state_unlock(other); in unix_dgram_sendmsg()
2077 other->sk_data_ready(other); in unix_dgram_sendmsg()
2078 sock_put(other); in unix_dgram_sendmsg()
2085 unix_state_unlock(other); in unix_dgram_sendmsg()
2089 if (other) in unix_dgram_sendmsg()
2090 sock_put(other); in unix_dgram_sendmsg()
2101 static int queue_oob(struct socket *sock, struct msghdr *msg, struct sock *other, in queue_oob() argument
2104 struct unix_sock *ousk = unix_sk(other); in queue_oob()
2126 unix_state_lock(other); in queue_oob()
2128 if (sock_flag(other, SOCK_DEAD) || in queue_oob()
2129 (other->sk_shutdown & RCV_SHUTDOWN)) { in queue_oob()
2130 unix_state_unlock(other); in queue_oob()
2135 maybe_add_creds(skb, sock, other); in queue_oob()
2138 scm_stat_add(other, skb); in queue_oob()
2140 spin_lock(&other->sk_receive_queue.lock); in queue_oob()
2144 __skb_queue_tail(&other->sk_receive_queue, skb); in queue_oob()
2145 spin_unlock(&other->sk_receive_queue.lock); in queue_oob()
2147 sk_send_sigurg(other); in queue_oob()
2148 unix_state_unlock(other); in queue_oob()
2149 other->sk_data_ready(other); in queue_oob()
2159 struct sock *other = NULL; in unix_stream_sendmsg() local
2187 other = unix_peer(sk); in unix_stream_sendmsg()
2188 if (!other) in unix_stream_sendmsg()
2248 unix_state_lock(other); in unix_stream_sendmsg()
2250 if (sock_flag(other, SOCK_DEAD) || in unix_stream_sendmsg()
2251 (other->sk_shutdown & RCV_SHUTDOWN)) in unix_stream_sendmsg()
2254 maybe_add_creds(skb, sock, other); in unix_stream_sendmsg()
2255 scm_stat_add(other, skb); in unix_stream_sendmsg()
2256 skb_queue_tail(&other->sk_receive_queue, skb); in unix_stream_sendmsg()
2257 unix_state_unlock(other); in unix_stream_sendmsg()
2258 other->sk_data_ready(other); in unix_stream_sendmsg()
2264 err = queue_oob(sock, msg, other, &scm, fds_sent); in unix_stream_sendmsg()
2276 unix_state_unlock(other); in unix_stream_sendmsg()
2949 struct sock *other; in unix_shutdown() local
2962 other = unix_peer(sk); in unix_shutdown()
2963 if (other) in unix_shutdown()
2964 sock_hold(other); in unix_shutdown()
2968 if (other && in unix_shutdown()
2972 const struct proto *prot = READ_ONCE(other->sk_prot); in unix_shutdown()
2975 prot->unhash(other); in unix_shutdown()
2980 unix_state_lock(other); in unix_shutdown()
2981 WRITE_ONCE(other->sk_shutdown, other->sk_shutdown | peer_mode); in unix_shutdown()
2982 unix_state_unlock(other); in unix_shutdown()
2983 other->sk_state_change(other); in unix_shutdown()
2985 sk_wake_async(other, SOCK_WAKE_WAITD, POLL_HUP); in unix_shutdown()
2987 sk_wake_async(other, SOCK_WAKE_WAITD, POLL_IN); in unix_shutdown()
2989 if (other) in unix_shutdown()
2990 sock_put(other); in unix_shutdown()
3157 struct sock *sk = sock->sk, *other; in unix_dgram_poll() local
3197 other = unix_peer(sk); in unix_dgram_poll()
3198 if (other && unix_peer(other) != sk && in unix_dgram_poll()
3199 unix_recvq_full_lockless(other) && in unix_dgram_poll()
3200 unix_dgram_peer_wake_me(sk, other)) in unix_dgram_poll()