--- zzzz-none-000/linux-4.1.38/net/ipv4/syncookies.c 2017-01-18 18:48:06.000000000 +0000 +++ bcm63-7582-715/linux-4.1.38/net/ipv4/syncookies.c 2020-11-25 10:06:48.000000000 +0000 @@ -16,6 +16,10 @@ #include #include #include +#if defined(CONFIG_BCM_MPTCP) && defined(CONFIG_BCM_KF_MPTCP) +#include +#include +#endif #include #include @@ -192,8 +196,13 @@ } EXPORT_SYMBOL_GPL(__cookie_v4_init_sequence); +#if !defined(CONFIG_BCM_MPTCP) || !defined(CONFIG_BCM_KF_MPTCP) __u32 cookie_v4_init_sequence(struct sock *sk, const struct sk_buff *skb, __u16 *mssp) +#else +__u32 cookie_v4_init_sequence(struct request_sock *req, 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); @@ -225,8 +234,30 @@ { struct inet_connection_sock *icsk = inet_csk(sk); struct sock *child; +#if defined(CONFIG_BCM_MPTCP) && defined(CONFIG_BCM_KF_MPTCP) +#ifdef CONFIG_MPTCP + int ret; +#endif +#endif child = icsk->icsk_af_ops->syn_recv_sock(sk, skb, req, dst); +#if defined(CONFIG_BCM_MPTCP) && defined(CONFIG_BCM_KF_MPTCP) + +#ifdef CONFIG_MPTCP + if (!child) + goto listen_overflow; + + ret = mptcp_check_req_master(sk, child, req, 0); + if (ret < 0) + return NULL; + + if (!ret) + return tcp_sk(child)->mpcb->master_sk; + +listen_overflow: +#endif + +#endif if (child) { atomic_set(&req->rsk_refcnt, 1); inet_csk_reqsk_queue_add(sk, req, child); @@ -292,6 +323,9 @@ { struct ip_options *opt = &TCP_SKB_CB(skb)->header.h4.opt; struct tcp_options_received tcp_opt; +#if defined(CONFIG_BCM_MPTCP) && defined(CONFIG_BCM_KF_MPTCP) + struct mptcp_options_received mopt; +#endif struct inet_request_sock *ireq; struct tcp_request_sock *treq; struct tcp_sock *tp = tcp_sk(sk); @@ -320,13 +354,27 @@ /* check for timestamp cookie support */ memset(&tcp_opt, 0, sizeof(tcp_opt)); +#if !defined(CONFIG_BCM_MPTCP) || !defined(CONFIG_BCM_KF_MPTCP) tcp_parse_options(skb, &tcp_opt, 0, NULL); +#else + mptcp_init_mp_opt(&mopt); + tcp_parse_options(skb, &tcp_opt, &mopt, 0, NULL, NULL); +#endif if (!cookie_timestamp_decode(&tcp_opt)) goto out; ret = NULL; +#if !defined(CONFIG_BCM_MPTCP) || !defined(CONFIG_BCM_KF_MPTCP) req = inet_reqsk_alloc(&tcp_request_sock_ops, sk); /* for safety */ +#else +#ifdef CONFIG_MPTCP + if (mopt.saw_mpc) + req = inet_reqsk_alloc(&mptcp_request_sock_ops, sk); /* for safety */ + else +#endif + req = inet_reqsk_alloc(&tcp_request_sock_ops, sk); /* for safety */ +#endif if (!req) goto out; @@ -344,12 +392,21 @@ 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_MPTCP) && defined(CONFIG_BCM_KF_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 = tcp_opt.saw_tstamp ? tcp_opt.rcv_tsecr : 0; treq->tfo_listener = false; ireq->ir_iif = sk->sk_bound_dev_if; +#if defined(CONFIG_BCM_MPTCP) && defined(CONFIG_BCM_KF_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) */ @@ -383,10 +440,17 @@ /* Try to redo what tcp_v4_send_synack did. */ req->window_clamp = tp->window_clamp ? :dst_metric(&rt->dst, RTAX_WINDOW); +#if !defined(CONFIG_BCM_MPTCP) || !defined(CONFIG_BCM_KF_MPTCP) tcp_select_initial_window(tcp_full_space(sk), req->mss, &req->rcv_wnd, &req->window_clamp, ireq->wscale_ok, &rcv_wscale, dst_metric(&rt->dst, RTAX_INITRWND)); +#else + tp->ops->select_initial_window(tcp_full_space(sk), req->mss, + &req->rcv_wnd, &req->window_clamp, + ireq->wscale_ok, &rcv_wscale, + dst_metric(&rt->dst, RTAX_INITRWND), sk); +#endif ireq->rcv_wscale = rcv_wscale; ireq->ecn_ok = cookie_ecn_ok(&tcp_opt, sock_net(sk), &rt->dst);