Lines Matching refs:sock
82 struct sock sk;
105 static int tipc_backlog_rcv(struct sock *sk, struct sk_buff *skb);
106 static void tipc_data_ready(struct sock *sk);
107 static void tipc_write_space(struct sock *sk);
108 static void tipc_sock_destruct(struct sock *sk);
109 static int tipc_release(struct socket *sock);
110 static int tipc_accept(struct socket *sock, struct socket *new_sock, int flags);
111 static int tipc_wait_for_sndmsg(struct socket *sock, long *timeo_p);
120 static int __tipc_send_stream(struct socket *sock, struct msghdr *m,
122 static int __tipc_sendmsg(struct socket *sock, struct msghdr *m, size_t dsz);
232 static struct tipc_sock *tipc_sk(const struct sock *sk) in tipc_sk()
247 static void tsk_advance_rx_queue(struct sock *sk) in tsk_advance_rx_queue()
254 static void tipc_sk_respond(struct sock *sk, struct sk_buff *skb, int err) in tipc_sk_respond()
273 static void tsk_rej_rx_queue(struct sock *sk) in tsk_rej_rx_queue()
326 static int tipc_sk_create(struct net *net, struct socket *sock, in tipc_sk_create() argument
332 struct sock *sk; in tipc_sk_create()
340 switch (sock->type) { in tipc_sk_create()
372 sock->ops = ops; in tipc_sk_create()
373 sock->state = state; in tipc_sk_create()
374 sock_init_data(sock, sk); in tipc_sk_create()
390 if (sock->state == SS_READY) { in tipc_sk_create()
392 if (sock->type == SOCK_DGRAM) in tipc_sk_create()
421 static int tipc_release(struct socket *sock) in tipc_release() argument
423 struct sock *sk = sock->sk; in tipc_release()
445 while (sock->state != SS_DISCONNECTING) { in tipc_release()
452 if ((sock->state == SS_CONNECTING) || in tipc_release()
453 (sock->state == SS_CONNECTED)) { in tipc_release()
454 sock->state = SS_DISCONNECTING; in tipc_release()
476 sock->state = SS_DISCONNECTING; in tipc_release()
480 sock->sk = NULL; in tipc_release()
500 static int tipc_bind(struct socket *sock, struct sockaddr *uaddr, in tipc_bind() argument
503 struct sock *sk = sock->sk; in tipc_bind()
558 static int tipc_getname(struct socket *sock, struct sockaddr *uaddr, in tipc_getname() argument
562 struct tipc_sock *tsk = tipc_sk(sock->sk); in tipc_getname()
563 struct tipc_net *tn = net_generic(sock_net(sock->sk), tipc_net_id); in tipc_getname()
567 if ((sock->state != SS_CONNECTED) && in tipc_getname()
568 ((peer != 2) || (sock->state != SS_DISCONNECTING))) in tipc_getname()
626 static unsigned int tipc_poll(struct file *file, struct socket *sock, in tipc_poll() argument
629 struct sock *sk = sock->sk; in tipc_poll()
635 switch ((int)sock->state) { in tipc_poll()
669 static int tipc_sendmcast(struct socket *sock, struct tipc_name_seq *seq, in tipc_sendmcast() argument
672 struct sock *sk = sock->sk; in tipc_sendmcast()
705 rc = tipc_wait_for_sndmsg(sock, &timeo); in tipc_sendmcast()
782 struct sock *sk = &tsk->sk; in tipc_sk_proto_rcv()
809 static int tipc_wait_for_sndmsg(struct socket *sock, long *timeo_p) in tipc_wait_for_sndmsg() argument
811 struct sock *sk = sock->sk; in tipc_wait_for_sndmsg()
820 if (sock->state == SS_DISCONNECTING) in tipc_wait_for_sndmsg()
847 static int tipc_sendmsg(struct socket *sock, in tipc_sendmsg() argument
850 struct sock *sk = sock->sk; in tipc_sendmsg()
854 ret = __tipc_sendmsg(sock, m, dsz); in tipc_sendmsg()
860 static int __tipc_sendmsg(struct socket *sock, struct msghdr *m, size_t dsz) in __tipc_sendmsg() argument
863 struct sock *sk = sock->sk; in __tipc_sendmsg()
879 if (tsk->connected && sock->state == SS_READY) in __tipc_sendmsg()
887 if (unlikely(sock->state != SS_READY)) { in __tipc_sendmsg()
888 if (sock->state == SS_LISTENING) in __tipc_sendmsg()
890 if (sock->state != SS_UNCONNECTED) in __tipc_sendmsg()
903 return tipc_sendmcast(sock, seq, m, dsz, timeo); in __tipc_sendmsg()
942 if (sock->state != SS_READY) in __tipc_sendmsg()
943 sock->state = SS_CONNECTING; in __tipc_sendmsg()
948 rc = tipc_wait_for_sndmsg(sock, &timeo); in __tipc_sendmsg()
963 static int tipc_wait_for_sndpkt(struct socket *sock, long *timeo_p) in tipc_wait_for_sndpkt() argument
965 struct sock *sk = sock->sk; in tipc_wait_for_sndpkt()
974 if (sock->state == SS_DISCONNECTING) in tipc_wait_for_sndpkt()
976 else if (sock->state != SS_CONNECTED) in tipc_wait_for_sndpkt()
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()
1010 ret = __tipc_send_stream(sock, m, dsz); in tipc_send_stream()
1016 static int __tipc_send_stream(struct socket *sock, struct msghdr *m, size_t dsz) in __tipc_send_stream() argument
1018 struct sock *sk = sock->sk; in __tipc_send_stream()
1033 rc = __tipc_sendmsg(sock, m, dsz); in __tipc_send_stream()
1041 if (unlikely(sock->state != SS_CONNECTED)) { in __tipc_send_stream()
1042 if (sock->state == SS_DISCONNECTING) in __tipc_send_stream()
1082 rc = tipc_wait_for_sndpkt(sock, &timeo); in __tipc_send_stream()
1099 static int tipc_send_packet(struct socket *sock, struct msghdr *m, size_t dsz) in tipc_send_packet() argument
1104 return tipc_send_stream(sock, m, dsz); in tipc_send_packet()
1112 struct sock *sk = &tsk->sk; in tipc_sk_finish_conn()
1244 static int tipc_wait_for_rcvmsg(struct socket *sock, long *timeop) in tipc_wait_for_rcvmsg() argument
1246 struct sock *sk = sock->sk; in tipc_wait_for_rcvmsg()
1254 if (sock->state == SS_DISCONNECTING) { in tipc_wait_for_rcvmsg()
1288 static int tipc_recvmsg(struct socket *sock, struct msghdr *m, size_t buf_len, in tipc_recvmsg() argument
1291 struct sock *sk = sock->sk; in tipc_recvmsg()
1306 if (unlikely(sock->state == SS_UNCONNECTED)) { in tipc_recvmsg()
1315 res = tipc_wait_for_rcvmsg(sock, &timeo); in tipc_recvmsg()
1350 if ((sock->state == SS_READY) || in tipc_recvmsg()
1359 if ((sock->state != SS_READY) && in tipc_recvmsg()
1382 static int tipc_recv_stream(struct socket *sock, struct msghdr *m, in tipc_recv_stream() argument
1385 struct sock *sk = sock->sk; in tipc_recv_stream()
1402 if (unlikely(sock->state == SS_UNCONNECTED)) { in tipc_recv_stream()
1412 res = tipc_wait_for_rcvmsg(sock, &timeo); in tipc_recv_stream()
1493 static void tipc_write_space(struct sock *sk) in tipc_write_space()
1510 static void tipc_data_ready(struct sock *sk) in tipc_data_ready()
1522 static void tipc_sock_destruct(struct sock *sk) in tipc_sock_destruct()
1536 struct sock *sk = &tsk->sk; in filter_connect()
1538 struct socket *sock = sk->sk_socket; in filter_connect() local
1544 switch ((int)sock->state) { in filter_connect()
1552 sock->state = SS_DISCONNECTING; in filter_connect()
1567 sock->state = SS_DISCONNECTING; in filter_connect()
1573 sock->state = SS_DISCONNECTING; in filter_connect()
1580 sock->state = SS_CONNECTED; in filter_connect()
1604 pr_err("Unknown socket state %u\n", sock->state); in filter_connect()
1627 static unsigned int rcvbuf_limit(struct sock *sk, struct sk_buff *buf) in rcvbuf_limit()
1650 static bool filter_rcv(struct sock *sk, struct sk_buff *skb) in filter_rcv()
1652 struct socket *sock = sk->sk_socket; in filter_rcv() local
1678 if (unlikely(sock->state == SS_READY)) { in filter_rcv()
1716 static int tipc_backlog_rcv(struct sock *sk, struct sk_buff *skb) in tipc_backlog_rcv()
1734 static void tipc_sk_enqueue(struct sk_buff_head *inputq, struct sock *sk, in tipc_sk_enqueue()
1781 struct sock *sk; in tipc_sk_rcv()
1817 static int tipc_wait_for_connect(struct socket *sock, long *timeo_p) in tipc_wait_for_connect() argument
1819 struct sock *sk = sock->sk; in tipc_wait_for_connect()
1833 done = sk_wait_event(sk, timeo_p, sock->state != SS_CONNECTING); in tipc_wait_for_connect()
1848 static int tipc_connect(struct socket *sock, struct sockaddr *dest, in tipc_connect() argument
1851 struct sock *sk = sock->sk; in tipc_connect()
1862 if (sock->state == SS_READY) { in tipc_connect()
1886 previous = sock->state; in tipc_connect()
1887 switch (sock->state) { in tipc_connect()
1899 res = __tipc_sendmsg(sock, &m, 0); in tipc_connect()
1915 res = tipc_wait_for_connect(sock, &timeout); in tipc_connect()
1936 static int tipc_listen(struct socket *sock, int len) in tipc_listen() argument
1938 struct sock *sk = sock->sk; in tipc_listen()
1943 if (sock->state != SS_UNCONNECTED) in tipc_listen()
1946 sock->state = SS_LISTENING; in tipc_listen()
1954 static int tipc_wait_for_accept(struct socket *sock, long timeo) in tipc_wait_for_accept() argument
1956 struct sock *sk = sock->sk; in tipc_wait_for_accept()
1977 if (sock->state != SS_LISTENING) in tipc_wait_for_accept()
1998 static int tipc_accept(struct socket *sock, struct socket *new_sock, int flags) in tipc_accept() argument
2000 struct sock *new_sk, *sk = sock->sk; in tipc_accept()
2009 if (sock->state != SS_LISTENING) { in tipc_accept()
2014 res = tipc_wait_for_accept(sock, timeo); in tipc_accept()
2020 res = tipc_sk_create(sock_net(sock->sk), new_sock, 0, 1); in tipc_accept()
2023 security_sk_clone(sock->sk, new_sock->sk); in tipc_accept()
2077 static int tipc_shutdown(struct socket *sock, int how) in tipc_shutdown() argument
2079 struct sock *sk = sock->sk; in tipc_shutdown()
2094 switch (sock->state) { in tipc_shutdown()
2117 sock->state = SS_DISCONNECTING; in tipc_shutdown()
2142 struct sock *sk = &tsk->sk; in tipc_sk_timeout()
2279 struct sock *sk = &tsk->sk; in tipc_sk_insert()
2302 struct sock *sk = &tsk->sk; in tipc_sk_remove()
2351 static int tipc_setsockopt(struct socket *sock, int lvl, int opt, in tipc_setsockopt() argument
2354 struct sock *sk = sock->sk; in tipc_setsockopt()
2359 if ((lvl == IPPROTO_TCP) && (sock->type == SOCK_STREAM)) in tipc_setsockopt()
2376 if (sock->type != SOCK_STREAM) in tipc_setsockopt()
2410 static int tipc_getsockopt(struct socket *sock, int lvl, int opt, in tipc_getsockopt() argument
2413 struct sock *sk = sock->sk; in tipc_getsockopt()
2419 if ((lvl == IPPROTO_TCP) && (sock->type == SOCK_STREAM)) in tipc_getsockopt()
2467 static int tipc_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) in tipc_ioctl() argument
2469 struct sock *sk = sock->sk; in tipc_ioctl()
2811 struct nlattr *sock[TIPC_NLA_SOCK_MAX + 1]; in tipc_nl_publ_dump() local
2820 err = nla_parse_nested(sock, TIPC_NLA_SOCK_MAX, in tipc_nl_publ_dump()
2826 if (!sock[TIPC_NLA_SOCK_REF]) in tipc_nl_publ_dump()
2829 tsk_portid = nla_get_u32(sock[TIPC_NLA_SOCK_REF]); in tipc_nl_publ_dump()