Lines Matching full:other
52 * other the moment one end closes.
451 static int unix_dgram_peer_wake_connect(struct sock *sk, struct sock *other) in unix_dgram_peer_wake_connect() argument
457 u_other = unix_sk(other); in unix_dgram_peer_wake_connect()
462 u->peer_wake.private = other; in unix_dgram_peer_wake_connect()
473 struct sock *other) in unix_dgram_peer_wake_disconnect() argument
478 u_other = unix_sk(other); in unix_dgram_peer_wake_disconnect()
481 if (u->peer_wake.private == other) { in unix_dgram_peer_wake_disconnect()
490 struct sock *other) in unix_dgram_peer_wake_disconnect_wakeup() argument
492 unix_dgram_peer_wake_disconnect(sk, other); in unix_dgram_peer_wake_disconnect_wakeup()
500 * - unix_peer(sk) == other
503 static int unix_dgram_peer_wake_me(struct sock *sk, struct sock *other) in unix_dgram_peer_wake_me() argument
507 connected = unix_dgram_peer_wake_connect(sk, other); in unix_dgram_peer_wake_me()
509 /* If other is SOCK_DEAD, we want to make sure we signal in unix_dgram_peer_wake_me()
512 * to other and its full, we will hang waiting for POLLOUT. in unix_dgram_peer_wake_me()
514 if (unix_recvq_full_lockless(other) && !sock_flag(other, SOCK_DEAD)) in unix_dgram_peer_wake_me()
518 unix_dgram_peer_wake_disconnect(sk, other); in unix_dgram_peer_wake_me()
548 static void unix_dgram_disconnected(struct sock *sk, struct sock *other) in unix_dgram_disconnected() argument
558 if (!sock_flag(other, SOCK_DEAD) && unix_peer(other) == sk) { in unix_dgram_disconnected()
559 other->sk_err = ECONNRESET; in unix_dgram_disconnected()
560 sk_error_report(other); in unix_dgram_disconnected()
563 other->sk_state = TCP_CLOSE; in unix_dgram_disconnected()
1351 struct sock *other; in unix_dgram_connect() local
1371 other = unix_find_other(sock_net(sk), sunaddr, alen, sock->type); in unix_dgram_connect()
1372 if (IS_ERR(other)) { in unix_dgram_connect()
1373 err = PTR_ERR(other); in unix_dgram_connect()
1377 unix_state_double_lock(sk, other); in unix_dgram_connect()
1380 if (sock_flag(other, SOCK_DEAD)) { in unix_dgram_connect()
1381 unix_state_double_unlock(sk, other); in unix_dgram_connect()
1382 sock_put(other); in unix_dgram_connect()
1387 if (!unix_may_send(sk, other)) in unix_dgram_connect()
1390 err = security_unix_may_send(sk->sk_socket, other->sk_socket); in unix_dgram_connect()
1394 sk->sk_state = other->sk_state = TCP_ESTABLISHED; in unix_dgram_connect()
1399 other = NULL; in unix_dgram_connect()
1400 unix_state_double_lock(sk, other); in unix_dgram_connect()
1409 unix_peer(sk) = other; in unix_dgram_connect()
1410 if (!other) in unix_dgram_connect()
1414 unix_state_double_unlock(sk, other); in unix_dgram_connect()
1416 if (other != old_peer) in unix_dgram_connect()
1420 unix_peer(sk) = other; in unix_dgram_connect()
1421 unix_state_double_unlock(sk, other); in unix_dgram_connect()
1427 unix_state_double_unlock(sk, other); in unix_dgram_connect()
1428 sock_put(other); in unix_dgram_connect()
1433 static long unix_wait_for_peer(struct sock *other, long timeo) in unix_wait_for_peer() argument
1434 __releases(&unix_sk(other)->lock) in unix_wait_for_peer()
1436 struct unix_sock *u = unix_sk(other); in unix_wait_for_peer()
1442 sched = !sock_flag(other, SOCK_DEAD) && in unix_wait_for_peer()
1443 !(other->sk_shutdown & RCV_SHUTDOWN) && in unix_wait_for_peer()
1444 unix_recvq_full(other); in unix_wait_for_peer()
1446 unix_state_unlock(other); in unix_wait_for_peer()
1459 struct sock *sk = sock->sk, *newsk = NULL, *other = NULL; in unix_stream_connect() local
1501 other = unix_find_other(net, sunaddr, addr_len, sk->sk_type); in unix_stream_connect()
1502 if (IS_ERR(other)) { in unix_stream_connect()
1503 err = PTR_ERR(other); in unix_stream_connect()
1504 other = NULL; in unix_stream_connect()
1509 unix_state_lock(other); in unix_stream_connect()
1512 if (sock_flag(other, SOCK_DEAD)) { in unix_stream_connect()
1513 unix_state_unlock(other); in unix_stream_connect()
1514 sock_put(other); in unix_stream_connect()
1519 if (other->sk_state != TCP_LISTEN) in unix_stream_connect()
1521 if (other->sk_shutdown & RCV_SHUTDOWN) in unix_stream_connect()
1524 if (unix_recvq_full(other)) { in unix_stream_connect()
1529 timeo = unix_wait_for_peer(other, timeo); in unix_stream_connect()
1534 sock_put(other); in unix_stream_connect()
1544 state. other is TCP_LISTEN, if sk is TCP_LISTEN we in unix_stream_connect()
1568 unix_state_unlock(other); in unix_stream_connect()
1569 sock_put(other); in unix_stream_connect()
1573 err = security_unix_stream_connect(sk, other, newsk); in unix_stream_connect()
1588 otheru = unix_sk(other); in unix_stream_connect()
1615 copy_peercred(sk, other); in unix_stream_connect()
1627 spin_lock(&other->sk_receive_queue.lock); in unix_stream_connect()
1628 __skb_queue_tail(&other->sk_receive_queue, skb); in unix_stream_connect()
1629 spin_unlock(&other->sk_receive_queue.lock); in unix_stream_connect()
1630 unix_state_unlock(other); in unix_stream_connect()
1631 other->sk_data_ready(other); in unix_stream_connect()
1632 sock_put(other); in unix_stream_connect()
1636 if (other) in unix_stream_connect()
1637 unix_state_unlock(other); in unix_stream_connect()
1643 if (other) in unix_stream_connect()
1644 sock_put(other); in unix_stream_connect()
1818 const struct sock *other) in unix_passcred_enabled() argument
1821 !other->sk_socket || in unix_passcred_enabled()
1822 test_bit(SOCK_PASSCRED, &other->sk_socket->flags); in unix_passcred_enabled()
1831 const struct sock *other) in maybe_add_creds() argument
1835 if (unix_passcred_enabled(sock, other)) { in maybe_add_creds()
1843 const struct sock *other) in maybe_init_creds() argument
1852 if (unix_passcred_enabled(socket, other)) { in maybe_init_creds()
1894 struct sock *sk = sock->sk, *other = NULL; in unix_dgram_sendmsg() local
1919 other = unix_peer_get(sk); in unix_dgram_sendmsg()
1920 if (!other) in unix_dgram_sendmsg()
1963 if (!other) { in unix_dgram_sendmsg()
1968 other = unix_find_other(sock_net(sk), sunaddr, msg->msg_namelen, in unix_dgram_sendmsg()
1970 if (IS_ERR(other)) { in unix_dgram_sendmsg()
1971 err = PTR_ERR(other); in unix_dgram_sendmsg()
1972 other = NULL; in unix_dgram_sendmsg()
1977 if (sk_filter(other, skb) < 0) { in unix_dgram_sendmsg()
1984 unix_state_lock(other); in unix_dgram_sendmsg()
1987 if (!unix_may_send(sk, other)) in unix_dgram_sendmsg()
1990 if (unlikely(sock_flag(other, SOCK_DEAD))) { in unix_dgram_sendmsg()
1995 unix_state_unlock(other); in unix_dgram_sendmsg()
1996 sock_put(other); in unix_dgram_sendmsg()
2002 if (unix_peer(sk) == other) { in unix_dgram_sendmsg()
2004 unix_dgram_peer_wake_disconnect_wakeup(sk, other); in unix_dgram_sendmsg()
2009 unix_dgram_disconnected(sk, other); in unix_dgram_sendmsg()
2010 sock_put(other); in unix_dgram_sendmsg()
2016 other = NULL; in unix_dgram_sendmsg()
2023 if (other->sk_shutdown & RCV_SHUTDOWN) in unix_dgram_sendmsg()
2027 err = security_unix_may_send(sk->sk_socket, other->sk_socket); in unix_dgram_sendmsg()
2032 /* other == sk && unix_peer(other) != sk if in unix_dgram_sendmsg()
2036 if (other != sk && in unix_dgram_sendmsg()
2037 unlikely(unix_peer(other) != sk && in unix_dgram_sendmsg()
2038 unix_recvq_full_lockless(other))) { in unix_dgram_sendmsg()
2040 timeo = unix_wait_for_peer(other, timeo); in unix_dgram_sendmsg()
2050 unix_state_unlock(other); in unix_dgram_sendmsg()
2051 unix_state_double_lock(sk, other); in unix_dgram_sendmsg()
2054 if (unix_peer(sk) != other || in unix_dgram_sendmsg()
2055 unix_dgram_peer_wake_me(sk, other)) { in unix_dgram_sendmsg()
2070 if (sock_flag(other, SOCK_RCVTSTAMP)) in unix_dgram_sendmsg()
2072 maybe_add_creds(skb, sock, other); in unix_dgram_sendmsg()
2073 scm_stat_add(other, skb); in unix_dgram_sendmsg()
2074 skb_queue_tail(&other->sk_receive_queue, skb); in unix_dgram_sendmsg()
2075 unix_state_unlock(other); in unix_dgram_sendmsg()
2076 other->sk_data_ready(other); in unix_dgram_sendmsg()
2077 sock_put(other); in unix_dgram_sendmsg()
2084 unix_state_unlock(other); in unix_dgram_sendmsg()
2088 if (other) in unix_dgram_sendmsg()
2089 sock_put(other); in unix_dgram_sendmsg()
2100 static int queue_oob(struct socket *sock, struct msghdr *msg, struct sock *other) in queue_oob() argument
2102 struct unix_sock *ousk = unix_sk(other); in queue_oob()
2119 unix_state_lock(other); in queue_oob()
2121 if (sock_flag(other, SOCK_DEAD) || in queue_oob()
2122 (other->sk_shutdown & RCV_SHUTDOWN)) { in queue_oob()
2123 unix_state_unlock(other); in queue_oob()
2128 maybe_add_creds(skb, sock, other); in queue_oob()
2136 scm_stat_add(other, skb); in queue_oob()
2137 skb_queue_tail(&other->sk_receive_queue, skb); in queue_oob()
2138 sk_send_sigurg(other); in queue_oob()
2139 unix_state_unlock(other); in queue_oob()
2140 other->sk_data_ready(other); in queue_oob()
2150 struct sock *other = NULL; in unix_stream_sendmsg() local
2178 other = unix_peer(sk); in unix_stream_sendmsg()
2179 if (!other) in unix_stream_sendmsg()
2222 unix_state_lock(other); in unix_stream_sendmsg()
2224 if (sock_flag(other, SOCK_DEAD) || in unix_stream_sendmsg()
2225 (other->sk_shutdown & RCV_SHUTDOWN)) in unix_stream_sendmsg()
2228 maybe_add_creds(skb, sock, other); in unix_stream_sendmsg()
2229 scm_stat_add(other, skb); in unix_stream_sendmsg()
2230 skb_queue_tail(&other->sk_receive_queue, skb); in unix_stream_sendmsg()
2231 unix_state_unlock(other); in unix_stream_sendmsg()
2232 other->sk_data_ready(other); in unix_stream_sendmsg()
2238 err = queue_oob(sock, msg, other); in unix_stream_sendmsg()
2250 unix_state_unlock(other); in unix_stream_sendmsg()
2268 struct sock *other, *sk = socket->sk; in unix_stream_sendpage() local
2274 other = unix_peer(sk); in unix_stream_sendpage()
2275 if (!other || sk->sk_state != TCP_ESTABLISHED) in unix_stream_sendpage()
2280 unix_state_unlock(other); in unix_stream_sendpage()
2281 mutex_unlock(&unix_sk(other)->iolock); in unix_stream_sendpage()
2291 err = mutex_lock_interruptible(&unix_sk(other)->iolock); in unix_stream_sendpage()
2303 unix_state_lock(other); in unix_stream_sendpage()
2305 if (sock_flag(other, SOCK_DEAD) || in unix_stream_sendpage()
2306 other->sk_shutdown & RCV_SHUTDOWN) { in unix_stream_sendpage()
2313 err = maybe_init_creds(&scm, socket, other); in unix_stream_sendpage()
2319 skb = skb_peek_tail(&other->sk_receive_queue); in unix_stream_sendpage()
2352 spin_lock(&other->sk_receive_queue.lock); in unix_stream_sendpage()
2353 __skb_queue_tail(&other->sk_receive_queue, newskb); in unix_stream_sendpage()
2354 spin_unlock(&other->sk_receive_queue.lock); in unix_stream_sendpage()
2357 unix_state_unlock(other); in unix_stream_sendpage()
2358 mutex_unlock(&unix_sk(other)->iolock); in unix_stream_sendpage()
2360 other->sk_data_ready(other); in unix_stream_sendpage()
2365 unix_state_unlock(other); in unix_stream_sendpage()
2367 mutex_unlock(&unix_sk(other)->iolock); in unix_stream_sendpage()
2985 struct sock *other; in unix_shutdown() local
2998 other = unix_peer(sk); in unix_shutdown()
2999 if (other) in unix_shutdown()
3000 sock_hold(other); in unix_shutdown()
3004 if (other && in unix_shutdown()
3008 const struct proto *prot = READ_ONCE(other->sk_prot); in unix_shutdown()
3011 prot->unhash(other); in unix_shutdown()
3016 unix_state_lock(other); in unix_shutdown()
3017 other->sk_shutdown |= peer_mode; in unix_shutdown()
3018 unix_state_unlock(other); in unix_shutdown()
3019 other->sk_state_change(other); in unix_shutdown()
3021 sk_wake_async(other, SOCK_WAKE_WAITD, POLL_HUP); in unix_shutdown()
3023 sk_wake_async(other, SOCK_WAKE_WAITD, POLL_IN); in unix_shutdown()
3025 if (other) in unix_shutdown()
3026 sock_put(other); in unix_shutdown()
3177 * we set writable also when the other side has shut down the in unix_poll()
3189 struct sock *sk = sock->sk, *other; in unix_dgram_poll() local
3229 other = unix_peer(sk); in unix_dgram_poll()
3230 if (other && unix_peer(other) != sk && in unix_dgram_poll()
3231 unix_recvq_full_lockless(other) && in unix_dgram_poll()
3232 unix_dgram_peer_wake_me(sk, other)) in unix_dgram_poll()
3764 /* Earlier than device_initcall() so that other drivers invoking