// SPDX-License-Identifier: GPL-2.0
/* Multipath TCP
*
* Copyright (c) 2021, Red Hat.
*/
#define pr_fmt(fmt) "MPTCP: " fmt
#include <linux/kernel.h>
#include <linux/module.h>
#include <net/sock.h>
#include <net/protocol.h>
#include <net/tcp.h>
#include <net/mptcp.h>
#include "protocol.h"
#define MIN_INFO_OPTLEN_SIZE 16
#define MIN_FULL_INFO_OPTLEN_SIZE 40
static struct sock *__mptcp_tcp_fallback(struct mptcp_sock *msk)
{
msk_owned_by_me(msk);
if (likely(!__mptcp_check_fallback(msk)))
return NULL;
return msk->first;
}
static u32 sockopt_seq_reset(const struct sock *sk)
{
sock_owned_by_me(sk);
/* Highbits contain state. Allows to distinguish sockopt_seq
* of listener and established:
* s0 = new_listener()
* sockopt(s0) - seq is 1
* s1 = accept(s0) - s1 inherits seq 1 if listener sk (s0)
* sockopt(s0) - seq increments to 2 on s0
* sockopt(s1) // seq increments to 2 on s1 (different option)
* new ssk completes join, inherits options from s0 // seq 2
* Needs sync from mptcp join logic, but ssk->seq == msk->seq
*
* Set High order bits to sk_state so ssk->seq == msk->seq test
* will fail.
*/
return (u32)sk->sk_state << 24u;
}
static void sockopt_seq_inc(struct