Skip to content

Commit

Permalink
mptcp: add sk parameter for mptcp_parse_option
Browse files Browse the repository at this point in the history
This patch added a new parameter name sk in mptcp_parse_option() and
mptcp_get_options().

Acked-by: Paolo Abeni <[email protected]>
Reviewed-by: Mat Martineau <[email protected]>
Signed-off-by: Geliang Tang <[email protected]>
  • Loading branch information
geliangtang authored and matttbe committed May 6, 2021
1 parent 1a99353 commit f343075
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
10 changes: 6 additions & 4 deletions net/mptcp/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ static bool mptcp_cap_flag_sha256(u8 flags)
return (flags & MPTCP_CAP_FLAG_MASK) == MPTCP_CAP_HMAC_SHA256;
}

static void mptcp_parse_option(const struct sk_buff *skb,
static void mptcp_parse_option(const struct sock *sk,
const struct sk_buff *skb,
const unsigned char *ptr, int opsize,
struct mptcp_options_received *mp_opt)
{
Expand Down Expand Up @@ -324,7 +325,8 @@ static void mptcp_parse_option(const struct sk_buff *skb,
}
}

void mptcp_get_options(const struct sk_buff *skb,
void mptcp_get_options(const struct sock *sk,
const struct sk_buff *skb,
struct mptcp_options_received *mp_opt)
{
const struct tcphdr *th = tcp_hdr(skb);
Expand Down Expand Up @@ -363,7 +365,7 @@ void mptcp_get_options(const struct sk_buff *skb,
if (opsize > length)
return; /* don't parse partial options */
if (opcode == TCPOPT_MPTCP)
mptcp_parse_option(skb, ptr, opsize, mp_opt);
mptcp_parse_option(sk, skb, ptr, opsize, mp_opt);
ptr += opsize - 2;
length -= opsize;
}
Expand Down Expand Up @@ -1028,7 +1030,7 @@ void mptcp_incoming_options(struct sock *sk, struct sk_buff *skb)
return;
}

mptcp_get_options(skb, &mp_opt);
mptcp_get_options(sk, skb, &mp_opt);
if (!check_fully_established(msk, sk, subflow, skb, &mp_opt))
return;

Expand Down
3 changes: 2 additions & 1 deletion net/mptcp/protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,8 @@ int __init mptcp_proto_v6_init(void);
struct sock *mptcp_sk_clone(const struct sock *sk,
const struct mptcp_options_received *mp_opt,
struct request_sock *req);
void mptcp_get_options(const struct sk_buff *skb,
void mptcp_get_options(const struct sock *sk,
const struct sk_buff *skb,
struct mptcp_options_received *mp_opt);

void mptcp_finish_connect(struct sock *sk);
Expand Down
10 changes: 5 additions & 5 deletions net/mptcp/subflow.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ static int subflow_check_req(struct request_sock *req,
return -EINVAL;
#endif

mptcp_get_options(skb, &mp_opt);
mptcp_get_options(sk_listener, skb, &mp_opt);

if (mp_opt.mp_capable) {
SUBFLOW_REQ_INC_STATS(req, MPTCP_MIB_MPCAPABLEPASSIVE);
Expand Down Expand Up @@ -248,7 +248,7 @@ int mptcp_subflow_init_cookie_req(struct request_sock *req,
int err;

subflow_init_req(req, sk_listener);
mptcp_get_options(skb, &mp_opt);
mptcp_get_options(sk_listener, skb, &mp_opt);

if (mp_opt.mp_capable && mp_opt.mp_join)
return -EINVAL;
Expand Down Expand Up @@ -395,7 +395,7 @@ static void subflow_finish_connect(struct sock *sk, const struct sk_buff *skb)
subflow->ssn_offset = TCP_SKB_CB(skb)->seq;
pr_debug("subflow=%p synack seq=%x", subflow, subflow->ssn_offset);

mptcp_get_options(skb, &mp_opt);
mptcp_get_options(sk, skb, &mp_opt);
if (subflow->request_mptcp) {
if (!mp_opt.mp_capable) {
MPTCP_INC_STATS(sock_net(sk),
Expand Down Expand Up @@ -639,7 +639,7 @@ static struct sock *subflow_syn_recv_sock(const struct sock *sk,
goto create_msk;
}

mptcp_get_options(skb, &mp_opt);
mptcp_get_options(sk, skb, &mp_opt);
if (!mp_opt.mp_capable) {
fallback = true;
goto create_child;
Expand All @@ -650,7 +650,7 @@ static struct sock *subflow_syn_recv_sock(const struct sock *sk,
if (!new_msk)
fallback = true;
} else if (subflow_req->mp_join) {
mptcp_get_options(skb, &mp_opt);
mptcp_get_options(sk, skb, &mp_opt);
if (!mp_opt.mp_join || !subflow_hmac_valid(req, &mp_opt) ||
!mptcp_can_accept_new_subflow(subflow_req->msk)) {
SUBFLOW_REQ_INC_STATS(req, MPTCP_MIB_JOINACKMAC);
Expand Down

0 comments on commit f343075

Please sign in to comment.