Lines Matching refs:sock

81 	struct sock sk;
104 static int tipc_backlog_rcv(struct sock *sk, struct sk_buff *skb);
105 static void tipc_data_ready(struct sock *sk);
106 static void tipc_write_space(struct sock *sk);
107 static int tipc_release(struct socket *sock);
108 static int tipc_accept(struct socket *sock, struct socket *new_sock, int flags);
109 static int tipc_wait_for_sndmsg(struct socket *sock, long *timeo_p);
118 static int __tipc_send_stream(struct socket *sock, struct msghdr *m,
120 static int __tipc_sendmsg(struct socket *sock, struct msghdr *m, size_t dsz);
230 static struct tipc_sock *tipc_sk(const struct sock *sk) in tipc_sk()
245 static void tsk_advance_rx_queue(struct sock *sk) in tsk_advance_rx_queue()
255 static void tsk_rej_rx_queue(struct sock *sk) in tsk_rej_rx_queue()
312 static int tipc_sk_create(struct net *net, struct socket *sock, in tipc_sk_create() argument
318 struct sock *sk; in tipc_sk_create()
326 switch (sock->type) { in tipc_sk_create()
358 sock->ops = ops; in tipc_sk_create()
359 sock->state = state; in tipc_sk_create()
360 sock_init_data(sock, sk); in tipc_sk_create()
375 if (sock->state == SS_READY) { in tipc_sk_create()
377 if (sock->type == SOCK_DGRAM) in tipc_sk_create()
406 static int tipc_release(struct socket *sock) in tipc_release() argument
408 struct sock *sk = sock->sk; in tipc_release()
430 while (sock->state != SS_DISCONNECTING) { in tipc_release()
437 if ((sock->state == SS_CONNECTING) || in tipc_release()
438 (sock->state == SS_CONNECTED)) { in tipc_release()
439 sock->state = SS_DISCONNECTING; in tipc_release()
469 sock->state = SS_DISCONNECTING; in tipc_release()
473 sock->sk = NULL; in tipc_release()
493 static int tipc_bind(struct socket *sock, struct sockaddr *uaddr, in tipc_bind() argument
496 struct sock *sk = sock->sk; in tipc_bind()
551 static int tipc_getname(struct socket *sock, struct sockaddr *uaddr, in tipc_getname() argument
555 struct tipc_sock *tsk = tipc_sk(sock->sk); in tipc_getname()
556 struct tipc_net *tn = net_generic(sock_net(sock->sk), tipc_net_id); in tipc_getname()
560 if ((sock->state != SS_CONNECTED) && in tipc_getname()
561 ((peer != 2) || (sock->state != SS_DISCONNECTING))) in tipc_getname()
619 static unsigned int tipc_poll(struct file *file, struct socket *sock, in tipc_poll() argument
622 struct sock *sk = sock->sk; in tipc_poll()
628 switch ((int)sock->state) { in tipc_poll()
662 static int tipc_sendmcast(struct socket *sock, struct tipc_name_seq *seq, in tipc_sendmcast() argument
665 struct sock *sk = sock->sk; in tipc_sendmcast()
702 rc = tipc_wait_for_sndmsg(sock, &timeo); in tipc_sendmcast()
799 static int tipc_wait_for_sndmsg(struct socket *sock, long *timeo_p) in tipc_wait_for_sndmsg() argument
801 struct sock *sk = sock->sk; in tipc_wait_for_sndmsg()
810 if (sock->state == SS_DISCONNECTING) in tipc_wait_for_sndmsg()
837 static int tipc_sendmsg(struct socket *sock, in tipc_sendmsg() argument
840 struct sock *sk = sock->sk; in tipc_sendmsg()
844 ret = __tipc_sendmsg(sock, m, dsz); in tipc_sendmsg()
850 static int __tipc_sendmsg(struct socket *sock, struct msghdr *m, size_t dsz) in __tipc_sendmsg() argument
853 struct sock *sk = sock->sk; in __tipc_sendmsg()
869 if (tsk->connected && sock->state == SS_READY) in __tipc_sendmsg()
877 if (unlikely(sock->state != SS_READY)) { in __tipc_sendmsg()
878 if (sock->state == SS_LISTENING) in __tipc_sendmsg()
880 if (sock->state != SS_UNCONNECTED) in __tipc_sendmsg()
893 return tipc_sendmcast(sock, seq, m, dsz, timeo); in __tipc_sendmsg()
931 if (sock->state != SS_READY) in __tipc_sendmsg()
932 sock->state = SS_CONNECTING; in __tipc_sendmsg()
943 rc = tipc_wait_for_sndmsg(sock, &timeo); in __tipc_sendmsg()
951 static int tipc_wait_for_sndpkt(struct socket *sock, long *timeo_p) in tipc_wait_for_sndpkt() argument
953 struct sock *sk = sock->sk; in tipc_wait_for_sndpkt()
962 if (sock->state == SS_DISCONNECTING) in tipc_wait_for_sndpkt()
964 else if (sock->state != SS_CONNECTED) in tipc_wait_for_sndpkt()
992 static int tipc_send_stream(struct socket *sock, struct msghdr *m, size_t dsz) in tipc_send_stream() argument
994 struct sock *sk = sock->sk; in tipc_send_stream()
998 ret = __tipc_send_stream(sock, m, dsz); in tipc_send_stream()
1004 static int __tipc_send_stream(struct socket *sock, struct msghdr *m, size_t dsz) in __tipc_send_stream() argument
1006 struct sock *sk = sock->sk; in __tipc_send_stream()
1021 rc = __tipc_sendmsg(sock, m, dsz); in __tipc_send_stream()
1029 if (unlikely(sock->state != SS_CONNECTED)) { in __tipc_send_stream()
1030 if (sock->state == SS_DISCONNECTING) in __tipc_send_stream()
1066 rc = tipc_wait_for_sndpkt(sock, &timeo); in __tipc_send_stream()
1084 static int tipc_send_packet(struct socket *sock, struct msghdr *m, size_t dsz) in tipc_send_packet() argument
1089 return tipc_send_stream(sock, m, dsz); in tipc_send_packet()
1097 struct sock *sk = &tsk->sk; in tipc_sk_finish_conn()
1229 static int tipc_wait_for_rcvmsg(struct socket *sock, long *timeop) in tipc_wait_for_rcvmsg() argument
1231 struct sock *sk = sock->sk; in tipc_wait_for_rcvmsg()
1239 if (sock->state == SS_DISCONNECTING) { in tipc_wait_for_rcvmsg()
1273 static int tipc_recvmsg(struct socket *sock, struct msghdr *m, size_t buf_len, in tipc_recvmsg() argument
1276 struct sock *sk = sock->sk; in tipc_recvmsg()
1291 if (unlikely(sock->state == SS_UNCONNECTED)) { in tipc_recvmsg()
1300 res = tipc_wait_for_rcvmsg(sock, &timeo); in tipc_recvmsg()
1335 if ((sock->state == SS_READY) || in tipc_recvmsg()
1344 if ((sock->state != SS_READY) && in tipc_recvmsg()
1367 static int tipc_recv_stream(struct socket *sock, struct msghdr *m, in tipc_recv_stream() argument
1370 struct sock *sk = sock->sk; in tipc_recv_stream()
1387 if (unlikely(sock->state == SS_UNCONNECTED)) { in tipc_recv_stream()
1397 res = tipc_wait_for_rcvmsg(sock, &timeo); in tipc_recv_stream()
1478 static void tipc_write_space(struct sock *sk) in tipc_write_space()
1495 static void tipc_data_ready(struct sock *sk) in tipc_data_ready()
1516 struct sock *sk = &tsk->sk; in filter_connect()
1518 struct socket *sock = sk->sk_socket; in filter_connect() local
1525 switch ((int)sock->state) { in filter_connect()
1530 sock->state = SS_DISCONNECTING; in filter_connect()
1546 sock->state = SS_DISCONNECTING; in filter_connect()
1553 sock->state = SS_DISCONNECTING; in filter_connect()
1561 sock->state = SS_CONNECTED; in filter_connect()
1585 pr_err("Unknown socket state %u\n", sock->state); in filter_connect()
1608 static unsigned int rcvbuf_limit(struct sock *sk, struct sk_buff *buf) in rcvbuf_limit()
1631 static int filter_rcv(struct sock *sk, struct sk_buff **skb) in filter_rcv()
1633 struct socket *sock = sk->sk_socket; in filter_rcv() local
1656 if (sock->state == SS_READY) { in filter_rcv()
1688 static int tipc_backlog_rcv(struct sock *sk, struct sk_buff *skb) in tipc_backlog_rcv()
1722 static int tipc_sk_enqueue(struct sk_buff_head *inputq, struct sock *sk, in tipc_sk_enqueue()
1771 struct sock *sk; in tipc_sk_rcv()
1806 static int tipc_wait_for_connect(struct socket *sock, long *timeo_p) in tipc_wait_for_connect() argument
1808 struct sock *sk = sock->sk; in tipc_wait_for_connect()
1822 done = sk_wait_event(sk, timeo_p, sock->state != SS_CONNECTING); in tipc_wait_for_connect()
1837 static int tipc_connect(struct socket *sock, struct sockaddr *dest, in tipc_connect() argument
1840 struct sock *sk = sock->sk; in tipc_connect()
1851 if (sock->state == SS_READY) { in tipc_connect()
1875 previous = sock->state; in tipc_connect()
1876 switch (sock->state) { in tipc_connect()
1888 res = __tipc_sendmsg(sock, &m, 0); in tipc_connect()
1904 res = tipc_wait_for_connect(sock, &timeout); in tipc_connect()
1925 static int tipc_listen(struct socket *sock, int len) in tipc_listen() argument
1927 struct sock *sk = sock->sk; in tipc_listen()
1932 if (sock->state != SS_UNCONNECTED) in tipc_listen()
1935 sock->state = SS_LISTENING; in tipc_listen()
1943 static int tipc_wait_for_accept(struct socket *sock, long timeo) in tipc_wait_for_accept() argument
1945 struct sock *sk = sock->sk; in tipc_wait_for_accept()
1966 if (sock->state != SS_LISTENING) in tipc_wait_for_accept()
1987 static int tipc_accept(struct socket *sock, struct socket *new_sock, int flags) in tipc_accept() argument
1989 struct sock *new_sk, *sk = sock->sk; in tipc_accept()
1998 if (sock->state != SS_LISTENING) { in tipc_accept()
2003 res = tipc_wait_for_accept(sock, timeo); in tipc_accept()
2009 res = tipc_sk_create(sock_net(sock->sk), new_sock, 0, 1); in tipc_accept()
2012 security_sk_clone(sock->sk, new_sock->sk); in tipc_accept()
2066 static int tipc_shutdown(struct socket *sock, int how) in tipc_shutdown() argument
2068 struct sock *sk = sock->sk; in tipc_shutdown()
2080 switch (sock->state) { in tipc_shutdown()
2107 sock->state = SS_DISCONNECTING; in tipc_shutdown()
2132 struct sock *sk = &tsk->sk; in tipc_sk_timeout()
2269 struct sock *sk = &tsk->sk; in tipc_sk_insert()
2292 struct sock *sk = &tsk->sk; in tipc_sk_remove()
2341 static int tipc_setsockopt(struct socket *sock, int lvl, int opt, in tipc_setsockopt() argument
2344 struct sock *sk = sock->sk; in tipc_setsockopt()
2349 if ((lvl == IPPROTO_TCP) && (sock->type == SOCK_STREAM)) in tipc_setsockopt()
2366 if (sock->type != SOCK_STREAM) in tipc_setsockopt()
2400 static int tipc_getsockopt(struct socket *sock, int lvl, int opt, in tipc_getsockopt() argument
2403 struct sock *sk = sock->sk; in tipc_getsockopt()
2409 if ((lvl == IPPROTO_TCP) && (sock->type == SOCK_STREAM)) in tipc_getsockopt()
2457 static int tipc_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) in tipc_ioctl() argument
2459 struct sock *sk = sock->sk; in tipc_ioctl()
2801 struct nlattr *sock[TIPC_NLA_SOCK_MAX + 1]; in tipc_nl_publ_dump() local
2807 err = nla_parse_nested(sock, TIPC_NLA_SOCK_MAX, in tipc_nl_publ_dump()
2813 if (!sock[TIPC_NLA_SOCK_REF]) in tipc_nl_publ_dump()
2816 tsk_portid = nla_get_u32(sock[TIPC_NLA_SOCK_REF]); in tipc_nl_publ_dump()