Lines Matching +full:tx +full:- +full:termination +full:- +full:fix
1 // SPDX-License-Identifier: GPL-2.0-only
51 /* the maximum queue length for tx in packets. 0 is no limit */
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()
120 switch (sk->sk_state) { in dccp_finish_passive_close()
141 sk->sk_shutdown = SHUTDOWN_MASK; in dccp_done()
144 sk->sk_state_change(sk); in dccp_done()
178 ccid_hc_tx_delete(dp->dccps_hc_tx_ccid, sk); in dccp_sk_destruct()
179 dp->dccps_hc_tx_ccid = NULL; in dccp_sk_destruct()
188 icsk->icsk_rto = DCCP_TIMEOUT_INIT; in dccp_init_sock()
189 icsk->icsk_syn_retries = sysctl_dccp_request_retries; 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()
193 icsk->icsk_sync_mss = dccp_sync_mss; in dccp_init_sock()
194 dp->dccps_mss_cache = 536; in dccp_init_sock()
195 dp->dccps_rate_last = jiffies; in dccp_init_sock()
196 dp->dccps_role = DCCP_ROLE_UNDEFINED; in dccp_init_sock()
197 dp->dccps_service = DCCP_SERVICE_CODE_IS_ABSENT; in dccp_init_sock()
198 dp->dccps_tx_qlen = sysctl_dccp_tx_qlen; in dccp_init_sock()
202 INIT_LIST_HEAD(&dp->dccps_featneg); in dccp_init_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()
225 kfree(dp->dccps_service_list); in dccp_destroy_sock()
226 dp->dccps_service_list = NULL; in dccp_destroy_sock()
228 if (dp->dccps_hc_rx_ackvec != NULL) { in dccp_destroy_sock()
229 dccp_ackvec_free(dp->dccps_hc_rx_ackvec); in dccp_destroy_sock()
230 dp->dccps_hc_rx_ackvec = NULL; in dccp_destroy_sock()
232 ccid_hc_rx_delete(dp->dccps_hc_rx_ccid, sk); in dccp_destroy_sock()
233 dp->dccps_hc_rx_ccid = NULL; in dccp_destroy_sock()
236 dccp_feat_list_purge(&dp->dccps_featneg); in dccp_destroy_sock()
245 dp->dccps_role = DCCP_ROLE_LISTEN; in dccp_listen_start()
248 return -EPROTO; in dccp_listen_start()
263 const int old_state = sk->sk_state; in dccp_disconnect()
276 sk->sk_err = ECONNRESET; in dccp_disconnect()
278 sk->sk_err = ECONNRESET; in dccp_disconnect()
281 ccid_hc_rx_delete(dp->dccps_hc_rx_ccid, sk); in dccp_disconnect()
282 dp->dccps_hc_rx_ccid = NULL; in dccp_disconnect()
284 __skb_queue_purge(&sk->sk_receive_queue); in dccp_disconnect()
285 __skb_queue_purge(&sk->sk_write_queue); in dccp_disconnect()
286 if (sk->sk_send_head != NULL) { in dccp_disconnect()
287 __kfree_skb(sk->sk_send_head); in dccp_disconnect()
288 sk->sk_send_head = NULL; in dccp_disconnect()
291 inet->inet_dport = 0; in dccp_disconnect()
293 if (!(sk->sk_userlocks & SOCK_BINDADDR_LOCK)) in dccp_disconnect()
296 sk->sk_shutdown = 0; in dccp_disconnect()
299 icsk->icsk_backoff = 0; in dccp_disconnect()
303 WARN_ON(inet->inet_num && !icsk->icsk_bind_hash); in dccp_disconnect()
305 sk->sk_error_report(sk); in dccp_disconnect()
322 struct sock *sk = sock->sk; in dccp_poll()
325 if (sk->sk_state == DCCP_LISTEN) in dccp_poll()
334 if (sk->sk_err) in dccp_poll()
337 if (sk->sk_shutdown == SHUTDOWN_MASK || sk->sk_state == DCCP_CLOSED) in dccp_poll()
339 if (sk->sk_shutdown & RCV_SHUTDOWN) in dccp_poll()
343 if ((1 << sk->sk_state) & ~(DCCPF_REQUESTING | DCCPF_RESPOND)) { in dccp_poll()
344 if (atomic_read(&sk->sk_rmem_alloc) > 0) in dccp_poll()
347 if (!(sk->sk_shutdown & SEND_SHUTDOWN)) { in dccp_poll()
352 set_bit(SOCK_NOSPACE, &sk->sk_socket->flags); in dccp_poll()
370 int rc = -ENOTCONN; in dccp_ioctl()
374 if (sk->sk_state == DCCP_LISTEN) in dccp_ioctl()
391 skb = skb_peek(&sk->sk_receive_queue); in dccp_ioctl()
397 amount = skb->len; in dccp_ioctl()
403 rc = -ENOIOCTLCMD; in dccp_ioctl()
421 return -EINVAL; in dccp_setsockopt_service()
426 return -ENOMEM; in dccp_setsockopt_service()
428 sl->dccpsl_nr = optlen / sizeof(u32) - 1; in dccp_setsockopt_service()
429 if (copy_from_sockptr_offset(sl->dccpsl_list, optval, in dccp_setsockopt_service()
430 sizeof(service), optlen - sizeof(service)) || in dccp_setsockopt_service()
433 return -EFAULT; in dccp_setsockopt_service()
438 dp->dccps_service = service; in dccp_setsockopt_service()
440 kfree(dp->dccps_service_list); in dccp_setsockopt_service()
442 dp->dccps_service_list = sl; in dccp_setsockopt_service()
453 return -EINVAL; in dccp_setsockopt_cscov()
458 * lowest-value first, negotiation will pick the smallest shared value. in dccp_setsockopt_cscov()
462 len = 16 - cscov; in dccp_setsockopt_cscov()
466 return -ENOBUFS; in dccp_setsockopt_cscov()
475 dccp_sk(sk)->dccps_pcrlen = cscov; in dccp_setsockopt_cscov()
477 dccp_sk(sk)->dccps_pcslen = cscov; in dccp_setsockopt_cscov()
490 return -EINVAL; in dccp_setsockopt_ccid()
516 DCCP_WARN("sockopt(PACKET_SIZE) is deprecated: fix your app\n"); in do_dccp_setsockopt()
520 DCCP_WARN("sockopt(CHANGE_L/R) is deprecated: fix your app\n"); in do_dccp_setsockopt()
529 return -EINVAL; in do_dccp_setsockopt()
532 return -EFAULT; in do_dccp_setsockopt()
540 if (dp->dccps_role != DCCP_ROLE_SERVER) in do_dccp_setsockopt()
541 err = -EOPNOTSUPP; in do_dccp_setsockopt()
543 dp->dccps_server_timewait = (val != 0); in do_dccp_setsockopt()
552 if (sk->sk_state != DCCP_CLOSED) in do_dccp_setsockopt()
553 err = -EISCONN; in do_dccp_setsockopt()
555 err = -EINVAL; in do_dccp_setsockopt()
557 dp->dccps_qpolicy = val; in do_dccp_setsockopt()
561 err = -EINVAL; in do_dccp_setsockopt()
563 dp->dccps_tx_qlen = val; in do_dccp_setsockopt()
566 err = -ENOPROTOOPT; in do_dccp_setsockopt()
578 return inet_csk(sk)->icsk_af_ops->setsockopt(sk, level, in dccp_setsockopt()
592 int err = -ENOENT, slen = 0, total_len = sizeof(u32); in dccp_getsockopt_service()
595 if ((sl = dp->dccps_service_list) != NULL) { in dccp_getsockopt_service()
596 slen = sl->dccpsl_nr * sizeof(u32); in dccp_getsockopt_service()
600 err = -EINVAL; in dccp_getsockopt_service()
606 put_user(dp->dccps_service, optval) || in dccp_getsockopt_service()
607 (sl != NULL && copy_to_user(optval + 1, sl->dccpsl_list, slen))) in dccp_getsockopt_service()
608 err = -EFAULT; in dccp_getsockopt_service()
621 return -EFAULT; in do_dccp_getsockopt()
624 return -EINVAL; in do_dccp_getsockopt()
630 DCCP_WARN("sockopt(PACKET_SIZE) is deprecated: fix your app\n"); in do_dccp_getsockopt()
636 val = dp->dccps_mss_cache; in do_dccp_getsockopt()
643 return -ENOPROTOOPT; in do_dccp_getsockopt()
648 return -ENOPROTOOPT; in do_dccp_getsockopt()
651 val = dp->dccps_server_timewait; in do_dccp_getsockopt()
654 val = dp->dccps_pcslen; in do_dccp_getsockopt()
657 val = dp->dccps_pcrlen; in do_dccp_getsockopt()
660 val = dp->dccps_qpolicy; in do_dccp_getsockopt()
663 val = dp->dccps_tx_qlen; in do_dccp_getsockopt()
666 return ccid_hc_rx_getsockopt(dp->dccps_hc_rx_ccid, sk, optname, in do_dccp_getsockopt()
669 return ccid_hc_tx_getsockopt(dp->dccps_hc_tx_ccid, sk, optname, in do_dccp_getsockopt()
672 return -ENOPROTOOPT; in do_dccp_getsockopt()
677 return -EFAULT; in do_dccp_getsockopt()
686 return inet_csk(sk)->icsk_af_ops->getsockopt(sk, level, in dccp_getsockopt()
699 * Assign an (opaque) qpolicy priority value to skb->priority. in dccp_msghdr_parse()
702 * The skb->priority is normally used for the SO_PRIORITY option, which in dccp_msghdr_parse()
704 * to skb->priority happens later (on layer 3), we overload this field in dccp_msghdr_parse()
708 skb->priority = 0; in dccp_msghdr_parse()
712 return -EINVAL; in dccp_msghdr_parse()
714 if (cmsg->cmsg_level != SOL_DCCP) in dccp_msghdr_parse()
717 if (cmsg->cmsg_type <= DCCP_SCM_QPOLICY_MAX && in dccp_msghdr_parse()
718 !dccp_qpolicy_param_ok(skb->sk, cmsg->cmsg_type)) in dccp_msghdr_parse()
719 return -EINVAL; in dccp_msghdr_parse()
721 switch (cmsg->cmsg_type) { in dccp_msghdr_parse()
723 if (cmsg->cmsg_len != CMSG_LEN(sizeof(__u32))) in dccp_msghdr_parse()
724 return -EINVAL; in dccp_msghdr_parse()
725 skb->priority = *(__u32 *)CMSG_DATA(cmsg); in dccp_msghdr_parse()
728 return -EINVAL; in dccp_msghdr_parse()
737 const int flags = msg->msg_flags; in dccp_sendmsg()
745 if (len > dp->dccps_mss_cache) in dccp_sendmsg()
746 return -EMSGSIZE; in dccp_sendmsg()
751 rc = -EAGAIN; in dccp_sendmsg()
762 if ((1 << sk->sk_state) & ~(DCCPF_OPEN | DCCPF_PARTOPEN)) in dccp_sendmsg()
766 size = sk->sk_prot->max_header + len; in dccp_sendmsg()
773 if (sk->sk_state == DCCP_CLOSED) { in dccp_sendmsg()
774 rc = -ENOTCONN; in dccp_sendmsg()
778 skb_reserve(skb, sk->sk_prot->max_header); in dccp_sendmsg()
789 * The xmit_timer is set if the TX CCID is rate-based and will expire in dccp_sendmsg()
791 * network. Window-based CCIDs do not use this timer. in dccp_sendmsg()
793 if (!timer_pending(&dp->dccps_xmit_timer)) in dccp_sendmsg()
813 if (sk->sk_state == DCCP_LISTEN) { in dccp_recvmsg()
814 len = -ENOTCONN; in dccp_recvmsg()
821 struct sk_buff *skb = skb_peek(&sk->sk_receive_queue); in dccp_recvmsg()
828 switch (dh->dccph_type) { in dccp_recvmsg()
840 dccp_packet_name(dh->dccph_type)); in dccp_recvmsg()
845 dccp_packet_name(dh->dccph_type)); in dccp_recvmsg()
854 if (sk->sk_err) { in dccp_recvmsg()
859 if (sk->sk_shutdown & RCV_SHUTDOWN) { in dccp_recvmsg()
864 if (sk->sk_state == DCCP_CLOSED) { in dccp_recvmsg()
869 len = -ENOTCONN; in dccp_recvmsg()
877 len = -EAGAIN; in dccp_recvmsg()
889 if (len > skb->len) in dccp_recvmsg()
890 len = skb->len; in dccp_recvmsg()
891 else if (len < skb->len) in dccp_recvmsg()
892 msg->msg_flags |= MSG_TRUNC; in dccp_recvmsg()
896 len = -EFAULT; in dccp_recvmsg()
900 len = skb->len; in dccp_recvmsg()
915 struct sock *sk = sock->sk; in inet_dccp_listen()
921 err = -EINVAL; in inet_dccp_listen()
922 if (sock->state != SS_UNCONNECTED || sock->type != SOCK_DCCP) in inet_dccp_listen()
925 old_state = sk->sk_state; in inet_dccp_listen()
929 WRITE_ONCE(sk->sk_max_ack_backlog, backlog); in inet_dccp_listen()
935 * FIXME: here it probably should be sk->sk_prot->listen_start in inet_dccp_listen()
955 switch (sk->sk_state) { in dccp_terminate_connection()
967 if (dccp_sk(sk)->dccps_role == DCCP_ROLE_SERVER && in dccp_terminate_connection()
968 !dccp_sk(sk)->dccps_server_timewait) in dccp_terminate_connection()
987 sk->sk_shutdown = SHUTDOWN_MASK; in dccp_close()
989 if (sk->sk_state == DCCP_LISTEN) { in dccp_close()
998 sk_stop_timer(sk, &dp->dccps_xmit_timer); in dccp_close()
1002 * descriptor close, not protocol-sourced closes, because the in dccp_close()
1005 while ((skb = __skb_dequeue(&sk->sk_receive_queue)) != NULL) { in dccp_close()
1006 data_was_unread += skb->len; in dccp_close()
1011 if (sk->sk_state == DCCP_CLOSED) in dccp_close()
1019 } else if (sock_flag(sk, SOCK_LINGER) && !sk->sk_lingertime) { in dccp_close()
1021 sk->sk_prot->disconnect(sk, 0); in dccp_close()
1022 } else if (sk->sk_state != DCCP_CLOSED) { in dccp_close()
1024 * Normal connection termination. May need to wait if there are in dccp_close()
1025 * still packets in the TX queue that are delayed by the CCID. in dccp_close()
1033 * - we have been closed by the peer but still have application data; in dccp_close()
1034 * - abortive termination (unread data or zero linger time), in dccp_close()
1035 * - normal termination but queue could not be flushed within time limit in dccp_close()
1037 __skb_queue_purge(&sk->sk_write_queue); in dccp_close()
1042 state = sk->sk_state; in dccp_close()
1058 percpu_counter_inc(sk->sk_prot->orphan_count); in dccp_close()
1061 if (state != DCCP_CLOSED && sk->sk_state == DCCP_CLOSED) in dccp_close()
1064 if (sk->sk_state == DCCP_CLOSED) in dccp_close()
1088 return -ENOMEM; in dccp_mib_init()
1125 rc = -ENOBUFS; in dccp_init()
1140 goal = nr_pages >> (21 - PAGE_SHIFT); in dccp_init()
1142 goal = nr_pages >> (23 - PAGE_SHIFT); in dccp_init()
1153 while (hash_size & (hash_size - 1)) in dccp_init()
1154 hash_size--; in dccp_init()
1155 dccp_hashinfo.ehash_mask = hash_size - 1; in dccp_init()
1158 } while (!dccp_hashinfo.ehash && --ehash_order > 0); in dccp_init()
1181 } while (!dccp_hashinfo.bhash && --bhash_order >= 0); in dccp_init()
1261 MODULE_DESCRIPTION("DCCP - Datagram Congestion Controlled Protocol");