Lines Matching refs:other
452 static int unix_dgram_peer_wake_connect(struct sock *sk, struct sock *other) in unix_dgram_peer_wake_connect() argument
458 u_other = unix_sk(other); in unix_dgram_peer_wake_connect()
463 u->peer_wake.private = other; in unix_dgram_peer_wake_connect()
474 struct sock *other) in unix_dgram_peer_wake_disconnect() argument
479 u_other = unix_sk(other); in unix_dgram_peer_wake_disconnect()
482 if (u->peer_wake.private == other) { in unix_dgram_peer_wake_disconnect()
491 struct sock *other) in unix_dgram_peer_wake_disconnect_wakeup() argument
493 unix_dgram_peer_wake_disconnect(sk, other); in unix_dgram_peer_wake_disconnect_wakeup()
504 static int unix_dgram_peer_wake_me(struct sock *sk, struct sock *other) in unix_dgram_peer_wake_me() argument
508 connected = unix_dgram_peer_wake_connect(sk, other); in unix_dgram_peer_wake_me()
515 if (unix_recvq_full_lockless(other) && !sock_flag(other, SOCK_DEAD)) in unix_dgram_peer_wake_me()
519 unix_dgram_peer_wake_disconnect(sk, other); in unix_dgram_peer_wake_me()
549 static void unix_dgram_disconnected(struct sock *sk, struct sock *other) in unix_dgram_disconnected() argument
559 if (!sock_flag(other, SOCK_DEAD) && unix_peer(other) == sk) { in unix_dgram_disconnected()
560 other->sk_err = ECONNRESET; in unix_dgram_disconnected()
561 sk_error_report(other); in unix_dgram_disconnected()
564 other->sk_state = TCP_CLOSE; in unix_dgram_disconnected()
1352 struct sock *other; in unix_dgram_connect() local
1372 other = unix_find_other(sock_net(sk), sunaddr, alen, sock->type); in unix_dgram_connect()
1373 if (IS_ERR(other)) { in unix_dgram_connect()
1374 err = PTR_ERR(other); in unix_dgram_connect()
1378 unix_state_double_lock(sk, other); in unix_dgram_connect()
1381 if (sock_flag(other, SOCK_DEAD)) { in unix_dgram_connect()
1382 unix_state_double_unlock(sk, other); in unix_dgram_connect()
1383 sock_put(other); in unix_dgram_connect()
1388 if (!unix_may_send(sk, other)) in unix_dgram_connect()
1391 err = security_unix_may_send(sk->sk_socket, other->sk_socket); in unix_dgram_connect()
1395 sk->sk_state = other->sk_state = TCP_ESTABLISHED; in unix_dgram_connect()
1400 other = NULL; in unix_dgram_connect()
1401 unix_state_double_lock(sk, other); in unix_dgram_connect()
1410 unix_peer(sk) = other; in unix_dgram_connect()
1411 if (!other) in unix_dgram_connect()
1415 unix_state_double_unlock(sk, other); in unix_dgram_connect()
1417 if (other != old_peer) in unix_dgram_connect()
1421 unix_peer(sk) = other; in unix_dgram_connect()
1422 unix_state_double_unlock(sk, other); in unix_dgram_connect()
1428 unix_state_double_unlock(sk, other); in unix_dgram_connect()
1429 sock_put(other); in unix_dgram_connect()
1434 static long unix_wait_for_peer(struct sock *other, long timeo) in unix_wait_for_peer() argument
1435 __releases(&unix_sk(other)->lock) in unix_wait_for_peer()
1437 struct unix_sock *u = unix_sk(other); in unix_wait_for_peer()
1443 sched = !sock_flag(other, SOCK_DEAD) && in unix_wait_for_peer()
1444 !(other->sk_shutdown & RCV_SHUTDOWN) && in unix_wait_for_peer()
1445 unix_recvq_full(other); in unix_wait_for_peer()
1447 unix_state_unlock(other); in unix_wait_for_peer()
1460 struct sock *sk = sock->sk, *newsk = NULL, *other = NULL; in unix_stream_connect() local
1502 other = unix_find_other(net, sunaddr, addr_len, sk->sk_type); in unix_stream_connect()
1503 if (IS_ERR(other)) { in unix_stream_connect()
1504 err = PTR_ERR(other); in unix_stream_connect()
1505 other = NULL; in unix_stream_connect()
1510 unix_state_lock(other); in unix_stream_connect()
1513 if (sock_flag(other, SOCK_DEAD)) { in unix_stream_connect()
1514 unix_state_unlock(other); in unix_stream_connect()
1515 sock_put(other); in unix_stream_connect()
1520 if (other->sk_state != TCP_LISTEN) in unix_stream_connect()
1522 if (other->sk_shutdown & RCV_SHUTDOWN) in unix_stream_connect()
1525 if (unix_recvq_full(other)) { in unix_stream_connect()
1530 timeo = unix_wait_for_peer(other, timeo); in unix_stream_connect()
1535 sock_put(other); in unix_stream_connect()
1569 unix_state_unlock(other); in unix_stream_connect()
1570 sock_put(other); in unix_stream_connect()
1574 err = security_unix_stream_connect(sk, other, newsk); in unix_stream_connect()
1589 otheru = unix_sk(other); in unix_stream_connect()
1616 copy_peercred(sk, other); in unix_stream_connect()
1628 spin_lock(&other->sk_receive_queue.lock); in unix_stream_connect()
1629 __skb_queue_tail(&other->sk_receive_queue, skb); in unix_stream_connect()
1630 spin_unlock(&other->sk_receive_queue.lock); in unix_stream_connect()
1631 unix_state_unlock(other); in unix_stream_connect()
1632 other->sk_data_ready(other); in unix_stream_connect()
1633 sock_put(other); in unix_stream_connect()
1637 if (other) in unix_stream_connect()
1638 unix_state_unlock(other); in unix_stream_connect()
1644 if (other) in unix_stream_connect()
1645 sock_put(other); in unix_stream_connect()
1819 const struct sock *other) in unix_passcred_enabled() argument
1822 !other->sk_socket || in unix_passcred_enabled()
1823 test_bit(SOCK_PASSCRED, &other->sk_socket->flags); in unix_passcred_enabled()
1832 const struct sock *other) in maybe_add_creds() argument
1836 if (unix_passcred_enabled(sock, other)) { in maybe_add_creds()
1844 const struct sock *other) in maybe_init_creds() argument
1853 if (unix_passcred_enabled(socket, other)) { in maybe_init_creds()
1895 struct sock *sk = sock->sk, *other = NULL; in unix_dgram_sendmsg() local
1920 other = unix_peer_get(sk); in unix_dgram_sendmsg()
1921 if (!other) in unix_dgram_sendmsg()
1964 if (!other) { in unix_dgram_sendmsg()
1969 other = unix_find_other(sock_net(sk), sunaddr, msg->msg_namelen, in unix_dgram_sendmsg()
1971 if (IS_ERR(other)) { in unix_dgram_sendmsg()
1972 err = PTR_ERR(other); in unix_dgram_sendmsg()
1973 other = NULL; in unix_dgram_sendmsg()
1978 if (sk_filter(other, skb) < 0) { in unix_dgram_sendmsg()
1985 unix_state_lock(other); in unix_dgram_sendmsg()
1988 if (!unix_may_send(sk, other)) in unix_dgram_sendmsg()
1991 if (unlikely(sock_flag(other, SOCK_DEAD))) { in unix_dgram_sendmsg()
1996 unix_state_unlock(other); in unix_dgram_sendmsg()
1997 sock_put(other); in unix_dgram_sendmsg()
2010 } else if (unix_peer(sk) == other) { in unix_dgram_sendmsg()
2012 unix_dgram_peer_wake_disconnect_wakeup(sk, other); in unix_dgram_sendmsg()
2017 unix_dgram_disconnected(sk, other); in unix_dgram_sendmsg()
2018 sock_put(other); in unix_dgram_sendmsg()
2024 other = NULL; in unix_dgram_sendmsg()
2031 if (other->sk_shutdown & RCV_SHUTDOWN) in unix_dgram_sendmsg()
2035 err = security_unix_may_send(sk->sk_socket, other->sk_socket); in unix_dgram_sendmsg()
2044 if (other != sk && in unix_dgram_sendmsg()
2045 unlikely(unix_peer(other) != sk && in unix_dgram_sendmsg()
2046 unix_recvq_full_lockless(other))) { in unix_dgram_sendmsg()
2048 timeo = unix_wait_for_peer(other, timeo); in unix_dgram_sendmsg()
2058 unix_state_unlock(other); in unix_dgram_sendmsg()
2059 unix_state_double_lock(sk, other); in unix_dgram_sendmsg()
2062 if (unix_peer(sk) != other || in unix_dgram_sendmsg()
2063 unix_dgram_peer_wake_me(sk, other)) { in unix_dgram_sendmsg()
2078 if (sock_flag(other, SOCK_RCVTSTAMP)) in unix_dgram_sendmsg()
2080 maybe_add_creds(skb, sock, other); in unix_dgram_sendmsg()
2081 scm_stat_add(other, skb); in unix_dgram_sendmsg()
2082 skb_queue_tail(&other->sk_receive_queue, skb); in unix_dgram_sendmsg()
2083 unix_state_unlock(other); in unix_dgram_sendmsg()
2084 other->sk_data_ready(other); in unix_dgram_sendmsg()
2085 sock_put(other); in unix_dgram_sendmsg()
2092 unix_state_unlock(other); in unix_dgram_sendmsg()
2096 if (other) in unix_dgram_sendmsg()
2097 sock_put(other); in unix_dgram_sendmsg()
2108 static int queue_oob(struct socket *sock, struct msghdr *msg, struct sock *other, in queue_oob() argument
2111 struct unix_sock *ousk = unix_sk(other); in queue_oob()
2133 unix_state_lock(other); in queue_oob()
2135 if (sock_flag(other, SOCK_DEAD) || in queue_oob()
2136 (other->sk_shutdown & RCV_SHUTDOWN)) { in queue_oob()
2137 unix_state_unlock(other); in queue_oob()
2142 maybe_add_creds(skb, sock, other); in queue_oob()
2150 scm_stat_add(other, skb); in queue_oob()
2151 skb_queue_tail(&other->sk_receive_queue, skb); in queue_oob()
2152 sk_send_sigurg(other); in queue_oob()
2153 unix_state_unlock(other); in queue_oob()
2154 other->sk_data_ready(other); in queue_oob()
2164 struct sock *other = NULL; in unix_stream_sendmsg() local
2192 other = unix_peer(sk); in unix_stream_sendmsg()
2193 if (!other) in unix_stream_sendmsg()
2236 unix_state_lock(other); in unix_stream_sendmsg()
2238 if (sock_flag(other, SOCK_DEAD) || in unix_stream_sendmsg()
2239 (other->sk_shutdown & RCV_SHUTDOWN)) in unix_stream_sendmsg()
2242 maybe_add_creds(skb, sock, other); in unix_stream_sendmsg()
2243 scm_stat_add(other, skb); in unix_stream_sendmsg()
2244 skb_queue_tail(&other->sk_receive_queue, skb); in unix_stream_sendmsg()
2245 unix_state_unlock(other); in unix_stream_sendmsg()
2246 other->sk_data_ready(other); in unix_stream_sendmsg()
2252 err = queue_oob(sock, msg, other, &scm, fds_sent); in unix_stream_sendmsg()
2264 unix_state_unlock(other); in unix_stream_sendmsg()
2282 struct sock *other, *sk = socket->sk; in unix_stream_sendpage() local
2288 other = unix_peer(sk); in unix_stream_sendpage()
2289 if (!other || sk->sk_state != TCP_ESTABLISHED) in unix_stream_sendpage()
2294 unix_state_unlock(other); in unix_stream_sendpage()
2295 mutex_unlock(&unix_sk(other)->iolock); in unix_stream_sendpage()
2305 err = mutex_lock_interruptible(&unix_sk(other)->iolock); in unix_stream_sendpage()
2317 unix_state_lock(other); in unix_stream_sendpage()
2319 if (sock_flag(other, SOCK_DEAD) || in unix_stream_sendpage()
2320 other->sk_shutdown & RCV_SHUTDOWN) { in unix_stream_sendpage()
2327 err = maybe_init_creds(&scm, socket, other); in unix_stream_sendpage()
2333 skb = skb_peek_tail(&other->sk_receive_queue); in unix_stream_sendpage()
2366 spin_lock(&other->sk_receive_queue.lock); in unix_stream_sendpage()
2367 __skb_queue_tail(&other->sk_receive_queue, newskb); in unix_stream_sendpage()
2368 spin_unlock(&other->sk_receive_queue.lock); in unix_stream_sendpage()
2371 unix_state_unlock(other); in unix_stream_sendpage()
2372 mutex_unlock(&unix_sk(other)->iolock); in unix_stream_sendpage()
2374 other->sk_data_ready(other); in unix_stream_sendpage()
2379 unix_state_unlock(other); in unix_stream_sendpage()
2381 mutex_unlock(&unix_sk(other)->iolock); in unix_stream_sendpage()
2999 struct sock *other; in unix_shutdown() local
3012 other = unix_peer(sk); in unix_shutdown()
3013 if (other) in unix_shutdown()
3014 sock_hold(other); in unix_shutdown()
3018 if (other && in unix_shutdown()
3022 const struct proto *prot = READ_ONCE(other->sk_prot); in unix_shutdown()
3025 prot->unhash(other); in unix_shutdown()
3030 unix_state_lock(other); in unix_shutdown()
3031 other->sk_shutdown |= peer_mode; in unix_shutdown()
3032 unix_state_unlock(other); in unix_shutdown()
3033 other->sk_state_change(other); in unix_shutdown()
3035 sk_wake_async(other, SOCK_WAKE_WAITD, POLL_HUP); in unix_shutdown()
3037 sk_wake_async(other, SOCK_WAKE_WAITD, POLL_IN); in unix_shutdown()
3039 if (other) in unix_shutdown()
3040 sock_put(other); in unix_shutdown()
3203 struct sock *sk = sock->sk, *other; in unix_dgram_poll() local
3243 other = unix_peer(sk); in unix_dgram_poll()
3244 if (other && unix_peer(other) != sk && in unix_dgram_poll()
3245 unix_recvq_full_lockless(other) && in unix_dgram_poll()
3246 unix_dgram_peer_wake_me(sk, other)) in unix_dgram_poll()