Skip to content

Commit

Permalink
mptcp: increment MIB counters in a few places
Browse files Browse the repository at this point in the history
Add initial use of the new MIB counters.
We can extend this later on as more features get added.

Signed-off-by: Florian Westphal <fw@strlen.de>
  • Loading branch information
Florian Westphal authored and jenkins-tessares committed Oct 9, 2019
1 parent c0b997e commit 7c65aa5
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
12 changes: 11 additions & 1 deletion net/mptcp/protocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,7 @@ static enum mapping_status mptcp_get_mapping(struct sock *ssk)

if (mpext->data_len == 0) {
pr_err("Infinite mapping not handled");
MPTCP_INC_STATS(sock_net(ssk), MPTCP_MIB_INFINITEMAPRX);
ret = MAPPING_MISSING;
goto del_out;
} else if (mpext->subflow_seq == 0 &&
Expand All @@ -504,8 +505,10 @@ static enum mapping_status mptcp_get_mapping(struct sock *ssk)
*/
if (subflow->map_seq != map_seq ||
subflow->map_subflow_seq != mpext->subflow_seq ||
subflow->map_data_len != mpext->data_len)
subflow->map_data_len != mpext->data_len) {
MPTCP_INC_STATS(sock_net(ssk), MPTCP_MIB_DSSNOMATCH);
pr_warn("Replaced mapping before it was done");
}
}

subflow->map_seq = map_seq;
Expand Down Expand Up @@ -811,6 +814,7 @@ static void mptcp_retransmit(struct work_struct *work)
if (ret < 0)
break;

MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_RETRANSSEGS);
copied += ret;
dfrag->data_len -= ret;
}
Expand Down Expand Up @@ -992,6 +996,8 @@ static struct sock *mptcp_accept(struct sock *sk, int flags, int *err,
subflow->conn = new_mptcp_sock;
list_add(&subflow->node, &msk->conn_list);
bh_unlock_sock(new_mptcp_sock);

__MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_MPCAPABLEPASSIVEACK);
local_bh_enable();
inet_sk_state_store(newsk, TCP_ESTABLISHED);
release_sock(sk);
Expand All @@ -1000,6 +1006,8 @@ static struct sock *mptcp_accept(struct sock *sk, int flags, int *err,
tcp_sk(newsk)->is_mptcp = 0;
new_sock->sk = NULL;
sock_release(new_sock);

MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_MPCAPABLEPASSIVEFALLBACK);
}

return newsk;
Expand Down Expand Up @@ -1151,6 +1159,8 @@ void mptcp_finish_connect(struct sock *sk, int mp_capable)
msk->subflow = NULL;
bh_unlock_sock(sk);
local_bh_enable();
} else {
MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_MPCAPABLEACTIVEFALLBACK);
}
inet_sk_state_store(sk, TCP_ESTABLISHED);
}
Expand Down
21 changes: 17 additions & 4 deletions net/mptcp/subflow.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@
#include <net/tcp.h>
#include <net/mptcp.h>
#include "protocol.h"
#include "mib.h"

static inline void SUBFLOW_REQ_INC_STATS(struct request_sock *req,
enum linux_mptcp_mib_field field)
{
MPTCP_INC_STATS(sock_net(req_to_sk(req)), field);
}

static int subflow_rebuild_header(struct sock *sk)
{
Expand Down Expand Up @@ -62,8 +69,7 @@ static bool subflow_token_join_request(struct request_sock *req,

msk = mptcp_token_get_sock(subflow_req->token);
if (!msk) {
pr_debug("subflow_req=%p, token=%u - not found\n",
subflow_req, subflow_req->token);
SUBFLOW_REQ_INC_STATS(req, MPTCP_MIB_JOINNOTOKEN);
return false;
}

Expand Down Expand Up @@ -103,8 +109,14 @@ static void subflow_v4_init_req(struct request_sock *req,
subflow_req->mp_capable = 0;
subflow_req->mp_join = 0;

if (rx_opt.mptcp.mp_capable && rx_opt.mptcp.mp_join)
return;
if (rx_opt.mptcp.mp_capable) {
SUBFLOW_REQ_INC_STATS(req, MPTCP_MIB_MPCAPABLEPASSIVE);

if (rx_opt.mptcp.mp_join)
return;
} else if (rx_opt.mptcp.mp_join) {
SUBFLOW_REQ_INC_STATS(req, MPTCP_MIB_JOINSYNRX);
}

if (rx_opt.mptcp.mp_capable && listener->request_mptcp) {
int err;
Expand Down Expand Up @@ -177,6 +189,7 @@ static void subflow_finish_connect(struct sock *sk, const struct sk_buff *skb)
subflow, subflow->thmac,
subflow->remote_nonce);
if (!subflow_thmac_valid(subflow)) {
MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_JOINACKMAC);
subflow->mp_join = 0;
// @@ need to trigger RST
return;
Expand Down

0 comments on commit 7c65aa5

Please sign in to comment.