Lines Matching refs:other
380 static int unix_dgram_peer_wake_connect(struct sock *sk, struct sock *other) in unix_dgram_peer_wake_connect() argument
386 u_other = unix_sk(other); in unix_dgram_peer_wake_connect()
391 u->peer_wake.private = other; in unix_dgram_peer_wake_connect()
402 struct sock *other) in unix_dgram_peer_wake_disconnect() argument
407 u_other = unix_sk(other); in unix_dgram_peer_wake_disconnect()
410 if (u->peer_wake.private == other) { in unix_dgram_peer_wake_disconnect()
419 struct sock *other) in unix_dgram_peer_wake_disconnect_wakeup() argument
421 unix_dgram_peer_wake_disconnect(sk, other); in unix_dgram_peer_wake_disconnect_wakeup()
432 static int unix_dgram_peer_wake_me(struct sock *sk, struct sock *other) in unix_dgram_peer_wake_me() argument
436 connected = unix_dgram_peer_wake_connect(sk, other); in unix_dgram_peer_wake_me()
443 if (unix_recvq_full_lockless(other) && !sock_flag(other, SOCK_DEAD)) in unix_dgram_peer_wake_me()
447 unix_dgram_peer_wake_disconnect(sk, other); in unix_dgram_peer_wake_me()
477 static void unix_dgram_disconnected(struct sock *sk, struct sock *other) in unix_dgram_disconnected() argument
487 if (!sock_flag(other, SOCK_DEAD) && unix_peer(other) == sk) { in unix_dgram_disconnected()
488 other->sk_err = ECONNRESET; in unix_dgram_disconnected()
489 other->sk_error_report(other); in unix_dgram_disconnected()
1144 struct sock *other; in unix_dgram_connect() local
1163 other = unix_find_other(net, sunaddr, alen, sock->type, hash, &err); in unix_dgram_connect()
1164 if (!other) in unix_dgram_connect()
1167 unix_state_double_lock(sk, other); in unix_dgram_connect()
1170 if (sock_flag(other, SOCK_DEAD)) { in unix_dgram_connect()
1171 unix_state_double_unlock(sk, other); in unix_dgram_connect()
1172 sock_put(other); in unix_dgram_connect()
1177 if (!unix_may_send(sk, other)) in unix_dgram_connect()
1180 err = security_unix_may_send(sk->sk_socket, other->sk_socket); in unix_dgram_connect()
1188 other = NULL; in unix_dgram_connect()
1189 unix_state_double_lock(sk, other); in unix_dgram_connect()
1197 unix_peer(sk) = other; in unix_dgram_connect()
1200 unix_state_double_unlock(sk, other); in unix_dgram_connect()
1202 if (other != old_peer) in unix_dgram_connect()
1206 unix_peer(sk) = other; in unix_dgram_connect()
1207 unix_state_double_unlock(sk, other); in unix_dgram_connect()
1212 unix_state_double_unlock(sk, other); in unix_dgram_connect()
1213 sock_put(other); in unix_dgram_connect()
1218 static long unix_wait_for_peer(struct sock *other, long timeo) in unix_wait_for_peer() argument
1220 struct unix_sock *u = unix_sk(other); in unix_wait_for_peer()
1226 sched = !sock_flag(other, SOCK_DEAD) && in unix_wait_for_peer()
1227 !(other->sk_shutdown & RCV_SHUTDOWN) && in unix_wait_for_peer()
1228 unix_recvq_full_lockless(other); in unix_wait_for_peer()
1230 unix_state_unlock(other); in unix_wait_for_peer()
1247 struct sock *other = NULL; in unix_stream_connect() local
1284 other = unix_find_other(net, sunaddr, addr_len, sk->sk_type, hash, &err); in unix_stream_connect()
1285 if (!other) in unix_stream_connect()
1289 unix_state_lock(other); in unix_stream_connect()
1292 if (sock_flag(other, SOCK_DEAD)) { in unix_stream_connect()
1293 unix_state_unlock(other); in unix_stream_connect()
1294 sock_put(other); in unix_stream_connect()
1299 if (other->sk_state != TCP_LISTEN) in unix_stream_connect()
1301 if (other->sk_shutdown & RCV_SHUTDOWN) in unix_stream_connect()
1304 if (unix_recvq_full(other)) { in unix_stream_connect()
1309 timeo = unix_wait_for_peer(other, timeo); in unix_stream_connect()
1314 sock_put(other); in unix_stream_connect()
1348 unix_state_unlock(other); in unix_stream_connect()
1349 sock_put(other); in unix_stream_connect()
1353 err = security_unix_stream_connect(sk, other, newsk); in unix_stream_connect()
1368 otheru = unix_sk(other); in unix_stream_connect()
1395 copy_peercred(sk, other); in unix_stream_connect()
1407 spin_lock(&other->sk_receive_queue.lock); in unix_stream_connect()
1408 __skb_queue_tail(&other->sk_receive_queue, skb); in unix_stream_connect()
1409 spin_unlock(&other->sk_receive_queue.lock); in unix_stream_connect()
1410 unix_state_unlock(other); in unix_stream_connect()
1411 other->sk_data_ready(other); in unix_stream_connect()
1412 sock_put(other); in unix_stream_connect()
1416 if (other) in unix_stream_connect()
1417 unix_state_unlock(other); in unix_stream_connect()
1423 if (other) in unix_stream_connect()
1424 sock_put(other); in unix_stream_connect()
1599 const struct sock *other) in unix_passcred_enabled() argument
1602 !other->sk_socket || in unix_passcred_enabled()
1603 test_bit(SOCK_PASSCRED, &other->sk_socket->flags); in unix_passcred_enabled()
1612 const struct sock *other) in maybe_add_creds() argument
1616 if (unix_passcred_enabled(sock, other)) { in maybe_add_creds()
1624 const struct sock *other) in maybe_init_creds() argument
1633 if (unix_passcred_enabled(socket, other)) { in maybe_init_creds()
1662 struct sock *other = NULL; in unix_dgram_sendmsg() local
1689 other = unix_peer_get(sk); in unix_dgram_sendmsg()
1690 if (!other) in unix_dgram_sendmsg()
1731 if (!other) { in unix_dgram_sendmsg()
1736 other = unix_find_other(net, sunaddr, namelen, sk->sk_type, in unix_dgram_sendmsg()
1738 if (other == NULL) in unix_dgram_sendmsg()
1742 if (sk_filter(other, skb) < 0) { in unix_dgram_sendmsg()
1749 unix_state_lock(other); in unix_dgram_sendmsg()
1752 if (!unix_may_send(sk, other)) in unix_dgram_sendmsg()
1755 if (unlikely(sock_flag(other, SOCK_DEAD))) { in unix_dgram_sendmsg()
1760 unix_state_unlock(other); in unix_dgram_sendmsg()
1761 sock_put(other); in unix_dgram_sendmsg()
1767 if (unix_peer(sk) == other) { in unix_dgram_sendmsg()
1769 unix_dgram_peer_wake_disconnect_wakeup(sk, other); in unix_dgram_sendmsg()
1773 unix_dgram_disconnected(sk, other); in unix_dgram_sendmsg()
1774 sock_put(other); in unix_dgram_sendmsg()
1780 other = NULL; in unix_dgram_sendmsg()
1787 if (other->sk_shutdown & RCV_SHUTDOWN) in unix_dgram_sendmsg()
1791 err = security_unix_may_send(sk->sk_socket, other->sk_socket); in unix_dgram_sendmsg()
1800 if (other != sk && in unix_dgram_sendmsg()
1801 unlikely(unix_peer(other) != sk && in unix_dgram_sendmsg()
1802 unix_recvq_full_lockless(other))) { in unix_dgram_sendmsg()
1804 timeo = unix_wait_for_peer(other, timeo); in unix_dgram_sendmsg()
1814 unix_state_unlock(other); in unix_dgram_sendmsg()
1815 unix_state_double_lock(sk, other); in unix_dgram_sendmsg()
1818 if (unix_peer(sk) != other || in unix_dgram_sendmsg()
1819 unix_dgram_peer_wake_me(sk, other)) { in unix_dgram_sendmsg()
1834 if (sock_flag(other, SOCK_RCVTSTAMP)) in unix_dgram_sendmsg()
1836 maybe_add_creds(skb, sock, other); in unix_dgram_sendmsg()
1837 skb_queue_tail(&other->sk_receive_queue, skb); in unix_dgram_sendmsg()
1838 unix_state_unlock(other); in unix_dgram_sendmsg()
1839 other->sk_data_ready(other); in unix_dgram_sendmsg()
1840 sock_put(other); in unix_dgram_sendmsg()
1847 unix_state_unlock(other); in unix_dgram_sendmsg()
1851 if (other) in unix_dgram_sendmsg()
1852 sock_put(other); in unix_dgram_sendmsg()
1866 struct sock *other = NULL; in unix_stream_sendmsg() local
1888 other = unix_peer(sk); in unix_stream_sendmsg()
1889 if (!other) in unix_stream_sendmsg()
1932 unix_state_lock(other); in unix_stream_sendmsg()
1934 if (sock_flag(other, SOCK_DEAD) || in unix_stream_sendmsg()
1935 (other->sk_shutdown & RCV_SHUTDOWN)) in unix_stream_sendmsg()
1938 maybe_add_creds(skb, sock, other); in unix_stream_sendmsg()
1939 skb_queue_tail(&other->sk_receive_queue, skb); in unix_stream_sendmsg()
1940 unix_state_unlock(other); in unix_stream_sendmsg()
1941 other->sk_data_ready(other); in unix_stream_sendmsg()
1950 unix_state_unlock(other); in unix_stream_sendmsg()
1968 struct sock *other, *sk = socket->sk; in unix_stream_sendpage() local
1974 other = unix_peer(sk); in unix_stream_sendpage()
1975 if (!other || sk->sk_state != TCP_ESTABLISHED) in unix_stream_sendpage()
1980 spin_unlock(&other->sk_receive_queue.lock); in unix_stream_sendpage()
1981 unix_state_unlock(other); in unix_stream_sendpage()
1982 mutex_unlock(&unix_sk(other)->iolock); in unix_stream_sendpage()
1992 err = mutex_lock_interruptible(&unix_sk(other)->iolock); in unix_stream_sendpage()
2004 unix_state_lock(other); in unix_stream_sendpage()
2006 if (sock_flag(other, SOCK_DEAD) || in unix_stream_sendpage()
2007 other->sk_shutdown & RCV_SHUTDOWN) { in unix_stream_sendpage()
2014 err = maybe_init_creds(&scm, socket, other); in unix_stream_sendpage()
2020 spin_lock(&other->sk_receive_queue.lock); in unix_stream_sendpage()
2021 skb = skb_peek_tail(&other->sk_receive_queue); in unix_stream_sendpage()
2052 __skb_queue_tail(&other->sk_receive_queue, newskb); in unix_stream_sendpage()
2055 spin_unlock(&other->sk_receive_queue.lock); in unix_stream_sendpage()
2056 unix_state_unlock(other); in unix_stream_sendpage()
2057 mutex_unlock(&unix_sk(other)->iolock); in unix_stream_sendpage()
2059 other->sk_data_ready(other); in unix_stream_sendpage()
2064 unix_state_unlock(other); in unix_stream_sendpage()
2066 mutex_unlock(&unix_sk(other)->iolock); in unix_stream_sendpage()
2534 struct sock *other; in unix_shutdown() local
2547 other = unix_peer(sk); in unix_shutdown()
2548 if (other) in unix_shutdown()
2549 sock_hold(other); in unix_shutdown()
2553 if (other && in unix_shutdown()
2562 unix_state_lock(other); in unix_shutdown()
2563 WRITE_ONCE(other->sk_shutdown, other->sk_shutdown | peer_mode); in unix_shutdown()
2564 unix_state_unlock(other); in unix_shutdown()
2565 other->sk_state_change(other); in unix_shutdown()
2567 sk_wake_async(other, SOCK_WAKE_WAITD, POLL_HUP); in unix_shutdown()
2569 sk_wake_async(other, SOCK_WAKE_WAITD, POLL_IN); in unix_shutdown()
2571 if (other) in unix_shutdown()
2572 sock_put(other); in unix_shutdown()
2718 struct sock *sk = sock->sk, *other; in unix_dgram_poll() local
2758 other = unix_peer(sk); in unix_dgram_poll()
2759 if (other && unix_peer(other) != sk && in unix_dgram_poll()
2760 unix_recvq_full_lockless(other) && in unix_dgram_poll()
2761 unix_dgram_peer_wake_me(sk, other)) in unix_dgram_poll()