Lines Matching +full:no +full:- +full:reset +full:- +full:on +full:- +full:init

1 // SPDX-License-Identifier: GPL-2.0-or-later
40 * The per-net v4_ctl_sk socket is used for responding to
41 * the Out-of-the-blue (OOTB) packets. A control sock will be created
57 dp->dccps_role = DCCP_ROLE_CLIENT; in dccp_v4_connect()
60 return -EINVAL; in dccp_v4_connect()
62 if (usin->sin_family != AF_INET) in dccp_v4_connect()
63 return -EAFNOSUPPORT; in dccp_v4_connect()
65 nexthop = daddr = usin->sin_addr.s_addr; in dccp_v4_connect()
67 inet_opt = rcu_dereference_protected(inet->inet_opt, in dccp_v4_connect()
69 if (inet_opt != NULL && inet_opt->opt.srr) { in dccp_v4_connect()
71 return -EINVAL; in dccp_v4_connect()
72 nexthop = inet_opt->opt.faddr; in dccp_v4_connect()
75 orig_sport = inet->inet_sport; in dccp_v4_connect()
76 orig_dport = usin->sin_port; in dccp_v4_connect()
77 fl4 = &inet->cork.fl.u.ip4; in dccp_v4_connect()
78 rt = ip_route_connect(fl4, nexthop, inet->inet_saddr, in dccp_v4_connect()
79 sk->sk_bound_dev_if, IPPROTO_DCCP, orig_sport, in dccp_v4_connect()
84 if (rt->rt_flags & (RTCF_MULTICAST | RTCF_BROADCAST)) { in dccp_v4_connect()
86 return -ENETUNREACH; in dccp_v4_connect()
89 if (inet_opt == NULL || !inet_opt->opt.srr) in dccp_v4_connect()
90 daddr = fl4->daddr; in dccp_v4_connect()
92 if (inet->inet_saddr == 0) { in dccp_v4_connect()
93 err = inet_bhash2_update_saddr(sk, &fl4->saddr, AF_INET); in dccp_v4_connect()
99 sk_rcv_saddr_set(sk, inet->inet_saddr); in dccp_v4_connect()
102 inet->inet_dport = usin->sin_port; in dccp_v4_connect()
105 inet_csk(sk)->icsk_ext_hdr_len = 0; in dccp_v4_connect()
107 inet_csk(sk)->icsk_ext_hdr_len = inet_opt->opt.optlen; in dccp_v4_connect()
120 inet->inet_sport, inet->inet_dport, sk); in dccp_v4_connect()
127 sk_setup_caps(sk, &rt->dst); in dccp_v4_connect()
129 dp->dccps_iss = secure_dccp_sequence_number(inet->inet_saddr, in dccp_v4_connect()
130 inet->inet_daddr, in dccp_v4_connect()
131 inet->inet_sport, in dccp_v4_connect()
132 inet->inet_dport); in dccp_v4_connect()
133 inet->inet_id = get_random_u16(); in dccp_v4_connect()
148 sk->sk_route_caps = 0; in dccp_v4_connect()
149 inet->inet_dport = 0; in dccp_v4_connect()
169 if (sk->sk_state == DCCP_LISTEN) in dccp_do_pmtu_discovery()
180 sk->sk_err_soft = EMSGSIZE; in dccp_do_pmtu_discovery()
184 if (inet->pmtudisc != IP_PMTUDISC_DONT && in dccp_do_pmtu_discovery()
186 inet_csk(sk)->icsk_pmtu_cookie > mtu) { in dccp_do_pmtu_discovery()
192 * DCCP-Sync packets are the best choice for upward in dccp_do_pmtu_discovery()
193 * probing, since DCCP-Sync probes do not risk application in dccp_do_pmtu_discovery()
196 dccp_send_sync(sk, dp->dccps_gsr, DCCP_PKT_SYNC); in dccp_do_pmtu_discovery()
205 dst->ops->redirect(dst, sk, skb); in dccp_do_redirect()
217 if (!between48(seq, dccp_rsk(req)->dreq_iss, dccp_rsk(req)->dreq_gss)) { in dccp_req_err()
222 * There is no good way to pass the error to the newly in dccp_req_err()
226 inet_csk_reqsk_queue_drop(req->rsk_listener, req); in dccp_req_err()
240 * accesses the socket the ICMP is just dropped and for some paths there is no
246 const struct iphdr *iph = (struct iphdr *)skb->data; in dccp_v4_err()
247 const u8 offset = iph->ihl << 2; in dccp_v4_err()
251 const int type = icmp_hdr(skb)->type; in dccp_v4_err()
252 const int code = icmp_hdr(skb)->code; in dccp_v4_err()
256 struct net *net = dev_net(skb->dev); in dccp_v4_err()
264 dh = (struct dccp_hdr *)(skb->data + offset); in dccp_v4_err()
267 iph->daddr, dh->dccph_dport, in dccp_v4_err()
268 iph->saddr, ntohs(dh->dccph_sport), in dccp_v4_err()
272 return -ENOENT; in dccp_v4_err()
275 if (sk->sk_state == DCCP_TIME_WAIT) { in dccp_v4_err()
280 if (sk->sk_state == DCCP_NEW_SYN_RECV) { in dccp_v4_err()
286 /* If too many ICMPs get dropped on busy in dccp_v4_err()
292 if (sk->sk_state == DCCP_CLOSED) in dccp_v4_err()
296 if ((1 << sk->sk_state) & ~(DCCPF_REQUESTING | DCCPF_LISTEN) && in dccp_v4_err()
297 !between48(seq, dp->dccps_awl, dp->dccps_awh)) { in dccp_v4_err()
332 switch (sk->sk_state) { in dccp_v4_err()
337 sk->sk_err = err; in dccp_v4_err()
343 sk->sk_err_soft = err; in dccp_v4_err()
360 * --ANK (980905) in dccp_v4_err()
364 if (!sock_owned_by_user(sk) && inet->recverr) { in dccp_v4_err()
365 sk->sk_err = err; in dccp_v4_err()
367 } else /* Only an error on timeout */ in dccp_v4_err()
368 sk->sk_err_soft = err; in dccp_v4_err()
378 return csum_tcpudp_magic(src, dst, skb->len, IPPROTO_DCCP, skb->csum); in dccp_v4_csum_finish()
387 dh->dccph_checksum = dccp_v4_csum_finish(skb, in dccp_v4_send_check()
388 inet->inet_saddr, in dccp_v4_send_check()
389 inet->inet_daddr); in dccp_v4_send_check()
395 return secure_dccp_sequence_number(ip_hdr(skb)->daddr, in dccp_v4_init_sequence()
396 ip_hdr(skb)->saddr, in dccp_v4_init_sequence()
397 dccp_hdr(skb)->dccph_dport, in dccp_v4_init_sequence()
398 dccp_hdr(skb)->dccph_sport); in dccp_v4_init_sequence()
402 * The three way handshake has completed - we got a valid ACK or DATAACK -
427 sk_daddr_set(newsk, ireq->ir_rmt_addr); in dccp_v4_request_recv_sock()
428 sk_rcv_saddr_set(newsk, ireq->ir_loc_addr); in dccp_v4_request_recv_sock()
429 newinet->inet_saddr = ireq->ir_loc_addr; in dccp_v4_request_recv_sock()
430 RCU_INIT_POINTER(newinet->inet_opt, rcu_dereference(ireq->ireq_opt)); in dccp_v4_request_recv_sock()
431 newinet->mc_index = inet_iif(skb); in dccp_v4_request_recv_sock()
432 newinet->mc_ttl = ip_hdr(skb)->ttl; in dccp_v4_request_recv_sock()
433 newinet->inet_id = get_random_u16(); in dccp_v4_request_recv_sock()
446 ireq->ireq_opt = NULL; in dccp_v4_request_recv_sock()
448 newinet->inet_opt = NULL; in dccp_v4_request_recv_sock()
459 newinet->inet_opt = NULL; in dccp_v4_request_recv_sock()
473 .daddr = iph->saddr, in dccp_v4_route_skb()
474 .saddr = iph->daddr, in dccp_v4_route_skb()
476 .flowi4_proto = sk->sk_protocol, in dccp_v4_route_skb()
477 .fl4_sport = dccp_hdr(skb)->dccph_dport, in dccp_v4_route_skb()
478 .fl4_dport = dccp_hdr(skb)->dccph_sport, in dccp_v4_route_skb()
488 return &rt->dst; in dccp_v4_route_skb()
493 int err = -1; in dccp_v4_send_response()
507 dh->dccph_checksum = dccp_v4_csum_finish(skb, ireq->ir_loc_addr, in dccp_v4_send_response()
508 ireq->ir_rmt_addr); in dccp_v4_send_response()
510 err = ip_build_and_send_pkt(skb, sk, ireq->ir_loc_addr, in dccp_v4_send_response()
511 ireq->ir_rmt_addr, in dccp_v4_send_response()
512 rcu_dereference(ireq->ireq_opt), in dccp_v4_send_response()
513 inet_sk(sk)->tos); in dccp_v4_send_response()
529 struct net *net = dev_net(skb_dst(rxskb)->dev); in dccp_v4_ctl_send_reset()
533 /* Never send a reset in response to a reset. */ in dccp_v4_ctl_send_reset()
534 if (dccp_hdr(rxskb)->dccph_type == DCCP_PKT_RESET) in dccp_v4_ctl_send_reset()
537 if (skb_rtable(rxskb)->rt_type != RTN_LOCAL) in dccp_v4_ctl_send_reset()
541 ctl_sk = pn->v4_ctl_sk; in dccp_v4_ctl_send_reset()
551 dccp_hdr(skb)->dccph_checksum = dccp_v4_csum_finish(skb, rxiph->saddr, in dccp_v4_ctl_send_reset()
552 rxiph->daddr); in dccp_v4_ctl_send_reset()
558 rxiph->daddr, rxiph->saddr, NULL, in dccp_v4_ctl_send_reset()
559 inet_sk(ctl_sk)->tos); in dccp_v4_ctl_send_reset()
573 dccp_feat_list_purge(&dccp_rsk(req)->dreq_featneg); in dccp_v4_reqsk_destructor()
574 kfree(rcu_dereference_protected(inet_rsk(req)->ireq_opt, 1)); in dccp_v4_reqsk_destructor()
597 const __be32 service = dccp_hdr_request(skb)->dccph_req_service; in dccp_v4_conn_request()
601 if (skb_rtable(skb)->rt_flags & (RTCF_BROADCAST | RTCF_MULTICAST)) in dccp_v4_conn_request()
602 return 0; /* discard, don't send a reset here */ in dccp_v4_conn_request()
605 dcb->dccpd_reset_code = DCCP_RESET_CODE_BAD_SERVICE_CODE; in dccp_v4_conn_request()
613 dcb->dccpd_reset_code = DCCP_RESET_CODE_TOO_BUSY; in dccp_v4_conn_request()
635 sk_rcv_saddr_set(req_to_sk(req), ip_hdr(skb)->daddr); in dccp_v4_conn_request()
636 sk_daddr_set(req_to_sk(req), ip_hdr(skb)->saddr); in dccp_v4_conn_request()
637 ireq->ir_mark = inet_request_mark(sk, skb); in dccp_v4_conn_request()
638 ireq->ireq_family = AF_INET; in dccp_v4_conn_request()
639 ireq->ir_iif = READ_ONCE(sk->sk_bound_dev_if); in dccp_v4_conn_request()
644 * Set S.ISR, S.GSR, S.SWL, S.SWH from packet or Init Cookie in dccp_v4_conn_request()
648 dreq->dreq_isr = dcb->dccpd_seq; in dccp_v4_conn_request()
649 dreq->dreq_gsr = dreq->dreq_isr; in dccp_v4_conn_request()
650 dreq->dreq_iss = dccp_v4_init_sequence(skb); in dccp_v4_conn_request()
651 dreq->dreq_gss = dreq->dreq_iss; in dccp_v4_conn_request()
652 dreq->dreq_service = service; in dccp_v4_conn_request()
665 return -1; in dccp_v4_conn_request()
673 if (sk->sk_state == DCCP_OPEN) { /* Fast path */ in dccp_v4_do_rcv()
674 if (dccp_rcv_established(sk, skb, dh, skb->len)) in dccp_v4_do_rcv()
675 goto reset; in dccp_v4_do_rcv()
681 * If P.type == Request or P contains a valid Init Cookie option, in dccp_v4_do_rcv()
682 * (* Must scan the packet's options to check for Init in dccp_v4_do_rcv()
683 * Cookies. Only Init Cookies are processed here, in dccp_v4_do_rcv()
685 * scan need only be performed if the endpoint uses Init in dccp_v4_do_rcv()
690 * Choose S.ISS (initial seqno) or set from Init Cookies in dccp_v4_do_rcv()
692 * Set S.ISR, S.GSR, S.SWL, S.SWH from packet or Init Cookies in dccp_v4_do_rcv()
696 * Generate Reset(No Connection) unless P.type == Reset in dccp_v4_do_rcv()
703 if (dccp_rcv_state_process(sk, skb, dh, skb->len)) in dccp_v4_do_rcv()
704 goto reset; in dccp_v4_do_rcv()
707 reset: in dccp_v4_do_rcv()
715 * dccp_invalid_packet - check for malformed packets
727 if (skb->pkt_type != PACKET_HOST) in dccp_invalid_packet()
739 if (dh->dccph_type >= DCCP_PKT_INVALID) { in dccp_invalid_packet()
747 dccph_doff = dh->dccph_doff; in dccp_invalid_packet()
764 if ((dh->dccph_type < DCCP_PKT_DATA || in dccp_invalid_packet()
765 dh->dccph_type > DCCP_PKT_DATAACK) && dh->dccph_x == 0) { in dccp_invalid_packet()
767 dccp_packet_name(dh->dccph_type)); in dccp_invalid_packet()
776 if (cscov > skb->len) { in dccp_invalid_packet()
778 dh->dccph_cscov, skb->len); in dccp_invalid_packet()
783 * (This step is completed in the AF-dependent functions.) */ in dccp_invalid_packet()
784 skb->csum = skb_checksum(skb, 0, cscov, 0); in dccp_invalid_packet()
806 if (dccp_v4_csum_finish(skb, iph->saddr, iph->daddr)) { in dccp_v4_rcv()
813 DCCP_SKB_CB(skb)->dccpd_seq = dccp_hdr_seq(dh); in dccp_v4_rcv()
814 DCCP_SKB_CB(skb)->dccpd_type = dh->dccph_type; in dccp_v4_rcv()
816 dccp_pr_debug("%8.8s src=%pI4@%-5d dst=%pI4@%-5d seq=%llu", in dccp_v4_rcv()
817 dccp_packet_name(dh->dccph_type), in dccp_v4_rcv()
818 &iph->saddr, ntohs(dh->dccph_sport), in dccp_v4_rcv()
819 &iph->daddr, ntohs(dh->dccph_dport), in dccp_v4_rcv()
820 (unsigned long long) DCCP_SKB_CB(skb)->dccpd_seq); in dccp_v4_rcv()
823 DCCP_SKB_CB(skb)->dccpd_ack_seq = DCCP_PKT_WITHOUT_ACK_SEQ; in dccp_v4_rcv()
826 DCCP_SKB_CB(skb)->dccpd_ack_seq = dccp_hdr_ack_seq(skb); in dccp_v4_rcv()
828 DCCP_SKB_CB(skb)->dccpd_ack_seq); in dccp_v4_rcv()
833 dh->dccph_sport, dh->dccph_dport, 0, &refcounted); in dccp_v4_rcv()
843 * Generate Reset(No Connection) unless P.type == Reset in dccp_v4_rcv()
846 if (sk->sk_state == DCCP_TIME_WAIT) { in dccp_v4_rcv()
847 dccp_pr_debug("sk->sk_state == DCCP_TIME_WAIT: do_time_wait\n"); in dccp_v4_rcv()
852 if (sk->sk_state == DCCP_NEW_SYN_RECV) { in dccp_v4_rcv()
856 sk = req->rsk_listener; in dccp_v4_rcv()
857 if (unlikely(sk->sk_state != DCCP_LISTEN)) { in dccp_v4_rcv()
883 min_cov = dccp_sk(sk)->dccps_pcrlen; in dccp_v4_rcv()
884 if (dh->dccph_cscov && (min_cov == 0 || dh->dccph_cscov < min_cov)) { in dccp_v4_rcv()
886 dh->dccph_cscov, min_cov); in dccp_v4_rcv()
897 return __sk_receive_skb(sk, skb, 1, dh->dccph_doff * 4, refcounted); in dccp_v4_rcv()
904 * If no socket ... in dccp_v4_rcv()
905 * Generate Reset(No Connection) unless P.type == Reset in dccp_v4_rcv()
908 if (dh->dccph_type != DCCP_PKT_RESET) { in dccp_v4_rcv()
909 DCCP_SKB_CB(skb)->dccpd_reset_code = in dccp_v4_rcv()
945 inet_csk(sk)->icsk_af_ops = &dccp_ipv4_af_ops; in dccp_v4_init_sock()
962 .init = dccp_v4_init_sock,
999 /* FIXME: work on tcp_poll to rename it to inet_csk_poll */
1003 /* FIXME: work on inet_listen to rename it to sock_common_listen */
1027 return -ESOCKTNOSUPPORT; in dccp_v4_init_net()
1029 return inet_ctl_sock_create(&pn->v4_ctl_sk, PF_INET, in dccp_v4_init_net()
1037 inet_ctl_sock_destroy(pn->v4_ctl_sk); in dccp_v4_exit_net()
1046 .init = dccp_v4_init_net,
1094 * i.e. net-pf-PF_INET-proto-0-type-SOCK_DCCP
1100 MODULE_DESCRIPTION("DCCP - Datagram Congestion Controlled Protocol");