Lines Matching refs:other
386 static int unix_dgram_peer_wake_connect(struct sock *sk, struct sock *other) in unix_dgram_peer_wake_connect() argument
392 u_other = unix_sk(other); in unix_dgram_peer_wake_connect()
397 u->peer_wake.private = other; in unix_dgram_peer_wake_connect()
408 struct sock *other) in unix_dgram_peer_wake_disconnect() argument
413 u_other = unix_sk(other); in unix_dgram_peer_wake_disconnect()
416 if (u->peer_wake.private == other) { in unix_dgram_peer_wake_disconnect()
425 struct sock *other) in unix_dgram_peer_wake_disconnect_wakeup() argument
427 unix_dgram_peer_wake_disconnect(sk, other); in unix_dgram_peer_wake_disconnect_wakeup()
438 static int unix_dgram_peer_wake_me(struct sock *sk, struct sock *other) in unix_dgram_peer_wake_me() argument
442 connected = unix_dgram_peer_wake_connect(sk, other); in unix_dgram_peer_wake_me()
449 if (unix_recvq_full(other) && !sock_flag(other, SOCK_DEAD)) in unix_dgram_peer_wake_me()
453 unix_dgram_peer_wake_disconnect(sk, other); in unix_dgram_peer_wake_me()
483 static void unix_dgram_disconnected(struct sock *sk, struct sock *other) in unix_dgram_disconnected() argument
493 if (!sock_flag(other, SOCK_DEAD) && unix_peer(other) == sk) { in unix_dgram_disconnected()
494 other->sk_err = ECONNRESET; in unix_dgram_disconnected()
495 sk_error_report(other); in unix_dgram_disconnected()
498 other->sk_state = TCP_CLOSE; in unix_dgram_disconnected()
1219 struct sock *other; in unix_dgram_connect() local
1238 other = unix_find_other(net, sunaddr, alen, sock->type, hash, &err); in unix_dgram_connect()
1239 if (!other) in unix_dgram_connect()
1242 unix_state_double_lock(sk, other); in unix_dgram_connect()
1245 if (sock_flag(other, SOCK_DEAD)) { in unix_dgram_connect()
1246 unix_state_double_unlock(sk, other); in unix_dgram_connect()
1247 sock_put(other); in unix_dgram_connect()
1252 if (!unix_may_send(sk, other)) in unix_dgram_connect()
1255 err = security_unix_may_send(sk->sk_socket, other->sk_socket); in unix_dgram_connect()
1259 sk->sk_state = other->sk_state = TCP_ESTABLISHED; in unix_dgram_connect()
1264 other = NULL; in unix_dgram_connect()
1265 unix_state_double_lock(sk, other); in unix_dgram_connect()
1274 unix_peer(sk) = other; in unix_dgram_connect()
1275 if (!other) in unix_dgram_connect()
1279 unix_state_double_unlock(sk, other); in unix_dgram_connect()
1281 if (other != old_peer) in unix_dgram_connect()
1285 unix_peer(sk) = other; in unix_dgram_connect()
1286 unix_state_double_unlock(sk, other); in unix_dgram_connect()
1292 unix_state_double_unlock(sk, other); in unix_dgram_connect()
1293 sock_put(other); in unix_dgram_connect()
1298 static long unix_wait_for_peer(struct sock *other, long timeo) in unix_wait_for_peer() argument
1299 __releases(&unix_sk(other)->lock) in unix_wait_for_peer()
1301 struct unix_sock *u = unix_sk(other); in unix_wait_for_peer()
1307 sched = !sock_flag(other, SOCK_DEAD) && in unix_wait_for_peer()
1308 !(other->sk_shutdown & RCV_SHUTDOWN) && in unix_wait_for_peer()
1309 unix_recvq_full(other); in unix_wait_for_peer()
1311 unix_state_unlock(other); in unix_wait_for_peer()
1328 struct sock *other = NULL; in unix_stream_connect() local
1368 other = unix_find_other(net, sunaddr, addr_len, sk->sk_type, hash, &err); in unix_stream_connect()
1369 if (!other) in unix_stream_connect()
1373 unix_state_lock(other); in unix_stream_connect()
1376 if (sock_flag(other, SOCK_DEAD)) { in unix_stream_connect()
1377 unix_state_unlock(other); in unix_stream_connect()
1378 sock_put(other); in unix_stream_connect()
1383 if (other->sk_state != TCP_LISTEN) in unix_stream_connect()
1385 if (other->sk_shutdown & RCV_SHUTDOWN) in unix_stream_connect()
1388 if (unix_recvq_full(other)) { in unix_stream_connect()
1393 timeo = unix_wait_for_peer(other, timeo); in unix_stream_connect()
1398 sock_put(other); in unix_stream_connect()
1432 unix_state_unlock(other); in unix_stream_connect()
1433 sock_put(other); in unix_stream_connect()
1437 err = security_unix_stream_connect(sk, other, newsk); in unix_stream_connect()
1452 otheru = unix_sk(other); in unix_stream_connect()
1479 copy_peercred(sk, other); in unix_stream_connect()
1491 spin_lock(&other->sk_receive_queue.lock); in unix_stream_connect()
1492 __skb_queue_tail(&other->sk_receive_queue, skb); in unix_stream_connect()
1493 spin_unlock(&other->sk_receive_queue.lock); in unix_stream_connect()
1494 unix_state_unlock(other); in unix_stream_connect()
1495 other->sk_data_ready(other); in unix_stream_connect()
1496 sock_put(other); in unix_stream_connect()
1500 if (other) in unix_stream_connect()
1501 unix_state_unlock(other); in unix_stream_connect()
1507 if (other) in unix_stream_connect()
1508 sock_put(other); in unix_stream_connect()
1681 const struct sock *other) in unix_passcred_enabled() argument
1684 !other->sk_socket || in unix_passcred_enabled()
1685 test_bit(SOCK_PASSCRED, &other->sk_socket->flags); in unix_passcred_enabled()
1694 const struct sock *other) in maybe_add_creds() argument
1698 if (unix_passcred_enabled(sock, other)) { in maybe_add_creds()
1706 const struct sock *other) in maybe_init_creds() argument
1715 if (unix_passcred_enabled(socket, other)) { in maybe_init_creds()
1762 struct sock *other = NULL; in unix_dgram_sendmsg() local
1789 other = unix_peer_get(sk); in unix_dgram_sendmsg()
1790 if (!other) in unix_dgram_sendmsg()
1831 if (!other) { in unix_dgram_sendmsg()
1836 other = unix_find_other(net, sunaddr, namelen, sk->sk_type, in unix_dgram_sendmsg()
1838 if (other == NULL) in unix_dgram_sendmsg()
1842 if (sk_filter(other, skb) < 0) { in unix_dgram_sendmsg()
1849 unix_state_lock(other); in unix_dgram_sendmsg()
1852 if (!unix_may_send(sk, other)) in unix_dgram_sendmsg()
1855 if (unlikely(sock_flag(other, SOCK_DEAD))) { in unix_dgram_sendmsg()
1860 unix_state_unlock(other); in unix_dgram_sendmsg()
1861 sock_put(other); in unix_dgram_sendmsg()
1867 if (unix_peer(sk) == other) { in unix_dgram_sendmsg()
1869 unix_dgram_peer_wake_disconnect_wakeup(sk, other); in unix_dgram_sendmsg()
1874 unix_dgram_disconnected(sk, other); in unix_dgram_sendmsg()
1875 sock_put(other); in unix_dgram_sendmsg()
1881 other = NULL; in unix_dgram_sendmsg()
1888 if (other->sk_shutdown & RCV_SHUTDOWN) in unix_dgram_sendmsg()
1892 err = security_unix_may_send(sk->sk_socket, other->sk_socket); in unix_dgram_sendmsg()
1901 if (other != sk && in unix_dgram_sendmsg()
1902 unlikely(unix_peer(other) != sk && in unix_dgram_sendmsg()
1903 unix_recvq_full_lockless(other))) { in unix_dgram_sendmsg()
1905 timeo = unix_wait_for_peer(other, timeo); in unix_dgram_sendmsg()
1915 unix_state_unlock(other); in unix_dgram_sendmsg()
1916 unix_state_double_lock(sk, other); in unix_dgram_sendmsg()
1919 if (unix_peer(sk) != other || in unix_dgram_sendmsg()
1920 unix_dgram_peer_wake_me(sk, other)) { in unix_dgram_sendmsg()
1935 if (sock_flag(other, SOCK_RCVTSTAMP)) in unix_dgram_sendmsg()
1937 maybe_add_creds(skb, sock, other); in unix_dgram_sendmsg()
1938 scm_stat_add(other, skb); in unix_dgram_sendmsg()
1939 skb_queue_tail(&other->sk_receive_queue, skb); in unix_dgram_sendmsg()
1940 unix_state_unlock(other); in unix_dgram_sendmsg()
1941 other->sk_data_ready(other); in unix_dgram_sendmsg()
1942 sock_put(other); in unix_dgram_sendmsg()
1949 unix_state_unlock(other); in unix_dgram_sendmsg()
1953 if (other) in unix_dgram_sendmsg()
1954 sock_put(other); in unix_dgram_sendmsg()
1965 static int queue_oob(struct socket *sock, struct msghdr *msg, struct sock *other) in queue_oob() argument
1967 struct unix_sock *ousk = unix_sk(other); in queue_oob()
1984 unix_state_lock(other); in queue_oob()
1986 if (sock_flag(other, SOCK_DEAD) || in queue_oob()
1987 (other->sk_shutdown & RCV_SHUTDOWN)) { in queue_oob()
1988 unix_state_unlock(other); in queue_oob()
1993 maybe_add_creds(skb, sock, other); in queue_oob()
2001 scm_stat_add(other, skb); in queue_oob()
2002 skb_queue_tail(&other->sk_receive_queue, skb); in queue_oob()
2003 sk_send_sigurg(other); in queue_oob()
2004 unix_state_unlock(other); in queue_oob()
2005 other->sk_data_ready(other); in queue_oob()
2015 struct sock *other = NULL; in unix_stream_sendmsg() local
2043 other = unix_peer(sk); in unix_stream_sendmsg()
2044 if (!other) in unix_stream_sendmsg()
2087 unix_state_lock(other); in unix_stream_sendmsg()
2089 if (sock_flag(other, SOCK_DEAD) || in unix_stream_sendmsg()
2090 (other->sk_shutdown & RCV_SHUTDOWN)) in unix_stream_sendmsg()
2093 maybe_add_creds(skb, sock, other); in unix_stream_sendmsg()
2094 scm_stat_add(other, skb); in unix_stream_sendmsg()
2095 skb_queue_tail(&other->sk_receive_queue, skb); in unix_stream_sendmsg()
2096 unix_state_unlock(other); in unix_stream_sendmsg()
2097 other->sk_data_ready(other); in unix_stream_sendmsg()
2103 err = queue_oob(sock, msg, other); in unix_stream_sendmsg()
2115 unix_state_unlock(other); in unix_stream_sendmsg()
2133 struct sock *other, *sk = socket->sk; in unix_stream_sendpage() local
2139 other = unix_peer(sk); in unix_stream_sendpage()
2140 if (!other || sk->sk_state != TCP_ESTABLISHED) in unix_stream_sendpage()
2145 unix_state_unlock(other); in unix_stream_sendpage()
2146 mutex_unlock(&unix_sk(other)->iolock); in unix_stream_sendpage()
2156 err = mutex_lock_interruptible(&unix_sk(other)->iolock); in unix_stream_sendpage()
2168 unix_state_lock(other); in unix_stream_sendpage()
2170 if (sock_flag(other, SOCK_DEAD) || in unix_stream_sendpage()
2171 other->sk_shutdown & RCV_SHUTDOWN) { in unix_stream_sendpage()
2178 err = maybe_init_creds(&scm, socket, other); in unix_stream_sendpage()
2184 skb = skb_peek_tail(&other->sk_receive_queue); in unix_stream_sendpage()
2217 spin_lock(&other->sk_receive_queue.lock); in unix_stream_sendpage()
2218 __skb_queue_tail(&other->sk_receive_queue, newskb); in unix_stream_sendpage()
2219 spin_unlock(&other->sk_receive_queue.lock); in unix_stream_sendpage()
2222 unix_state_unlock(other); in unix_stream_sendpage()
2223 mutex_unlock(&unix_sk(other)->iolock); in unix_stream_sendpage()
2225 other->sk_data_ready(other); in unix_stream_sendpage()
2230 unix_state_unlock(other); in unix_stream_sendpage()
2232 mutex_unlock(&unix_sk(other)->iolock); in unix_stream_sendpage()
2872 struct sock *other; in unix_shutdown() local
2885 other = unix_peer(sk); in unix_shutdown()
2886 if (other) in unix_shutdown()
2887 sock_hold(other); in unix_shutdown()
2891 if (other && in unix_shutdown()
2895 const struct proto *prot = READ_ONCE(other->sk_prot); in unix_shutdown()
2898 prot->unhash(other); in unix_shutdown()
2903 unix_state_lock(other); in unix_shutdown()
2904 other->sk_shutdown |= peer_mode; in unix_shutdown()
2905 unix_state_unlock(other); in unix_shutdown()
2906 other->sk_state_change(other); in unix_shutdown()
2908 sk_wake_async(other, SOCK_WAKE_WAITD, POLL_HUP); in unix_shutdown()
2910 sk_wake_async(other, SOCK_WAKE_WAITD, POLL_IN); in unix_shutdown()
2912 if (other) in unix_shutdown()
2913 sock_put(other); in unix_shutdown()
3073 struct sock *sk = sock->sk, *other; in unix_dgram_poll() local
3113 other = unix_peer(sk); in unix_dgram_poll()
3114 if (other && unix_peer(other) != sk && in unix_dgram_poll()
3115 unix_recvq_full_lockless(other) && in unix_dgram_poll()
3116 unix_dgram_peer_wake_me(sk, other)) in unix_dgram_poll()