1 // SPDX-License-Identifier: GPL-2.0-or-later
3 #include <linux/seq_file.h>
7 #include <net/net_namespace.h>
11 static const struct snmp_mib mptcp_snmp_list
[] = {
12 SNMP_MIB_ITEM("MPCapableSYNRX", MPTCP_MIB_MPCAPABLEPASSIVE
),
13 SNMP_MIB_ITEM("MPCapableACKRX", MPTCP_MIB_MPCAPABLEPASSIVEACK
),
14 SNMP_MIB_ITEM("MPCapableFallbackACK", MPTCP_MIB_MPCAPABLEPASSIVEFALLBACK
),
15 SNMP_MIB_ITEM("MPCapableFallbackSYNACK", MPTCP_MIB_MPCAPABLEACTIVEFALLBACK
),
16 SNMP_MIB_ITEM("MPTCPRetrans", MPTCP_MIB_RETRANSSEGS
),
17 SNMP_MIB_ITEM("MPJoinNoTokenFound", MPTCP_MIB_JOINNOTOKEN
),
18 SNMP_MIB_ITEM("MPJoinSynRx", MPTCP_MIB_JOINSYNRX
),
19 SNMP_MIB_ITEM("MPJoinSynAckRx", MPTCP_MIB_JOINSYNACKRX
),
20 SNMP_MIB_ITEM("MPJoinSynAckHMacFailure", MPTCP_MIB_JOINSYNACKMAC
),
21 SNMP_MIB_ITEM("MPJoinAckRx", MPTCP_MIB_JOINACKRX
),
22 SNMP_MIB_ITEM("MPJoinAckHMacFailure", MPTCP_MIB_JOINACKMAC
),
23 SNMP_MIB_ITEM("DSSNotMatching", MPTCP_MIB_DSSNOMATCH
),
24 SNMP_MIB_ITEM("InfiniteMapRx", MPTCP_MIB_INFINITEMAPRX
),
25 SNMP_MIB_ITEM("OFOQueueTail", MPTCP_MIB_OFOQUEUETAIL
),
26 SNMP_MIB_ITEM("OFOQueue", MPTCP_MIB_OFOQUEUE
),
27 SNMP_MIB_ITEM("OFOMerge", MPTCP_MIB_OFOMERGE
),
28 SNMP_MIB_ITEM("NoDSSInWindow", MPTCP_MIB_NODSSWINDOW
),
29 SNMP_MIB_ITEM("DuplicateData", MPTCP_MIB_DUPDATA
),
30 SNMP_MIB_ITEM("AddAddr", MPTCP_MIB_ADDADDR
),
31 SNMP_MIB_ITEM("EchoAdd", MPTCP_MIB_ECHOADD
),
32 SNMP_MIB_ITEM("RmAddr", MPTCP_MIB_RMADDR
),
33 SNMP_MIB_ITEM("RmSubflow", MPTCP_MIB_RMSUBFLOW
),
37 /* mptcp_mib_alloc - allocate percpu mib counters
39 * These are allocated when the first mptcp socket is created so
40 * we do not waste percpu memory if mptcp isn't in use.
42 bool mptcp_mib_alloc(struct net
*net
)
44 struct mptcp_mib __percpu
*mib
= alloc_percpu(struct mptcp_mib
);
49 if (cmpxchg(&net
->mib
.mptcp_statistics
, NULL
, mib
))
55 void mptcp_seq_show(struct seq_file
*seq
)
57 struct net
*net
= seq
->private;
60 seq_puts(seq
, "MPTcpExt:");
61 for (i
= 0; mptcp_snmp_list
[i
].name
; i
++)
62 seq_printf(seq
, " %s", mptcp_snmp_list
[i
].name
);
64 seq_puts(seq
, "\nMPTcpExt:");
66 if (!net
->mib
.mptcp_statistics
) {
67 for (i
= 0; mptcp_snmp_list
[i
].name
; i
++)
74 for (i
= 0; mptcp_snmp_list
[i
].name
; i
++)
75 seq_printf(seq
, " %lu",
76 snmp_fold_field(net
->mib
.mptcp_statistics
,
77 mptcp_snmp_list
[i
].entry
));