• 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()
263 const int old_state = sk->sk_state; in dccp_disconnect()
266 dccp_set_state(sk, DCCP_CLOSED); in dccp_disconnect()
273 inet_csk_listen_stop(sk); in dccp_disconnect()
275 dccp_send_reset(sk, DCCP_RESET_CODE_ABORTED); in dccp_disconnect()
276 sk->sk_err = ECONNRESET; in dccp_disconnect()
278 sk->sk_err = ECONNRESET; in dccp_disconnect()
280 dccp_clear_xmit_timers(sk); in dccp_disconnect()
282 __skb_queue_purge(&sk->sk_receive_queue); in dccp_disconnect()
283 __skb_queue_purge(&sk->sk_write_queue); in dccp_disconnect()
284 if (sk->sk_send_head != NULL) { in dccp_disconnect()
285 __kfree_skb(sk->sk_send_head); in dccp_disconnect()
286 sk->sk_send_head = NULL; in dccp_disconnect()
291 if (!(sk->sk_userlocks & SOCK_BINDADDR_LOCK)) in dccp_disconnect()
292 inet_reset_saddr(sk); in dccp_disconnect()
294 sk->sk_shutdown = 0; in dccp_disconnect()
295 sock_reset_flag(sk, SOCK_DONE); in dccp_disconnect()
298 inet_csk_delack_init(sk); in dccp_disconnect()
299 __sk_dst_reset(sk); in dccp_disconnect()
303 sk->sk_error_report(sk); in dccp_disconnect()
320 struct sock *sk = sock->sk; in dccp_poll() local
322 sock_poll_wait(file, sk_sleep(sk), wait); in dccp_poll()
323 if (sk->sk_state == DCCP_LISTEN) in dccp_poll()
324 return inet_csk_listen_poll(sk); in dccp_poll()
332 if (sk->sk_err) in dccp_poll()
335 if (sk->sk_shutdown == SHUTDOWN_MASK || sk->sk_state == DCCP_CLOSED) in dccp_poll()
337 if (sk->sk_shutdown & RCV_SHUTDOWN) in dccp_poll()
341 if ((1 << sk->sk_state) & ~(DCCPF_REQUESTING | DCCPF_RESPOND)) { in dccp_poll()
342 if (atomic_read(&sk->sk_rmem_alloc) > 0) in dccp_poll()
345 if (!(sk->sk_shutdown & SEND_SHUTDOWN)) { in dccp_poll()
346 if (sk_stream_is_writeable(sk)) { in dccp_poll()
350 &sk->sk_socket->flags); in dccp_poll()
351 set_bit(SOCK_NOSPACE, &sk->sk_socket->flags); in dccp_poll()
357 if (sk_stream_is_writeable(sk)) in dccp_poll()
367 int dccp_ioctl(struct sock *sk, int cmd, unsigned long arg) in dccp_ioctl() argument
371 lock_sock(sk); in dccp_ioctl()
373 if (sk->sk_state == DCCP_LISTEN) in dccp_ioctl()
381 skb = skb_peek(&sk->sk_receive_queue); in dccp_ioctl()
397 release_sock(sk); in dccp_ioctl()
403 static int dccp_setsockopt_service(struct sock *sk, const __be32 service, in dccp_setsockopt_service() argument
406 struct dccp_sock *dp = dccp_sk(sk); in dccp_setsockopt_service()
428 lock_sock(sk); in dccp_setsockopt_service()
434 release_sock(sk); in dccp_setsockopt_service()
438 static int dccp_setsockopt_cscov(struct sock *sk, int cscov, bool rx) in dccp_setsockopt_cscov() argument
462 rc = dccp_feat_register_sp(sk, DCCPF_MIN_CSUM_COVER, rx, list, len); in dccp_setsockopt_cscov()
466 dccp_sk(sk)->dccps_pcrlen = cscov; in dccp_setsockopt_cscov()
468 dccp_sk(sk)->dccps_pcslen = cscov; in dccp_setsockopt_cscov()
474 static int dccp_setsockopt_ccid(struct sock *sk, int type, in dccp_setsockopt_ccid() argument
487 lock_sock(sk); in dccp_setsockopt_ccid()
489 rc = dccp_feat_register_sp(sk, DCCPF_CCID, 1, val, optlen); in dccp_setsockopt_ccid()
492 rc = dccp_feat_register_sp(sk, DCCPF_CCID, 0, val, optlen); in dccp_setsockopt_ccid()
493 release_sock(sk); in dccp_setsockopt_ccid()
499 static int do_dccp_setsockopt(struct sock *sk, int level, int optname, in do_dccp_setsockopt() argument
502 struct dccp_sock *dp = dccp_sk(sk); in do_dccp_setsockopt()
516 return dccp_setsockopt_ccid(sk, optname, optval, optlen); in do_dccp_setsockopt()
526 return dccp_setsockopt_service(sk, val, optval, optlen); in do_dccp_setsockopt()
528 lock_sock(sk); in do_dccp_setsockopt()
537 err = dccp_setsockopt_cscov(sk, val, false); in do_dccp_setsockopt()
540 err = dccp_setsockopt_cscov(sk, val, true); in do_dccp_setsockopt()
543 if (sk->sk_state != DCCP_CLOSED) in do_dccp_setsockopt()
560 release_sock(sk); in do_dccp_setsockopt()
565 int dccp_setsockopt(struct sock *sk, int level, int optname, in dccp_setsockopt() argument
569 return inet_csk(sk)->icsk_af_ops->setsockopt(sk, level, in dccp_setsockopt()
572 return do_dccp_setsockopt(sk, level, optname, optval, optlen); in dccp_setsockopt()
578 int compat_dccp_setsockopt(struct sock *sk, int level, int optname, in compat_dccp_setsockopt() argument
582 return inet_csk_compat_setsockopt(sk, level, optname, in compat_dccp_setsockopt()
584 return do_dccp_setsockopt(sk, level, optname, optval, optlen); in compat_dccp_setsockopt()
590 static int dccp_getsockopt_service(struct sock *sk, int len, in dccp_getsockopt_service() argument
594 const struct dccp_sock *dp = dccp_sk(sk); in dccp_getsockopt_service()
598 lock_sock(sk); in dccp_getsockopt_service()
614 release_sock(sk); in dccp_getsockopt_service()
618 static int do_dccp_getsockopt(struct sock *sk, int level, int optname, in do_dccp_getsockopt() argument
630 dp = dccp_sk(sk); in do_dccp_getsockopt()
637 return dccp_getsockopt_service(sk, len, in do_dccp_getsockopt()
643 return ccid_getsockopt_builtin_ccids(sk, len, optval, optlen); in do_dccp_getsockopt()
670 return ccid_hc_rx_getsockopt(dp->dccps_hc_rx_ccid, sk, optname, in do_dccp_getsockopt()
673 return ccid_hc_tx_getsockopt(dp->dccps_hc_tx_ccid, sk, optname, in do_dccp_getsockopt()
686 int dccp_getsockopt(struct sock *sk, int level, int optname, in dccp_getsockopt() argument
690 return inet_csk(sk)->icsk_af_ops->getsockopt(sk, level, in dccp_getsockopt()
693 return do_dccp_getsockopt(sk, level, optname, optval, optlen); in dccp_getsockopt()
699 int compat_dccp_getsockopt(struct sock *sk, int level, int optname, in compat_dccp_getsockopt() argument
703 return inet_csk_compat_getsockopt(sk, level, optname, in compat_dccp_getsockopt()
705 return do_dccp_getsockopt(sk, level, optname, optval, optlen); in compat_dccp_getsockopt()
736 !dccp_qpolicy_param_ok(skb->sk, cmsg->cmsg_type)) in dccp_msghdr_parse()
752 int dccp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, in dccp_sendmsg() argument
755 const struct dccp_sock *dp = dccp_sk(sk); in dccp_sendmsg()
765 lock_sock(sk); in dccp_sendmsg()
767 if (dccp_qpolicy_full(sk)) { in dccp_sendmsg()
772 timeo = sock_sndtimeo(sk, noblock); in dccp_sendmsg()
779 if ((1 << sk->sk_state) & ~(DCCPF_OPEN | DCCPF_PARTOPEN)) in dccp_sendmsg()
780 if ((rc = sk_stream_wait_connect(sk, &timeo)) != 0) in dccp_sendmsg()
783 size = sk->sk_prot->max_header + len; in dccp_sendmsg()
784 release_sock(sk); in dccp_sendmsg()
785 skb = sock_alloc_send_skb(sk, size, noblock, &rc); in dccp_sendmsg()
786 lock_sock(sk); in dccp_sendmsg()
790 skb_reserve(skb, sk->sk_prot->max_header); in dccp_sendmsg()
799 dccp_qpolicy_push(sk, skb); in dccp_sendmsg()
806 dccp_write_xmit(sk); in dccp_sendmsg()
808 release_sock(sk); in dccp_sendmsg()
817 int dccp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, in dccp_recvmsg() argument
823 lock_sock(sk); in dccp_recvmsg()
825 if (sk->sk_state == DCCP_LISTEN) { in dccp_recvmsg()
830 timeo = sock_rcvtimeo(sk, nonblock); in dccp_recvmsg()
833 struct sk_buff *skb = skb_peek(&sk->sk_receive_queue); in dccp_recvmsg()
848 dccp_finish_passive_close(sk); in dccp_recvmsg()
858 sk_eat_skb(sk, skb); in dccp_recvmsg()
861 if (sock_flag(sk, SOCK_DONE)) { in dccp_recvmsg()
866 if (sk->sk_err) { in dccp_recvmsg()
867 len = sock_error(sk); in dccp_recvmsg()
871 if (sk->sk_shutdown & RCV_SHUTDOWN) { in dccp_recvmsg()
876 if (sk->sk_state == DCCP_CLOSED) { in dccp_recvmsg()
877 if (!sock_flag(sk, SOCK_DONE)) { in dccp_recvmsg()
898 sk_wait_data(sk, &timeo); in dccp_recvmsg()
915 sk_eat_skb(sk, skb); in dccp_recvmsg()
919 release_sock(sk); in dccp_recvmsg()
927 struct sock *sk = sock->sk; in inet_dccp_listen() local
931 lock_sock(sk); in inet_dccp_listen()
937 old_state = sk->sk_state; in inet_dccp_listen()
949 err = dccp_listen_start(sk, backlog); in inet_dccp_listen()
953 sk->sk_max_ack_backlog = backlog; in inet_dccp_listen()
957 release_sock(sk); in inet_dccp_listen()
963 static void dccp_terminate_connection(struct sock *sk) in dccp_terminate_connection() argument
967 switch (sk->sk_state) { in dccp_terminate_connection()
970 dccp_finish_passive_close(sk); in dccp_terminate_connection()
973 dccp_pr_debug("Stop PARTOPEN timer (%p)\n", sk); in dccp_terminate_connection()
974 inet_csk_clear_xmit_timer(sk, ICSK_TIME_DACK); in dccp_terminate_connection()
977 dccp_send_close(sk, 1); in dccp_terminate_connection()
979 if (dccp_sk(sk)->dccps_role == DCCP_ROLE_SERVER && in dccp_terminate_connection()
980 !dccp_sk(sk)->dccps_server_timewait) in dccp_terminate_connection()
986 dccp_set_state(sk, next_state); in dccp_terminate_connection()
990 void dccp_close(struct sock *sk, long timeout) in dccp_close() argument
992 struct dccp_sock *dp = dccp_sk(sk); in dccp_close()
997 lock_sock(sk); in dccp_close()
999 sk->sk_shutdown = SHUTDOWN_MASK; in dccp_close()
1001 if (sk->sk_state == DCCP_LISTEN) { in dccp_close()
1002 dccp_set_state(sk, DCCP_CLOSED); in dccp_close()
1005 inet_csk_listen_stop(sk); in dccp_close()
1010 sk_stop_timer(sk, &dp->dccps_xmit_timer); in dccp_close()
1017 while ((skb = __skb_dequeue(&sk->sk_receive_queue)) != NULL) { in dccp_close()
1025 dccp_send_reset(sk, DCCP_RESET_CODE_ABORTED); in dccp_close()
1026 dccp_set_state(sk, DCCP_CLOSED); in dccp_close()
1027 } else if (sock_flag(sk, SOCK_LINGER) && !sk->sk_lingertime) { in dccp_close()
1029 sk->sk_prot->disconnect(sk, 0); in dccp_close()
1030 } else if (sk->sk_state != DCCP_CLOSED) { in dccp_close()
1035 dccp_flush_write_queue(sk, &timeout); in dccp_close()
1036 dccp_terminate_connection(sk); in dccp_close()
1045 __skb_queue_purge(&sk->sk_write_queue); in dccp_close()
1047 sk_stream_wait_close(sk, timeout); in dccp_close()
1050 state = sk->sk_state; in dccp_close()
1051 sock_hold(sk); in dccp_close()
1052 sock_orphan(sk); in dccp_close()
1057 release_sock(sk); in dccp_close()
1063 bh_lock_sock(sk); in dccp_close()
1064 WARN_ON(sock_owned_by_user(sk)); in dccp_close()
1066 percpu_counter_inc(sk->sk_prot->orphan_count); in dccp_close()
1069 if (state != DCCP_CLOSED && sk->sk_state == DCCP_CLOSED) in dccp_close()
1072 if (sk->sk_state == DCCP_CLOSED) in dccp_close()
1073 inet_csk_destroy_sock(sk); in dccp_close()
1078 bh_unlock_sock(sk); in dccp_close()
1080 sock_put(sk); in dccp_close()
1085 void dccp_shutdown(struct sock *sk, int how) in dccp_shutdown() argument