2020-03-28 05:48:50 +08:00
|
|
|
// 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),
|
2021-04-02 07:19:42 +08:00
|
|
|
SNMP_MIB_ITEM("MPCapableSYNTX", MPTCP_MIB_MPCAPABLEACTIVE),
|
|
|
|
SNMP_MIB_ITEM("MPCapableSYNACKRX", MPTCP_MIB_MPCAPABLEACTIVEACK),
|
2020-03-28 05:48:50 +08:00
|
|
|
SNMP_MIB_ITEM("MPCapableACKRX", MPTCP_MIB_MPCAPABLEPASSIVEACK),
|
|
|
|
SNMP_MIB_ITEM("MPCapableFallbackACK", MPTCP_MIB_MPCAPABLEPASSIVEFALLBACK),
|
|
|
|
SNMP_MIB_ITEM("MPCapableFallbackSYNACK", MPTCP_MIB_MPCAPABLEACTIVEFALLBACK),
|
2021-04-02 07:19:41 +08:00
|
|
|
SNMP_MIB_ITEM("MPFallbackTokenInit", MPTCP_MIB_TOKENFALLBACKINIT),
|
2020-03-28 05:48:50 +08:00
|
|
|
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),
|
2021-06-22 06:54:37 +08:00
|
|
|
SNMP_MIB_ITEM("DSSNoMatchTCP", MPTCP_MIB_DSSTCPMISMATCH),
|
2021-06-18 07:46:18 +08:00
|
|
|
SNMP_MIB_ITEM("DataCsumErr", MPTCP_MIB_DATACSUMERR),
|
2020-09-14 16:01:14 +08:00
|
|
|
SNMP_MIB_ITEM("OFOQueueTail", MPTCP_MIB_OFOQUEUETAIL),
|
|
|
|
SNMP_MIB_ITEM("OFOQueue", MPTCP_MIB_OFOQUEUE),
|
|
|
|
SNMP_MIB_ITEM("OFOMerge", MPTCP_MIB_OFOMERGE),
|
|
|
|
SNMP_MIB_ITEM("NoDSSInWindow", MPTCP_MIB_NODSSWINDOW),
|
|
|
|
SNMP_MIB_ITEM("DuplicateData", MPTCP_MIB_DUPDATA),
|
2020-09-24 08:29:51 +08:00
|
|
|
SNMP_MIB_ITEM("AddAddr", MPTCP_MIB_ADDADDR),
|
|
|
|
SNMP_MIB_ITEM("EchoAdd", MPTCP_MIB_ECHOADD),
|
2021-02-02 07:09:19 +08:00
|
|
|
SNMP_MIB_ITEM("PortAdd", MPTCP_MIB_PORTADD),
|
|
|
|
SNMP_MIB_ITEM("MPJoinPortSynRx", MPTCP_MIB_JOINPORTSYNRX),
|
|
|
|
SNMP_MIB_ITEM("MPJoinPortSynAckRx", MPTCP_MIB_JOINPORTSYNACKRX),
|
|
|
|
SNMP_MIB_ITEM("MPJoinPortAckRx", MPTCP_MIB_JOINPORTACKRX),
|
|
|
|
SNMP_MIB_ITEM("MismatchPortSynRx", MPTCP_MIB_MISMATCHPORTSYNRX),
|
|
|
|
SNMP_MIB_ITEM("MismatchPortAckRx", MPTCP_MIB_MISMATCHPORTACKRX),
|
2020-09-24 08:29:56 +08:00
|
|
|
SNMP_MIB_ITEM("RmAddr", MPTCP_MIB_RMADDR),
|
|
|
|
SNMP_MIB_ITEM("RmSubflow", MPTCP_MIB_RMSUBFLOW),
|
2021-01-09 08:48:01 +08:00
|
|
|
SNMP_MIB_ITEM("MPPrioTx", MPTCP_MIB_MPPRIOTX),
|
|
|
|
SNMP_MIB_ITEM("MPPrioRx", MPTCP_MIB_MPPRIORX),
|
2021-07-10 08:20:51 +08:00
|
|
|
SNMP_MIB_ITEM("RcvPruned", MPTCP_MIB_RCVPRUNED),
|
2020-03-28 05:48:50 +08:00
|
|
|
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");
|
|
|
|
|
2020-12-05 15:56:33 +08:00
|
|
|
seq_putc(seq, '\n');
|
2020-03-28 05:48:50 +08:00
|
|
|
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');
|
|
|
|
}
|