--- zzzz-none-000/linux-4.19.183/net/ipv4/syncookies.c 2021-03-24 10:07:39.000000000 +0000 +++ bcm63-7530ax-756/linux-4.19.183/net/ipv4/syncookies.c 2023-06-28 08:54:21.000000000 +0000 @@ -16,6 +16,10 @@ #include #include #include +#if defined(CONFIG_BCM_KF_MPTCP) && defined(CONFIG_BCM_MPTCP) +#include +#include +#endif #include #include #include @@ -179,7 +183,12 @@ } EXPORT_SYMBOL_GPL(__cookie_v4_init_sequence); +#if !defined(CONFIG_BCM_KF_MPTCP) || !defined(CONFIG_BCM_MPTCP) __u32 cookie_v4_init_sequence(const struct sk_buff *skb, __u16 *mssp) +#else +__u32 cookie_v4_init_sequence(struct request_sock *req, const struct sock *sk, + const struct sk_buff *skb, __u16 *mssp) +#endif { const struct iphdr *iph = ip_hdr(skb); const struct tcphdr *th = tcp_hdr(skb); @@ -209,9 +218,31 @@ struct inet_connection_sock *icsk = inet_csk(sk); struct sock *child; bool own_req; +#if defined(CONFIG_BCM_KF_MPTCP) && defined(CONFIG_BCM_MPTCP) +#ifdef CONFIG_MPTCP + int ret; +#endif +#endif child = icsk->icsk_af_ops->syn_recv_sock(sk, skb, req, dst, NULL, &own_req); +#if defined(CONFIG_BCM_KF_MPTCP) && defined(CONFIG_BCM_MPTCP) + +#ifdef CONFIG_MPTCP + if (!child) + goto listen_overflow; + + ret = mptcp_check_req_master(sk, child, req, skb, 0, tsoff); + if (ret < 0) + return NULL; + + if (!ret) + return tcp_sk(child)->mpcb->master_sk; + +listen_overflow: +#endif + +#endif if (child) { refcount_set(&req->rsk_refcnt, 1); tcp_sk(child)->tsoffset = tsoff; @@ -289,6 +320,9 @@ { struct ip_options *opt = &TCP_SKB_CB(skb)->header.h4.opt; 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 tcp_sock *tp = tcp_sk(sk); @@ -318,7 +352,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_tcp_ts_off(sock_net(sk), @@ -331,7 +370,16 @@ goto out; ret = NULL; +#if !defined(CONFIG_BCM_KF_MPTCP) || !defined(CONFIG_BCM_MPTCP) req = inet_reqsk_alloc(&tcp_request_sock_ops, sk, false); /* for safety */ +#else +#ifdef CONFIG_MPTCP + if (mopt.saw_mpc) + req = inet_reqsk_alloc(&mptcp_request_sock_ops, sk, false); /* for safety */ + else +#endif + req = inet_reqsk_alloc(&tcp_request_sock_ops, sk, false); /* for safety */ +#endif if (!req) goto out; @@ -351,6 +399,10 @@ ireq->sack_ok = tcp_opt.sack_ok; ireq->wscale_ok = tcp_opt.wscale_ok; ireq->tstamp_ok = tcp_opt.saw_tstamp; +#if defined(CONFIG_BCM_KF_MPTCP) && defined(CONFIG_BCM_MPTCP) + ireq->mptcp_rqsk = 0; + ireq->saw_mpc = 0; +#endif req->ts_recent = tcp_opt.saw_tstamp ? tcp_opt.rcv_tsval : 0; treq->snt_synack = 0; treq->tfo_listener = false; @@ -359,6 +411,11 @@ ireq->ir_iif = inet_request_bound_dev_if(sk, skb); +#if defined(CONFIG_BCM_KF_MPTCP) && defined(CONFIG_BCM_MPTCP) + if (mopt.saw_mpc) + mptcp_cookies_reqsk_init(req, &mopt, skb); + +#endif /* We throwed the options of the initial SYN away, so we hope * the ACK carries the same options again (see RFC1122 4.2.3.8) */ @@ -397,10 +454,17 @@ (req->rsk_window_clamp > full_space || req->rsk_window_clamp == 0)) req->rsk_window_clamp = full_space; +#if !defined(CONFIG_BCM_KF_MPTCP) || !defined(CONFIG_BCM_MPTCP) tcp_select_initial_window(sk, full_space, req->mss, &req->rsk_rcv_wnd, &req->rsk_window_clamp, ireq->wscale_ok, &rcv_wscale, dst_metric(&rt->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(&rt->dst, RTAX_INITRWND)); +#endif ireq->rcv_wscale = rcv_wscale; ireq->ecn_ok = cookie_ecn_ok(&tcp_opt, sock_net(sk), &rt->dst);