Lines Matching refs:sk

56 #define __iucv_sock_wait(sk, condition, timeo, ret)			\  argument
61 prepare_to_wait(sk_sleep(sk), &__wait, TASK_INTERRUPTIBLE); \
71 release_sock(sk); \
73 lock_sock(sk); \
74 ret = sock_error(sk); \
78 finish_wait(sk_sleep(sk), &__wait); \
81 #define iucv_sock_wait(sk, condition, timeo) \ argument
85 __iucv_sock_wait(sk, condition, timeo, __ret); \
91 static void iucv_sock_kill(struct sock *sk);
92 static void iucv_sock_close(struct sock *sk);
94 static void afiucv_hs_callback_txnotify(struct sock *sk, enum iucv_tx_notify);
150 static int iucv_sock_in_state(struct sock *sk, int state, int state2) in iucv_sock_in_state() argument
152 return (sk->sk_state == state || sk->sk_state == state2); in iucv_sock_in_state()
163 static inline int iucv_below_msglim(struct sock *sk) in iucv_below_msglim() argument
165 struct iucv_sock *iucv = iucv_sk(sk); in iucv_below_msglim()
167 if (sk->sk_state != IUCV_CONNECTED) in iucv_below_msglim()
179 static void iucv_sock_wake_msglim(struct sock *sk) in iucv_sock_wake_msglim() argument
184 wq = rcu_dereference(sk->sk_wq); in iucv_sock_wake_msglim()
187 sk_wake_async(sk, SOCK_WAKE_SPACE, POLL_OUT); in iucv_sock_wake_msglim()
267 struct sock *sk; in __iucv_get_sock_by_name() local
269 sk_for_each(sk, &iucv_sk_list.head) in __iucv_get_sock_by_name()
270 if (!memcmp(&iucv_sk(sk)->src_name, nm, 8)) in __iucv_get_sock_by_name()
271 return sk; in __iucv_get_sock_by_name()
276 static void iucv_sock_destruct(struct sock *sk) in iucv_sock_destruct() argument
278 skb_queue_purge(&sk->sk_receive_queue); in iucv_sock_destruct()
279 skb_queue_purge(&sk->sk_error_queue); in iucv_sock_destruct()
281 if (!sock_flag(sk, SOCK_DEAD)) { in iucv_sock_destruct()
282 pr_err("Attempt to release alive iucv socket %p\n", sk); in iucv_sock_destruct()
286 WARN_ON(atomic_read(&sk->sk_rmem_alloc)); in iucv_sock_destruct()
287 WARN_ON(refcount_read(&sk->sk_wmem_alloc)); in iucv_sock_destruct()
288 WARN_ON(sk->sk_wmem_queued); in iucv_sock_destruct()
289 WARN_ON(sk->sk_forward_alloc); in iucv_sock_destruct()
295 struct sock *sk; in iucv_sock_cleanup_listen() local
298 while ((sk = iucv_accept_dequeue(parent, NULL))) { in iucv_sock_cleanup_listen()
299 iucv_sock_close(sk); in iucv_sock_cleanup_listen()
300 iucv_sock_kill(sk); in iucv_sock_cleanup_listen()
306 static void iucv_sock_link(struct iucv_sock_list *l, struct sock *sk) in iucv_sock_link() argument
309 sk_add_node(sk, &l->head); in iucv_sock_link()
313 static void iucv_sock_unlink(struct iucv_sock_list *l, struct sock *sk) in iucv_sock_unlink() argument
316 sk_del_node_init(sk); in iucv_sock_unlink()
321 static void iucv_sock_kill(struct sock *sk) in iucv_sock_kill() argument
323 if (!sock_flag(sk, SOCK_ZAPPED) || sk->sk_socket) in iucv_sock_kill()
326 iucv_sock_unlink(&iucv_sk_list, sk); in iucv_sock_kill()
327 sock_set_flag(sk, SOCK_DEAD); in iucv_sock_kill()
328 sock_put(sk); in iucv_sock_kill()
332 static void iucv_sever_path(struct sock *sk, int with_user_data) in iucv_sever_path() argument
335 struct iucv_sock *iucv = iucv_sk(sk); in iucv_sever_path()
352 static int iucv_send_ctrl(struct sock *sk, u8 flags) in iucv_send_ctrl() argument
354 struct iucv_sock *iucv = iucv_sk(sk); in iucv_send_ctrl()
362 if (sk->sk_shutdown & SEND_SHUTDOWN) { in iucv_send_ctrl()
364 shutdown = sk->sk_shutdown; in iucv_send_ctrl()
365 sk->sk_shutdown &= RCV_SHUTDOWN; in iucv_send_ctrl()
367 skb = sock_alloc_send_skb(sk, blen, 1, &err); in iucv_send_ctrl()
370 err = afiucv_hs_send(NULL, sk, skb, flags); in iucv_send_ctrl()
373 sk->sk_shutdown = shutdown; in iucv_send_ctrl()
378 static void iucv_sock_close(struct sock *sk) in iucv_sock_close() argument
380 struct iucv_sock *iucv = iucv_sk(sk); in iucv_sock_close()
384 lock_sock(sk); in iucv_sock_close()
386 switch (sk->sk_state) { in iucv_sock_close()
388 iucv_sock_cleanup_listen(sk); in iucv_sock_close()
393 err = iucv_send_ctrl(sk, AF_IUCV_FLAG_FIN); in iucv_sock_close()
394 sk->sk_state = IUCV_DISCONN; in iucv_sock_close()
395 sk->sk_state_change(sk); in iucv_sock_close()
400 sk->sk_state = IUCV_CLOSING; in iucv_sock_close()
401 sk->sk_state_change(sk); in iucv_sock_close()
404 if (sock_flag(sk, SOCK_LINGER) && sk->sk_lingertime) in iucv_sock_close()
405 timeo = sk->sk_lingertime; in iucv_sock_close()
408 iucv_sock_wait(sk, in iucv_sock_close()
409 iucv_sock_in_state(sk, IUCV_CLOSED, 0), in iucv_sock_close()
415 sk->sk_state = IUCV_CLOSED; in iucv_sock_close()
416 sk->sk_state_change(sk); in iucv_sock_close()
418 sk->sk_err = ECONNRESET; in iucv_sock_close()
419 sk->sk_state_change(sk); in iucv_sock_close()
426 iucv_sever_path(sk, 1); in iucv_sock_close()
432 sk->sk_bound_dev_if = 0; in iucv_sock_close()
436 sock_set_flag(sk, SOCK_ZAPPED); in iucv_sock_close()
438 release_sock(sk); in iucv_sock_close()
441 static void iucv_sock_init(struct sock *sk, struct sock *parent) in iucv_sock_init() argument
444 sk->sk_type = parent->sk_type; in iucv_sock_init()
445 security_sk_clone(parent, sk); in iucv_sock_init()
451 struct sock *sk; in iucv_sock_alloc() local
454 sk = sk_alloc(&init_net, PF_IUCV, prio, &iucv_proto, kern); in iucv_sock_alloc()
455 if (!sk) in iucv_sock_alloc()
457 iucv = iucv_sk(sk); in iucv_sock_alloc()
459 sock_init_data(sock, sk); in iucv_sock_alloc()
481 sk->sk_destruct = iucv_sock_destruct; in iucv_sock_alloc()
482 sk->sk_sndtimeo = IUCV_CONN_TIMEOUT; in iucv_sock_alloc()
484 sock_reset_flag(sk, SOCK_ZAPPED); in iucv_sock_alloc()
486 sk->sk_protocol = proto; in iucv_sock_alloc()
487 sk->sk_state = IUCV_OPEN; in iucv_sock_alloc()
489 iucv_sock_link(&iucv_sk_list, sk); in iucv_sock_alloc()
490 return sk; in iucv_sock_alloc()
493 static void iucv_accept_enqueue(struct sock *parent, struct sock *sk) in iucv_accept_enqueue() argument
498 sock_hold(sk); in iucv_accept_enqueue()
500 list_add_tail(&iucv_sk(sk)->accept_q, &par->accept_q); in iucv_accept_enqueue()
502 iucv_sk(sk)->parent = parent; in iucv_accept_enqueue()
506 static void iucv_accept_unlink(struct sock *sk) in iucv_accept_unlink() argument
509 struct iucv_sock *par = iucv_sk(iucv_sk(sk)->parent); in iucv_accept_unlink()
512 list_del_init(&iucv_sk(sk)->accept_q); in iucv_accept_unlink()
514 sk_acceptq_removed(iucv_sk(sk)->parent); in iucv_accept_unlink()
515 iucv_sk(sk)->parent = NULL; in iucv_accept_unlink()
516 sock_put(sk); in iucv_accept_unlink()
523 struct sock *sk; in iucv_accept_dequeue() local
526 sk = (struct sock *) isk; in iucv_accept_dequeue()
527 lock_sock(sk); in iucv_accept_dequeue()
529 if (sk->sk_state == IUCV_CLOSED) { in iucv_accept_dequeue()
530 iucv_accept_unlink(sk); in iucv_accept_dequeue()
531 release_sock(sk); in iucv_accept_dequeue()
535 if (sk->sk_state == IUCV_CONNECTED || in iucv_accept_dequeue()
536 sk->sk_state == IUCV_DISCONN || in iucv_accept_dequeue()
538 iucv_accept_unlink(sk); in iucv_accept_dequeue()
540 sock_graft(sk, newsock); in iucv_accept_dequeue()
542 release_sock(sk); in iucv_accept_dequeue()
543 return sk; in iucv_accept_dequeue()
546 release_sock(sk); in iucv_accept_dequeue()
569 struct sock *sk = sock->sk; in iucv_sock_bind() local
579 lock_sock(sk); in iucv_sock_bind()
580 if (sk->sk_state != IUCV_OPEN) { in iucv_sock_bind()
587 iucv = iucv_sk(sk); in iucv_sock_bind()
612 sk->sk_bound_dev_if = dev->ifindex; in iucv_sock_bind()
615 sk->sk_state = IUCV_BOUND; in iucv_sock_bind()
629 sk->sk_state = IUCV_BOUND; in iucv_sock_bind()
631 sk->sk_allocation |= GFP_DMA; in iucv_sock_bind()
642 release_sock(sk); in iucv_sock_bind()
647 static int iucv_sock_autobind(struct sock *sk) in iucv_sock_autobind() argument
649 struct iucv_sock *iucv = iucv_sk(sk); in iucv_sock_autobind()
657 sk->sk_allocation |= GFP_DMA; in iucv_sock_autobind()
672 struct sock *sk = sock->sk; in afiucv_path_connect() local
673 struct iucv_sock *iucv = iucv_sk(sk); in afiucv_path_connect()
690 sk); in afiucv_path_connect()
719 struct sock *sk = sock->sk; in iucv_sock_connect() local
720 struct iucv_sock *iucv = iucv_sk(sk); in iucv_sock_connect()
726 if (sk->sk_state != IUCV_OPEN && sk->sk_state != IUCV_BOUND) in iucv_sock_connect()
729 if (sk->sk_state == IUCV_OPEN && in iucv_sock_connect()
733 if (sk->sk_type != SOCK_STREAM && sk->sk_type != SOCK_SEQPACKET) in iucv_sock_connect()
736 if (sk->sk_state == IUCV_OPEN) { in iucv_sock_connect()
737 err = iucv_sock_autobind(sk); in iucv_sock_connect()
742 lock_sock(sk); in iucv_sock_connect()
749 err = iucv_send_ctrl(sock->sk, AF_IUCV_FLAG_SYN); in iucv_sock_connect()
755 if (sk->sk_state != IUCV_CONNECTED) in iucv_sock_connect()
756 err = iucv_sock_wait(sk, iucv_sock_in_state(sk, IUCV_CONNECTED, in iucv_sock_connect()
758 sock_sndtimeo(sk, flags & O_NONBLOCK)); in iucv_sock_connect()
760 if (sk->sk_state == IUCV_DISCONN || sk->sk_state == IUCV_CLOSED) in iucv_sock_connect()
764 iucv_sever_path(sk, 0); in iucv_sock_connect()
767 release_sock(sk); in iucv_sock_connect()
774 struct sock *sk = sock->sk; in iucv_sock_listen() local
777 lock_sock(sk); in iucv_sock_listen()
780 if (sk->sk_state != IUCV_BOUND) in iucv_sock_listen()
786 sk->sk_max_ack_backlog = backlog; in iucv_sock_listen()
787 sk->sk_ack_backlog = 0; in iucv_sock_listen()
788 sk->sk_state = IUCV_LISTEN; in iucv_sock_listen()
792 release_sock(sk); in iucv_sock_listen()
801 struct sock *sk = sock->sk, *nsk; in iucv_sock_accept() local
805 lock_sock_nested(sk, SINGLE_DEPTH_NESTING); in iucv_sock_accept()
807 if (sk->sk_state != IUCV_LISTEN) { in iucv_sock_accept()
812 timeo = sock_rcvtimeo(sk, flags & O_NONBLOCK); in iucv_sock_accept()
815 add_wait_queue_exclusive(sk_sleep(sk), &wait); in iucv_sock_accept()
816 while (!(nsk = iucv_accept_dequeue(sk, newsock))) { in iucv_sock_accept()
823 release_sock(sk); in iucv_sock_accept()
825 lock_sock_nested(sk, SINGLE_DEPTH_NESTING); in iucv_sock_accept()
827 if (sk->sk_state != IUCV_LISTEN) { in iucv_sock_accept()
839 remove_wait_queue(sk_sleep(sk), &wait); in iucv_sock_accept()
847 release_sock(sk); in iucv_sock_accept()
855 struct sock *sk = sock->sk; in iucv_sock_getname() local
856 struct iucv_sock *iucv = iucv_sk(sk); in iucv_sock_getname()
901 struct sock *sk = sock->sk; in iucv_sock_sendmsg() local
902 struct iucv_sock *iucv = iucv_sk(sk); in iucv_sock_sendmsg()
915 err = sock_error(sk); in iucv_sock_sendmsg()
923 if (sk->sk_type == SOCK_SEQPACKET && !(msg->msg_flags & MSG_EOR)) in iucv_sock_sendmsg()
926 lock_sock(sk); in iucv_sock_sendmsg()
928 if (sk->sk_shutdown & SEND_SHUTDOWN) { in iucv_sock_sendmsg()
934 if (sk->sk_state != IUCV_CONNECTED) { in iucv_sock_sendmsg()
997 skb = sock_alloc_send_pskb(sk, headroom + linear, len - linear, in iucv_sock_sendmsg()
1011 timeo = sock_sndtimeo(sk, noblock); in iucv_sock_sendmsg()
1012 err = iucv_sock_wait(sk, iucv_below_msglim(sk), timeo); in iucv_sock_sendmsg()
1017 if (sk->sk_state != IUCV_CONNECTED) { in iucv_sock_sendmsg()
1028 err = afiucv_hs_send(&txmsg, sk, skb, 0); in iucv_sock_sendmsg()
1099 release_sock(sk); in iucv_sock_sendmsg()
1105 release_sock(sk); in iucv_sock_sendmsg()
1141 static void iucv_process_message(struct sock *sk, struct sk_buff *skb, in iucv_process_message() argument
1190 if (sk_filter(sk, skb)) { in iucv_process_message()
1191 atomic_inc(&sk->sk_drops); /* skb rejected by filter */ in iucv_process_message()
1195 if (__sock_queue_rcv_skb(sk, skb)) /* handle rcv queue full */ in iucv_process_message()
1196 skb_queue_tail(&iucv_sk(sk)->backlog_skb_q, skb); in iucv_process_message()
1203 static void iucv_process_message_q(struct sock *sk) in iucv_process_message_q() argument
1205 struct iucv_sock *iucv = iucv_sk(sk); in iucv_process_message_q()
1213 iucv_process_message(sk, skb, p->path, &p->msg); in iucv_process_message_q()
1224 struct sock *sk = sock->sk; in iucv_sock_recvmsg() local
1225 struct iucv_sock *iucv = iucv_sk(sk); in iucv_sock_recvmsg()
1231 if ((sk->sk_state == IUCV_DISCONN) && in iucv_sock_recvmsg()
1233 skb_queue_empty(&sk->sk_receive_queue) && in iucv_sock_recvmsg()
1242 skb = skb_recv_datagram(sk, flags, &err); in iucv_sock_recvmsg()
1244 if (sk->sk_shutdown & RCV_SHUTDOWN) in iucv_sock_recvmsg()
1253 sk->sk_shutdown = sk->sk_shutdown | RCV_SHUTDOWN; in iucv_sock_recvmsg()
1258 skb_queue_head(&sk->sk_receive_queue, skb); in iucv_sock_recvmsg()
1263 if (sk->sk_type == SOCK_SEQPACKET) { in iucv_sock_recvmsg()
1278 skb_queue_head(&sk->sk_receive_queue, skb); in iucv_sock_recvmsg()
1286 if (sk->sk_type == SOCK_STREAM) { in iucv_sock_recvmsg()
1289 skb_queue_head(&sk->sk_receive_queue, skb); in iucv_sock_recvmsg()
1299 iucv_sock_close(sk); in iucv_sock_recvmsg()
1309 if (__sock_queue_rcv_skb(sk, rskb)) { in iucv_sock_recvmsg()
1319 iucv_process_message_q(sk); in iucv_sock_recvmsg()
1322 err = iucv_send_ctrl(sk, AF_IUCV_FLAG_WIN); in iucv_sock_recvmsg()
1324 sk->sk_state = IUCV_DISCONN; in iucv_sock_recvmsg()
1325 sk->sk_state_change(sk); in iucv_sock_recvmsg()
1334 if (sk->sk_type == SOCK_SEQPACKET && (flags & MSG_TRUNC)) in iucv_sock_recvmsg()
1343 struct sock *sk; in iucv_accept_poll() local
1346 sk = (struct sock *) isk; in iucv_accept_poll()
1348 if (sk->sk_state == IUCV_CONNECTED) in iucv_accept_poll()
1358 struct sock *sk = sock->sk; in iucv_sock_poll() local
1363 if (sk->sk_state == IUCV_LISTEN) in iucv_sock_poll()
1364 return iucv_accept_poll(sk); in iucv_sock_poll()
1366 if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue)) in iucv_sock_poll()
1368 (sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? EPOLLPRI : 0); in iucv_sock_poll()
1370 if (sk->sk_shutdown & RCV_SHUTDOWN) in iucv_sock_poll()
1373 if (sk->sk_shutdown == SHUTDOWN_MASK) in iucv_sock_poll()
1376 if (!skb_queue_empty(&sk->sk_receive_queue) || in iucv_sock_poll()
1377 (sk->sk_shutdown & RCV_SHUTDOWN)) in iucv_sock_poll()
1380 if (sk->sk_state == IUCV_CLOSED) in iucv_sock_poll()
1383 if (sk->sk_state == IUCV_DISCONN) in iucv_sock_poll()
1386 if (sock_writeable(sk) && iucv_below_msglim(sk)) in iucv_sock_poll()
1389 sk_set_bit(SOCKWQ_ASYNC_NOSPACE, sk); in iucv_sock_poll()
1396 struct sock *sk = sock->sk; in iucv_sock_shutdown() local
1397 struct iucv_sock *iucv = iucv_sk(sk); in iucv_sock_shutdown()
1406 lock_sock(sk); in iucv_sock_shutdown()
1407 switch (sk->sk_state) { in iucv_sock_shutdown()
1419 sk->sk_state == IUCV_CONNECTED) { in iucv_sock_shutdown()
1439 iucv_send_ctrl(sk, AF_IUCV_FLAG_SHT); in iucv_sock_shutdown()
1442 sk->sk_shutdown |= how; in iucv_sock_shutdown()
1451 skb_queue_purge(&sk->sk_receive_queue); in iucv_sock_shutdown()
1455 sk->sk_state_change(sk); in iucv_sock_shutdown()
1458 release_sock(sk); in iucv_sock_shutdown()
1464 struct sock *sk = sock->sk; in iucv_sock_release() local
1467 if (!sk) in iucv_sock_release()
1470 iucv_sock_close(sk); in iucv_sock_release()
1472 sock_orphan(sk); in iucv_sock_release()
1473 iucv_sock_kill(sk); in iucv_sock_release()
1481 struct sock *sk = sock->sk; in iucv_sock_setsockopt() local
1482 struct iucv_sock *iucv = iucv_sk(sk); in iucv_sock_setsockopt()
1497 lock_sock(sk); in iucv_sock_setsockopt()
1506 switch (sk->sk_state) { in iucv_sock_setsockopt()
1523 release_sock(sk); in iucv_sock_setsockopt()
1531 struct sock *sk = sock->sk; in iucv_sock_getsockopt() local
1532 struct iucv_sock *iucv = iucv_sk(sk); in iucv_sock_getsockopt()
1552 lock_sock(sk); in iucv_sock_getsockopt()
1555 release_sock(sk); in iucv_sock_getsockopt()
1558 if (sk->sk_state == IUCV_OPEN) in iucv_sock_getsockopt()
1584 struct sock *sk, *nsk; in iucv_callback_connreq() local
1593 sk = NULL; in iucv_callback_connreq()
1594 sk_for_each(sk, &iucv_sk_list.head) in iucv_callback_connreq()
1595 if (sk->sk_state == IUCV_LISTEN && in iucv_callback_connreq()
1596 !memcmp(&iucv_sk(sk)->src_name, src_name, 8)) { in iucv_callback_connreq()
1601 iucv = iucv_sk(sk); in iucv_callback_connreq()
1609 bh_lock_sock(sk); in iucv_callback_connreq()
1615 if (sk->sk_state != IUCV_LISTEN) { in iucv_callback_connreq()
1622 if (sk_acceptq_is_full(sk)) { in iucv_callback_connreq()
1629 nsk = iucv_sock_alloc(NULL, sk->sk_protocol, GFP_ATOMIC, 0); in iucv_callback_connreq()
1637 iucv_sock_init(nsk, sk); in iucv_callback_connreq()
1664 iucv_accept_enqueue(sk, nsk); in iucv_callback_connreq()
1668 sk->sk_data_ready(sk); in iucv_callback_connreq()
1671 bh_unlock_sock(sk); in iucv_callback_connreq()
1677 struct sock *sk = path->private; in iucv_callback_connack() local
1679 sk->sk_state = IUCV_CONNECTED; in iucv_callback_connack()
1680 sk->sk_state_change(sk); in iucv_callback_connack()
1685 struct sock *sk = path->private; in iucv_callback_rx() local
1686 struct iucv_sock *iucv = iucv_sk(sk); in iucv_callback_rx()
1691 if (sk->sk_shutdown & RCV_SHUTDOWN) { in iucv_callback_rx()
1702 len = atomic_read(&sk->sk_rmem_alloc); in iucv_callback_rx()
1704 if (len > sk->sk_rcvbuf) in iucv_callback_rx()
1711 iucv_process_message(sk, skb, path, msg); in iucv_callback_rx()
1730 struct sock *sk = path->private; in iucv_callback_txdone() local
1737 iucv = iucv_sk(sk); in iucv_callback_txdone()
1740 bh_lock_sock(sk); in iucv_callback_txdone()
1759 iucv_sock_wake_msglim(sk); in iucv_callback_txdone()
1762 if (sk->sk_state == IUCV_CLOSING) { in iucv_callback_txdone()
1764 sk->sk_state = IUCV_CLOSED; in iucv_callback_txdone()
1765 sk->sk_state_change(sk); in iucv_callback_txdone()
1768 bh_unlock_sock(sk); in iucv_callback_txdone()
1774 struct sock *sk = path->private; in iucv_callback_connrej() local
1776 if (sk->sk_state == IUCV_CLOSED) in iucv_callback_connrej()
1779 bh_lock_sock(sk); in iucv_callback_connrej()
1780 iucv_sever_path(sk, 1); in iucv_callback_connrej()
1781 sk->sk_state = IUCV_DISCONN; in iucv_callback_connrej()
1783 sk->sk_state_change(sk); in iucv_callback_connrej()
1784 bh_unlock_sock(sk); in iucv_callback_connrej()
1792 struct sock *sk = path->private; in iucv_callback_shutdown() local
1794 bh_lock_sock(sk); in iucv_callback_shutdown()
1795 if (sk->sk_state != IUCV_CLOSED) { in iucv_callback_shutdown()
1796 sk->sk_shutdown |= SEND_SHUTDOWN; in iucv_callback_shutdown()
1797 sk->sk_state_change(sk); in iucv_callback_shutdown()
1799 bh_unlock_sock(sk); in iucv_callback_shutdown()
1835 static int afiucv_hs_callback_syn(struct sock *sk, struct sk_buff *skb) in afiucv_hs_callback_syn() argument
1842 iucv = iucv_sk(sk); in afiucv_hs_callback_syn()
1851 nsk = iucv_sock_alloc(NULL, sk->sk_protocol, GFP_ATOMIC, 0); in afiucv_hs_callback_syn()
1852 bh_lock_sock(sk); in afiucv_hs_callback_syn()
1853 if ((sk->sk_state != IUCV_LISTEN) || in afiucv_hs_callback_syn()
1854 sk_acceptq_is_full(sk) || in afiucv_hs_callback_syn()
1861 bh_unlock_sock(sk); in afiucv_hs_callback_syn()
1866 iucv_sock_init(nsk, sk); in afiucv_hs_callback_syn()
1877 nsk->sk_bound_dev_if = sk->sk_bound_dev_if; in afiucv_hs_callback_syn()
1886 iucv_accept_enqueue(sk, nsk); in afiucv_hs_callback_syn()
1888 sk->sk_data_ready(sk); in afiucv_hs_callback_syn()
1891 bh_unlock_sock(sk); in afiucv_hs_callback_syn()
1900 static int afiucv_hs_callback_synack(struct sock *sk, struct sk_buff *skb) in afiucv_hs_callback_synack() argument
1902 struct iucv_sock *iucv = iucv_sk(sk); in afiucv_hs_callback_synack()
1904 if (!iucv || sk->sk_state != IUCV_BOUND) { in afiucv_hs_callback_synack()
1909 bh_lock_sock(sk); in afiucv_hs_callback_synack()
1911 sk->sk_state = IUCV_CONNECTED; in afiucv_hs_callback_synack()
1912 sk->sk_state_change(sk); in afiucv_hs_callback_synack()
1913 bh_unlock_sock(sk); in afiucv_hs_callback_synack()
1921 static int afiucv_hs_callback_synfin(struct sock *sk, struct sk_buff *skb) in afiucv_hs_callback_synfin() argument
1923 struct iucv_sock *iucv = iucv_sk(sk); in afiucv_hs_callback_synfin()
1925 if (!iucv || sk->sk_state != IUCV_BOUND) { in afiucv_hs_callback_synfin()
1930 bh_lock_sock(sk); in afiucv_hs_callback_synfin()
1931 sk->sk_state = IUCV_DISCONN; in afiucv_hs_callback_synfin()
1932 sk->sk_state_change(sk); in afiucv_hs_callback_synfin()
1933 bh_unlock_sock(sk); in afiucv_hs_callback_synfin()
1941 static int afiucv_hs_callback_fin(struct sock *sk, struct sk_buff *skb) in afiucv_hs_callback_fin() argument
1943 struct iucv_sock *iucv = iucv_sk(sk); in afiucv_hs_callback_fin()
1951 bh_lock_sock(sk); in afiucv_hs_callback_fin()
1952 if (sk->sk_state == IUCV_CONNECTED) { in afiucv_hs_callback_fin()
1953 sk->sk_state = IUCV_DISCONN; in afiucv_hs_callback_fin()
1954 sk->sk_state_change(sk); in afiucv_hs_callback_fin()
1956 bh_unlock_sock(sk); in afiucv_hs_callback_fin()
1964 static int afiucv_hs_callback_win(struct sock *sk, struct sk_buff *skb) in afiucv_hs_callback_win() argument
1966 struct iucv_sock *iucv = iucv_sk(sk); in afiucv_hs_callback_win()
1971 if (sk->sk_state != IUCV_CONNECTED) in afiucv_hs_callback_win()
1975 iucv_sock_wake_msglim(sk); in afiucv_hs_callback_win()
1982 static int afiucv_hs_callback_rx(struct sock *sk, struct sk_buff *skb) in afiucv_hs_callback_rx() argument
1984 struct iucv_sock *iucv = iucv_sk(sk); in afiucv_hs_callback_rx()
1991 if (sk->sk_state != IUCV_CONNECTED) { in afiucv_hs_callback_rx()
1996 if (sk->sk_shutdown & RCV_SHUTDOWN) { in afiucv_hs_callback_rx()
2006 if (sk_filter(sk, skb)) { in afiucv_hs_callback_rx()
2007 atomic_inc(&sk->sk_drops); /* skb rejected by filter */ in afiucv_hs_callback_rx()
2014 if (__sock_queue_rcv_skb(sk, skb)) in afiucv_hs_callback_rx()
2018 skb_queue_tail(&iucv_sk(sk)->backlog_skb_q, skb); in afiucv_hs_callback_rx()
2031 struct sock *sk; in afiucv_hs_rcv() local
2049 sk = NULL; in afiucv_hs_rcv()
2051 sk_for_each(sk, &iucv_sk_list.head) { in afiucv_hs_rcv()
2053 if ((!memcmp(&iucv_sk(sk)->src_name, in afiucv_hs_rcv()
2055 (!memcmp(&iucv_sk(sk)->src_user_id, in afiucv_hs_rcv()
2057 (!memcmp(&iucv_sk(sk)->dst_name, nullstring, 8)) && in afiucv_hs_rcv()
2058 (!memcmp(&iucv_sk(sk)->dst_user_id, in afiucv_hs_rcv()
2060 iucv = iucv_sk(sk); in afiucv_hs_rcv()
2064 if ((!memcmp(&iucv_sk(sk)->src_name, in afiucv_hs_rcv()
2066 (!memcmp(&iucv_sk(sk)->src_user_id, in afiucv_hs_rcv()
2068 (!memcmp(&iucv_sk(sk)->dst_name, in afiucv_hs_rcv()
2070 (!memcmp(&iucv_sk(sk)->dst_user_id, in afiucv_hs_rcv()
2072 iucv = iucv_sk(sk); in afiucv_hs_rcv()
2079 sk = NULL; in afiucv_hs_rcv()
2093 err = afiucv_hs_callback_syn(sk, skb); in afiucv_hs_rcv()
2097 err = afiucv_hs_callback_synack(sk, skb); in afiucv_hs_rcv()
2101 err = afiucv_hs_callback_synfin(sk, skb); in afiucv_hs_rcv()
2105 err = afiucv_hs_callback_fin(sk, skb); in afiucv_hs_rcv()
2108 err = afiucv_hs_callback_win(sk, skb); in afiucv_hs_rcv()
2120 err = afiucv_hs_callback_rx(sk, skb); in afiucv_hs_rcv()
2133 static void afiucv_hs_callback_txnotify(struct sock *sk, enum iucv_tx_notify n) in afiucv_hs_callback_txnotify() argument
2135 struct iucv_sock *iucv = iucv_sk(sk); in afiucv_hs_callback_txnotify()
2137 if (sock_flag(sk, SOCK_ZAPPED)) in afiucv_hs_callback_txnotify()
2143 iucv_sock_wake_msglim(sk); in afiucv_hs_callback_txnotify()
2151 iucv_sock_wake_msglim(sk); in afiucv_hs_callback_txnotify()
2155 if (sk->sk_state == IUCV_CONNECTED) { in afiucv_hs_callback_txnotify()
2156 sk->sk_state = IUCV_DISCONN; in afiucv_hs_callback_txnotify()
2157 sk->sk_state_change(sk); in afiucv_hs_callback_txnotify()
2161 if (sk->sk_state == IUCV_CLOSING) { in afiucv_hs_callback_txnotify()
2163 sk->sk_state = IUCV_CLOSED; in afiucv_hs_callback_txnotify()
2164 sk->sk_state_change(sk); in afiucv_hs_callback_txnotify()
2176 struct sock *sk; in afiucv_netdev_event() local
2182 sk_for_each(sk, &iucv_sk_list.head) { in afiucv_netdev_event()
2183 iucv = iucv_sk(sk); in afiucv_netdev_event()
2185 (sk->sk_state == IUCV_CONNECTED)) { in afiucv_netdev_event()
2187 iucv_send_ctrl(sk, AF_IUCV_FLAG_FIN); in afiucv_netdev_event()
2188 sk->sk_state = IUCV_DISCONN; in afiucv_netdev_event()
2189 sk->sk_state_change(sk); in afiucv_netdev_event()
2228 struct sock *sk; in iucv_sock_create() local
2245 sk = iucv_sock_alloc(sock, protocol, GFP_KERNEL, kern); in iucv_sock_create()
2246 if (!sk) in iucv_sock_create()
2249 iucv_sock_init(sk, NULL); in iucv_sock_create()