--- zzzz-none-000/linux-4.1.38/net/ipv6/syncookies.c 2017-01-18 18:48:06.000000000 +0000 +++ bcm63-7582-715/linux-4.1.38/net/ipv6/syncookies.c 2020-11-25 10:06:48.000000000 +0000 @@ -19,6 +19,10 @@ #include #include #include +#if defined(CONFIG_BCM_MPTCP) && defined(CONFIG_BCM_KF_MPTCP) +#include +#include +#endif #include #define COOKIEBITS 24 /* Upper bits store count */ @@ -47,8 +51,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); @@ -131,7 +157,12 @@ } EXPORT_SYMBOL_GPL(__cookie_v6_init_sequence); +#if !defined(CONFIG_BCM_MPTCP) || !defined(CONFIG_BCM_KF_MPTCP) __u32 cookie_v6_init_sequence(struct sock *sk, const struct sk_buff *skb, __u16 *mssp) +#else +__u32 cookie_v6_init_sequence(struct request_sock *req, 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); @@ -156,6 +187,9 @@ struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb) { 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 ipv6_pinfo *np = inet6_sk(sk); @@ -184,20 +218,46 @@ /* 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(&tcp6_request_sock_ops, sk); +#else +#ifdef CONFIG_MPTCP + if (mopt.saw_mpc) + req = inet_reqsk_alloc(&mptcp6_request_sock_ops, sk); + else +#endif + req = inet_reqsk_alloc(&tcp6_request_sock_ops, sk); +#endif if (!req) goto out; ireq = inet_rsk(req); +#if defined(CONFIG_BCM_MPTCP) && defined(CONFIG_BCM_KF_MPTCP) + ireq->mptcp_rqsk = 0; + ireq->saw_mpc = 0; +#endif treq = tcp_rsk(req); treq->tfo_listener = false; +#if defined(CONFIG_BCM_MPTCP) && defined(CONFIG_BCM_KF_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; @@ -256,10 +316,17 @@ } req->window_clamp = tp->window_clamp ? :dst_metric(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(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(dst, RTAX_INITRWND), sk); +#endif ireq->rcv_wscale = rcv_wscale; ireq->ecn_ok = cookie_ecn_ok(&tcp_opt, sock_net(sk), dst);