--- zzzz-none-000/linux-4.19.183/net/ipv6/syncookies.c 2021-03-24 10:07:39.000000000 +0000 +++ bcm63-7530ax-756/linux-4.19.183/net/ipv6/syncookies.c 2023-06-28 08:54:21.000000000 +0000 @@ -20,6 +20,10 @@ #include #include #include +#if defined(CONFIG_BCM_KF_MPTCP) && defined(CONFIG_BCM_MPTCP) +#include +#include +#endif #include #define COOKIEBITS 24 /* Upper bits store count */ @@ -111,7 +115,12 @@ } EXPORT_SYMBOL_GPL(__cookie_v6_init_sequence); +#if !defined(CONFIG_BCM_KF_MPTCP) || !defined(CONFIG_BCM_MPTCP) __u32 cookie_v6_init_sequence(const struct sk_buff *skb, __u16 *mssp) +#else +__u32 cookie_v6_init_sequence(struct request_sock *req, const struct sock *sk, + const struct sk_buff *skb, __u16 *mssp) +#endif { const struct ipv6hdr *iph = ipv6_hdr(skb); const struct tcphdr *th = tcp_hdr(skb); @@ -133,6 +142,9 @@ struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb) { struct tcp_options_received tcp_opt; +#if defined(CONFIG_BCM_KF_MPTCP) && defined(CONFIG_BCM_MPTCP) + struct mptcp_options_received mopt; +#endif struct inet_request_sock *ireq; struct tcp_request_sock *treq; struct ipv6_pinfo *np = inet6_sk(sk); @@ -162,7 +174,12 @@ /* check for timestamp cookie support */ memset(&tcp_opt, 0, sizeof(tcp_opt)); +#if !defined(CONFIG_BCM_KF_MPTCP) || !defined(CONFIG_BCM_MPTCP) tcp_parse_options(sock_net(sk), skb, &tcp_opt, 0, NULL); +#else + mptcp_init_mp_opt(&mopt); + tcp_parse_options(sock_net(sk), skb, &tcp_opt, &mopt, 0, NULL, NULL); +#endif if (tcp_opt.saw_tstamp && tcp_opt.rcv_tsecr) { tsoff = secure_tcpv6_ts_off(sock_net(sk), @@ -175,14 +192,35 @@ goto out; ret = NULL; +#if !defined(CONFIG_BCM_KF_MPTCP) || !defined(CONFIG_BCM_MPTCP) req = inet_reqsk_alloc(&tcp6_request_sock_ops, sk, false); +#else +#ifdef CONFIG_MPTCP + if (mopt.saw_mpc) + req = inet_reqsk_alloc(&mptcp6_request_sock_ops, sk, false); + else +#endif + req = inet_reqsk_alloc(&tcp6_request_sock_ops, sk, false); +#endif if (!req) goto out; ireq = inet_rsk(req); +#if defined(CONFIG_BCM_KF_MPTCP) && defined(CONFIG_BCM_MPTCP) + ireq->mptcp_rqsk = 0; + ireq->saw_mpc = 0; +#endif treq = tcp_rsk(req); treq->tfo_listener = false; +#if defined(CONFIG_BCM_KF_MPTCP) && defined(CONFIG_BCM_MPTCP) + /* Must be done before anything else, as it initializes + * hash_entry of the MPTCP request-sock. + */ + if (mopt.saw_mpc) + mptcp_cookies_reqsk_init(req, &mopt, skb); + +#endif if (security_inet_conn_request(sk, skb, req)) goto out_free; @@ -246,6 +284,7 @@ } req->rsk_window_clamp = tp->window_clamp ? :dst_metric(dst, RTAX_WINDOW); +#if !defined(CONFIG_BCM_KF_MPTCP) || !defined(CONFIG_BCM_MPTCP) /* limit the window selection if the user enforce a smaller rx buffer */ full_space = tcp_full_space(sk); if (sk->sk_userlocks & SOCK_RCVBUF_LOCK && @@ -256,6 +295,12 @@ &req->rsk_rcv_wnd, &req->rsk_window_clamp, ireq->wscale_ok, &rcv_wscale, dst_metric(dst, RTAX_INITRWND)); +#else + tp->ops->select_initial_window(sk, tcp_full_space(sk), req->mss, + &req->rsk_rcv_wnd, &req->rsk_window_clamp, + ireq->wscale_ok, &rcv_wscale, + dst_metric(dst, RTAX_INITRWND)); +#endif ireq->rcv_wscale = rcv_wscale; ireq->ecn_ok = cookie_ecn_ok(&tcp_opt, sock_net(sk), dst);