• Home
  • Raw
  • Download

Lines Matching refs:sk

78 void dccp_set_state(struct sock *sk, const int state)  in dccp_set_state()  argument
80 const int oldstate = sk->sk_state; in dccp_set_state()
82 dccp_pr_debug("%s(%p) %s --> %s\n", dccp_role(sk), sk, in dccp_set_state()
92 dccp_feat_list_purge(&dccp_sk(sk)->dccps_featneg); in dccp_set_state()
100 sk->sk_prot->unhash(sk); in dccp_set_state()
101 if (inet_csk(sk)->icsk_bind_hash != NULL && in dccp_set_state()
102 !(sk->sk_userlocks & SOCK_BINDPORT_LOCK)) in dccp_set_state()
103 inet_put_port(sk); in dccp_set_state()
113 sk->sk_state = state; in dccp_set_state()
118 static void dccp_finish_passive_close(struct sock *sk) in dccp_finish_passive_close() argument
120 switch (sk->sk_state) { in dccp_finish_passive_close()
123 dccp_send_reset(sk, DCCP_RESET_CODE_CLOSED); in dccp_finish_passive_close()
124 dccp_set_state(sk, DCCP_CLOSED); in dccp_finish_passive_close()
131 dccp_send_close(sk, 1); in dccp_finish_passive_close()
132 dccp_set_state(sk, DCCP_CLOSING); in dccp_finish_passive_close()
136 void dccp_done(struct sock *sk) in dccp_done() argument
138 dccp_set_state(sk, DCCP_CLOSED); in dccp_done()
139 dccp_clear_xmit_timers(sk); in dccp_done()
141 sk->sk_shutdown = SHUTDOWN_MASK; in dccp_done()
143 if (!sock_flag(sk, SOCK_DEAD)) in dccp_done()
144 sk->sk_state_change(sk); in dccp_done()
146 inet_csk_destroy_sock(sk); in dccp_done()
174 static void dccp_sk_destruct(struct sock *sk) in dccp_sk_destruct() argument
176 struct dccp_sock *dp = dccp_sk(sk); in dccp_sk_destruct()
178 ccid_hc_tx_delete(dp->dccps_hc_tx_ccid, sk); in dccp_sk_destruct()
180 inet_sock_destruct(sk); in dccp_sk_destruct()
183 int dccp_init_sock(struct sock *sk, const __u8 ctl_sock_initialized) in dccp_init_sock() argument
185 struct dccp_sock *dp = dccp_sk(sk); in dccp_init_sock()
186 struct inet_connection_sock *icsk = inet_csk(sk); in dccp_init_sock()
190 sk->sk_state = DCCP_CLOSED; in dccp_init_sock()
191 sk->sk_write_space = dccp_write_space; in dccp_init_sock()
192 sk->sk_destruct = dccp_sk_destruct; in dccp_init_sock()
200 dccp_init_xmit_timers(sk); in dccp_init_sock()
205 return dccp_feat_init(sk); in dccp_init_sock()
211 void dccp_destroy_sock(struct sock *sk) in dccp_destroy_sock() argument
213 struct dccp_sock *dp = dccp_sk(sk); in dccp_destroy_sock()
215 __skb_queue_purge(&sk->sk_write_queue); in dccp_destroy_sock()
216 if (sk->sk_send_head != NULL) { in dccp_destroy_sock()
217 kfree_skb(sk->sk_send_head); in dccp_destroy_sock()
218 sk->sk_send_head = NULL; in dccp_destroy_sock()
222 if (inet_csk(sk)->icsk_bind_hash != NULL) in dccp_destroy_sock()
223 inet_put_port(sk); in dccp_destroy_sock()
232 ccid_hc_rx_delete(dp->dccps_hc_rx_ccid, sk); in dccp_destroy_sock()
241 static inline int dccp_listen_start(struct sock *sk, int backlog) in dccp_listen_start() argument
243 struct dccp_sock *dp = dccp_sk(sk); in dccp_listen_start()
249 return inet_csk_listen_start(sk, backlog); in dccp_listen_start()
258 int dccp_disconnect(struct sock *sk, int flags) in dccp_disconnect() argument
260 struct inet_connection_sock *icsk = inet_csk(sk); in dccp_disconnect()
261 struct inet_sock *inet = inet_sk(sk); in dccp_disconnect()
262 struct dccp_sock *dp = dccp_sk(sk); in dccp_disconnect()
264 const int old_state = sk->sk_state; in dccp_disconnect()
267 dccp_set_state(sk, DCCP_CLOSED); in dccp_disconnect()
274 inet_csk_listen_stop(sk); in dccp_disconnect()
276 dccp_send_reset(sk, DCCP_RESET_CODE_ABORTED); in dccp_disconnect()
277 sk->sk_err = ECONNRESET; in dccp_disconnect()
279 sk->sk_err = ECONNRESET; in dccp_disconnect()
281 dccp_clear_xmit_timers(sk); in dccp_disconnect()
282 ccid_hc_rx_delete(dp->dccps_hc_rx_ccid, sk); in dccp_disconnect()
283 ccid_hc_tx_delete(dp->dccps_hc_tx_ccid, sk); in dccp_disconnect()
287 __skb_queue_purge(&sk->sk_receive_queue); in dccp_disconnect()
288 __skb_queue_purge(&sk->sk_write_queue); in dccp_disconnect()
289 if (sk->sk_send_head != NULL) { in dccp_disconnect()
290 __kfree_skb(sk->sk_send_head); in dccp_disconnect()
291 sk->sk_send_head = NULL; in dccp_disconnect()
296 if (!(sk->sk_userlocks & SOCK_BINDADDR_LOCK)) in dccp_disconnect()
297 inet_reset_saddr(sk); in dccp_disconnect()
299 sk->sk_shutdown = 0; in dccp_disconnect()
300 sock_reset_flag(sk, SOCK_DONE); in dccp_disconnect()
303 inet_csk_delack_init(sk); in dccp_disconnect()
304 __sk_dst_reset(sk); in dccp_disconnect()
308 sk->sk_error_report(sk); in dccp_disconnect()
325 struct sock *sk = sock->sk; in dccp_poll() local
327 sock_poll_wait(file, sk_sleep(sk), wait); in dccp_poll()
328 if (sk->sk_state == DCCP_LISTEN) in dccp_poll()
329 return inet_csk_listen_poll(sk); in dccp_poll()
337 if (sk->sk_err) in dccp_poll()
340 if (sk->sk_shutdown == SHUTDOWN_MASK || sk->sk_state == DCCP_CLOSED) in dccp_poll()
342 if (sk->sk_shutdown & RCV_SHUTDOWN) in dccp_poll()
346 if ((1 << sk->sk_state) & ~(DCCPF_REQUESTING | DCCPF_RESPOND)) { in dccp_poll()
347 if (atomic_read(&sk->sk_rmem_alloc) > 0) in dccp_poll()
350 if (!(sk->sk_shutdown & SEND_SHUTDOWN)) { in dccp_poll()
351 if (sk_stream_is_writeable(sk)) { in dccp_poll()
354 sk_set_bit(SOCKWQ_ASYNC_NOSPACE, sk); in dccp_poll()
355 set_bit(SOCK_NOSPACE, &sk->sk_socket->flags); in dccp_poll()
361 if (sk_stream_is_writeable(sk)) in dccp_poll()
371 int dccp_ioctl(struct sock *sk, int cmd, unsigned long arg) in dccp_ioctl() argument
375 lock_sock(sk); in dccp_ioctl()
377 if (sk->sk_state == DCCP_LISTEN) in dccp_ioctl()
385 skb = skb_peek(&sk->sk_receive_queue); in dccp_ioctl()
401 release_sock(sk); in dccp_ioctl()
407 static int dccp_setsockopt_service(struct sock *sk, const __be32 service, in dccp_setsockopt_service() argument
410 struct dccp_sock *dp = dccp_sk(sk); in dccp_setsockopt_service()
432 lock_sock(sk); in dccp_setsockopt_service()
438 release_sock(sk); in dccp_setsockopt_service()
442 static int dccp_setsockopt_cscov(struct sock *sk, int cscov, bool rx) in dccp_setsockopt_cscov() argument
466 rc = dccp_feat_register_sp(sk, DCCPF_MIN_CSUM_COVER, rx, list, len); in dccp_setsockopt_cscov()
470 dccp_sk(sk)->dccps_pcrlen = cscov; in dccp_setsockopt_cscov()
472 dccp_sk(sk)->dccps_pcslen = cscov; in dccp_setsockopt_cscov()
478 static int dccp_setsockopt_ccid(struct sock *sk, int type, in dccp_setsockopt_ccid() argument
491 lock_sock(sk); in dccp_setsockopt_ccid()
493 rc = dccp_feat_register_sp(sk, DCCPF_CCID, 1, val, optlen); in dccp_setsockopt_ccid()
496 rc = dccp_feat_register_sp(sk, DCCPF_CCID, 0, val, optlen); in dccp_setsockopt_ccid()
497 release_sock(sk); in dccp_setsockopt_ccid()
503 static int do_dccp_setsockopt(struct sock *sk, int level, int optname, in do_dccp_setsockopt() argument
506 struct dccp_sock *dp = dccp_sk(sk); in do_dccp_setsockopt()
520 return dccp_setsockopt_ccid(sk, optname, optval, optlen); in do_dccp_setsockopt()
530 return dccp_setsockopt_service(sk, val, optval, optlen); in do_dccp_setsockopt()
532 lock_sock(sk); in do_dccp_setsockopt()
541 err = dccp_setsockopt_cscov(sk, val, false); in do_dccp_setsockopt()
544 err = dccp_setsockopt_cscov(sk, val, true); in do_dccp_setsockopt()
547 if (sk->sk_state != DCCP_CLOSED) in do_dccp_setsockopt()
564 release_sock(sk); in do_dccp_setsockopt()
569 int dccp_setsockopt(struct sock *sk, int level, int optname, in dccp_setsockopt() argument
573 return inet_csk(sk)->icsk_af_ops->setsockopt(sk, level, in dccp_setsockopt()
576 return do_dccp_setsockopt(sk, level, optname, optval, optlen); in dccp_setsockopt()
582 int compat_dccp_setsockopt(struct sock *sk, int level, int optname, in compat_dccp_setsockopt() argument
586 return inet_csk_compat_setsockopt(sk, level, optname, in compat_dccp_setsockopt()
588 return do_dccp_setsockopt(sk, level, optname, optval, optlen); in compat_dccp_setsockopt()
594 static int dccp_getsockopt_service(struct sock *sk, int len, in dccp_getsockopt_service() argument
598 const struct dccp_sock *dp = dccp_sk(sk); in dccp_getsockopt_service()
602 lock_sock(sk); in dccp_getsockopt_service()
618 release_sock(sk); in dccp_getsockopt_service()
622 static int do_dccp_getsockopt(struct sock *sk, int level, int optname, in do_dccp_getsockopt() argument
634 dp = dccp_sk(sk); in do_dccp_getsockopt()
641 return dccp_getsockopt_service(sk, len, in do_dccp_getsockopt()
647 return ccid_getsockopt_builtin_ccids(sk, len, optval, optlen); in do_dccp_getsockopt()
674 return ccid_hc_rx_getsockopt(dp->dccps_hc_rx_ccid, sk, optname, in do_dccp_getsockopt()
677 return ccid_hc_tx_getsockopt(dp->dccps_hc_tx_ccid, sk, optname, in do_dccp_getsockopt()
690 int dccp_getsockopt(struct sock *sk, int level, int optname, in dccp_getsockopt() argument
694 return inet_csk(sk)->icsk_af_ops->getsockopt(sk, level, in dccp_getsockopt()
697 return do_dccp_getsockopt(sk, level, optname, optval, optlen); in dccp_getsockopt()
703 int compat_dccp_getsockopt(struct sock *sk, int level, int optname, in compat_dccp_getsockopt() argument
707 return inet_csk_compat_getsockopt(sk, level, optname, in compat_dccp_getsockopt()
709 return do_dccp_getsockopt(sk, level, optname, optval, optlen); in compat_dccp_getsockopt()
739 !dccp_qpolicy_param_ok(skb->sk, cmsg->cmsg_type)) in dccp_msghdr_parse()
755 int dccp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len) in dccp_sendmsg() argument
757 const struct dccp_sock *dp = dccp_sk(sk); in dccp_sendmsg()
767 lock_sock(sk); in dccp_sendmsg()
769 if (dccp_qpolicy_full(sk)) { in dccp_sendmsg()
774 timeo = sock_sndtimeo(sk, noblock); in dccp_sendmsg()
781 if ((1 << sk->sk_state) & ~(DCCPF_OPEN | DCCPF_PARTOPEN)) in dccp_sendmsg()
782 if ((rc = sk_stream_wait_connect(sk, &timeo)) != 0) in dccp_sendmsg()
785 size = sk->sk_prot->max_header + len; in dccp_sendmsg()
786 release_sock(sk); in dccp_sendmsg()
787 skb = sock_alloc_send_skb(sk, size, noblock, &rc); in dccp_sendmsg()
788 lock_sock(sk); in dccp_sendmsg()
792 if (sk->sk_state == DCCP_CLOSED) { in dccp_sendmsg()
797 skb_reserve(skb, sk->sk_prot->max_header); in dccp_sendmsg()
806 dccp_qpolicy_push(sk, skb); in dccp_sendmsg()
813 dccp_write_xmit(sk); in dccp_sendmsg()
815 release_sock(sk); in dccp_sendmsg()
824 int dccp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int nonblock, in dccp_recvmsg() argument
830 lock_sock(sk); in dccp_recvmsg()
832 if (sk->sk_state == DCCP_LISTEN) { in dccp_recvmsg()
837 timeo = sock_rcvtimeo(sk, nonblock); in dccp_recvmsg()
840 struct sk_buff *skb = skb_peek(&sk->sk_receive_queue); in dccp_recvmsg()
855 dccp_finish_passive_close(sk); in dccp_recvmsg()
865 sk_eat_skb(sk, skb); in dccp_recvmsg()
868 if (sock_flag(sk, SOCK_DONE)) { in dccp_recvmsg()
873 if (sk->sk_err) { in dccp_recvmsg()
874 len = sock_error(sk); in dccp_recvmsg()
878 if (sk->sk_shutdown & RCV_SHUTDOWN) { in dccp_recvmsg()
883 if (sk->sk_state == DCCP_CLOSED) { in dccp_recvmsg()
884 if (!sock_flag(sk, SOCK_DONE)) { in dccp_recvmsg()
905 sk_wait_data(sk, &timeo, NULL); in dccp_recvmsg()
922 sk_eat_skb(sk, skb); in dccp_recvmsg()
926 release_sock(sk); in dccp_recvmsg()
934 struct sock *sk = sock->sk; in inet_dccp_listen() local
938 lock_sock(sk); in inet_dccp_listen()
944 old_state = sk->sk_state; in inet_dccp_listen()
956 err = dccp_listen_start(sk, backlog); in inet_dccp_listen()
960 sk->sk_max_ack_backlog = backlog; in inet_dccp_listen()
964 release_sock(sk); in inet_dccp_listen()
970 static void dccp_terminate_connection(struct sock *sk) in dccp_terminate_connection() argument
974 switch (sk->sk_state) { in dccp_terminate_connection()
977 dccp_finish_passive_close(sk); in dccp_terminate_connection()
980 dccp_pr_debug("Stop PARTOPEN timer (%p)\n", sk); in dccp_terminate_connection()
981 inet_csk_clear_xmit_timer(sk, ICSK_TIME_DACK); in dccp_terminate_connection()
984 dccp_send_close(sk, 1); in dccp_terminate_connection()
986 if (dccp_sk(sk)->dccps_role == DCCP_ROLE_SERVER && in dccp_terminate_connection()
987 !dccp_sk(sk)->dccps_server_timewait) in dccp_terminate_connection()
993 dccp_set_state(sk, next_state); in dccp_terminate_connection()
997 void dccp_close(struct sock *sk, long timeout) in dccp_close() argument
999 struct dccp_sock *dp = dccp_sk(sk); in dccp_close()
1004 lock_sock(sk); in dccp_close()
1006 sk->sk_shutdown = SHUTDOWN_MASK; in dccp_close()
1008 if (sk->sk_state == DCCP_LISTEN) { in dccp_close()
1009 dccp_set_state(sk, DCCP_CLOSED); in dccp_close()
1012 inet_csk_listen_stop(sk); in dccp_close()
1017 sk_stop_timer(sk, &dp->dccps_xmit_timer); in dccp_close()
1024 while ((skb = __skb_dequeue(&sk->sk_receive_queue)) != NULL) { in dccp_close()
1030 if (sk->sk_state == DCCP_CLOSED) in dccp_close()
1036 dccp_send_reset(sk, DCCP_RESET_CODE_ABORTED); in dccp_close()
1037 dccp_set_state(sk, DCCP_CLOSED); in dccp_close()
1038 } else if (sock_flag(sk, SOCK_LINGER) && !sk->sk_lingertime) { in dccp_close()
1040 sk->sk_prot->disconnect(sk, 0); in dccp_close()
1041 } else if (sk->sk_state != DCCP_CLOSED) { in dccp_close()
1046 dccp_flush_write_queue(sk, &timeout); in dccp_close()
1047 dccp_terminate_connection(sk); in dccp_close()
1056 __skb_queue_purge(&sk->sk_write_queue); in dccp_close()
1058 sk_stream_wait_close(sk, timeout); in dccp_close()
1061 state = sk->sk_state; in dccp_close()
1062 sock_hold(sk); in dccp_close()
1063 sock_orphan(sk); in dccp_close()
1068 release_sock(sk); in dccp_close()
1074 bh_lock_sock(sk); in dccp_close()
1075 WARN_ON(sock_owned_by_user(sk)); in dccp_close()
1077 percpu_counter_inc(sk->sk_prot->orphan_count); in dccp_close()
1080 if (state != DCCP_CLOSED && sk->sk_state == DCCP_CLOSED) in dccp_close()
1083 if (sk->sk_state == DCCP_CLOSED) in dccp_close()
1084 inet_csk_destroy_sock(sk); in dccp_close()
1089 bh_unlock_sock(sk); in dccp_close()
1091 sock_put(sk); in dccp_close()
1096 void dccp_shutdown(struct sock *sk, int how) in dccp_shutdown() argument