-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mptcp: add and use MIB counter infrastructure
Exported via same /proc file as the Linux TCP MIB counters, so "netstat -s" or "nstat" will show them automatically. The MPTCP MIB counters are allocated in a distinct pcpu area in order to avoid bloating/wasting TCP pcpu memory. Counters are allocated once the first MPTCP socket is created in a network namespace and free'd on exit. If no sockets have been allocated, all-zero mptcp counters are shown. The MIB counter list is taken from the multipath-tcp.org kernel, but only a few counters have been picked up so far. The counter list can be increased at any time later on. v2 -> v3: - remove 'inline' in foo.c files (David S. Miller) Co-developed-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: Florian Westphal <fw@strlen.de> Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
- Loading branch information
Showing
9 changed files
with
172 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# SPDX-License-Identifier: GPL-2.0 | ||
obj-$(CONFIG_MPTCP) += mptcp.o | ||
|
||
mptcp-y := protocol.o subflow.o options.o token.o crypto.o ctrl.o pm.o diag.o | ||
mptcp-y := protocol.o subflow.o options.o token.o crypto.o ctrl.o pm.o diag.o mib.o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
|
||
#include <linux/seq_file.h> | ||
#include <net/ip.h> | ||
#include <net/mptcp.h> | ||
#include <net/snmp.h> | ||
#include <net/net_namespace.h> | ||
|
||
#include "mib.h" | ||
|
||
static const struct snmp_mib mptcp_snmp_list[] = { | ||
SNMP_MIB_ITEM("MPCapableSYNRX", MPTCP_MIB_MPCAPABLEPASSIVE), | ||
SNMP_MIB_ITEM("MPCapableACKRX", MPTCP_MIB_MPCAPABLEPASSIVEACK), | ||
SNMP_MIB_ITEM("MPCapableFallbackACK", MPTCP_MIB_MPCAPABLEPASSIVEFALLBACK), | ||
SNMP_MIB_ITEM("MPCapableFallbackSYNACK", MPTCP_MIB_MPCAPABLEACTIVEFALLBACK), | ||
SNMP_MIB_ITEM("MPTCPRetrans", MPTCP_MIB_RETRANSSEGS), | ||
SNMP_MIB_ITEM("MPJoinNoTokenFound", MPTCP_MIB_JOINNOTOKEN), | ||
SNMP_MIB_ITEM("MPJoinSynRx", MPTCP_MIB_JOINSYNRX), | ||
SNMP_MIB_ITEM("MPJoinSynAckRx", MPTCP_MIB_JOINSYNACKRX), | ||
SNMP_MIB_ITEM("MPJoinSynAckHMacFailure", MPTCP_MIB_JOINSYNACKMAC), | ||
SNMP_MIB_ITEM("MPJoinAckRx", MPTCP_MIB_JOINACKRX), | ||
SNMP_MIB_ITEM("MPJoinAckHMacFailure", MPTCP_MIB_JOINACKMAC), | ||
SNMP_MIB_ITEM("DSSNotMatching", MPTCP_MIB_DSSNOMATCH), | ||
SNMP_MIB_ITEM("InfiniteMapRx", MPTCP_MIB_INFINITEMAPRX), | ||
SNMP_MIB_SENTINEL | ||
}; | ||
|
||
/* mptcp_mib_alloc - allocate percpu mib counters | ||
* | ||
* These are allocated when the first mptcp socket is created so | ||
* we do not waste percpu memory if mptcp isn't in use. | ||
*/ | ||
bool mptcp_mib_alloc(struct net *net) | ||
{ | ||
struct mptcp_mib __percpu *mib = alloc_percpu(struct mptcp_mib); | ||
|
||
if (!mib) | ||
return false; | ||
|
||
if (cmpxchg(&net->mib.mptcp_statistics, NULL, mib)) | ||
free_percpu(mib); | ||
|
||
return true; | ||
} | ||
|
||
void mptcp_seq_show(struct seq_file *seq) | ||
{ | ||
struct net *net = seq->private; | ||
int i; | ||
|
||
seq_puts(seq, "MPTcpExt:"); | ||
for (i = 0; mptcp_snmp_list[i].name; i++) | ||
seq_printf(seq, " %s", mptcp_snmp_list[i].name); | ||
|
||
seq_puts(seq, "\nMPTcpExt:"); | ||
|
||
if (!net->mib.mptcp_statistics) { | ||
for (i = 0; mptcp_snmp_list[i].name; i++) | ||
seq_puts(seq, " 0"); | ||
|
||
return; | ||
} | ||
|
||
for (i = 0; mptcp_snmp_list[i].name; i++) | ||
seq_printf(seq, " %lu", | ||
snmp_fold_field(net->mib.mptcp_statistics, | ||
mptcp_snmp_list[i].entry)); | ||
seq_putc(seq, '\n'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* SPDX-License-Identifier: GPL-2.0-or-later */ | ||
|
||
enum linux_mptcp_mib_field { | ||
MPTCP_MIB_NUM = 0, | ||
MPTCP_MIB_MPCAPABLEPASSIVE, /* Received SYN with MP_CAPABLE */ | ||
MPTCP_MIB_MPCAPABLEPASSIVEACK, /* Received third ACK with MP_CAPABLE */ | ||
MPTCP_MIB_MPCAPABLEPASSIVEFALLBACK,/* Server-side fallback during 3-way handshake */ | ||
MPTCP_MIB_MPCAPABLEACTIVEFALLBACK, /* Client-side fallback during 3-way handshake */ | ||
MPTCP_MIB_RETRANSSEGS, /* Segments retransmitted at the MPTCP-level */ | ||
MPTCP_MIB_JOINNOTOKEN, /* Received MP_JOIN but the token was not found */ | ||
MPTCP_MIB_JOINSYNRX, /* Received a SYN + MP_JOIN */ | ||
MPTCP_MIB_JOINSYNACKRX, /* Received a SYN/ACK + MP_JOIN */ | ||
MPTCP_MIB_JOINSYNACKMAC, /* HMAC was wrong on SYN/ACK + MP_JOIN */ | ||
MPTCP_MIB_JOINACKRX, /* Received an ACK + MP_JOIN */ | ||
MPTCP_MIB_JOINACKMAC, /* HMAC was wrong on ACK + MP_JOIN */ | ||
MPTCP_MIB_DSSNOMATCH, /* Received a new mapping that did not match the previous one */ | ||
MPTCP_MIB_INFINITEMAPRX, /* Received an infinite mapping */ | ||
__MPTCP_MIB_MAX | ||
}; | ||
|
||
#define LINUX_MIB_MPTCP_MAX __MPTCP_MIB_MAX | ||
struct mptcp_mib { | ||
unsigned long mibs[LINUX_MIB_MPTCP_MAX]; | ||
}; | ||
|
||
static inline void MPTCP_INC_STATS(struct net *net, | ||
enum linux_mptcp_mib_field field) | ||
{ | ||
if (likely(net->mib.mptcp_statistics)) | ||
SNMP_INC_STATS(net->mib.mptcp_statistics, field); | ||
} | ||
|
||
static inline void __MPTCP_INC_STATS(struct net *net, | ||
enum linux_mptcp_mib_field field) | ||
{ | ||
if (likely(net->mib.mptcp_statistics)) | ||
__SNMP_INC_STATS(net->mib.mptcp_statistics, field); | ||
} | ||
|
||
bool mptcp_mib_alloc(struct net *net); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters