28450d2780
commit 4dde0d72ccec500c60c798e036b852e013d6e124 upstream. Without such counters, it is difficult to easily debug issues with MPJ not having the backup flags on production servers. This is not strictly a fix, but it eases to validate the following patches without requiring to take packet traces, to query ongoing connections with Netlink with admin permissions, or to guess by looking at the behaviour of the packet scheduler. Also, the modification is self contained, isolated, well controlled, and the increments are done just after others, there from the beginning. It looks then safe, and helpful to backport this. Fixes: 4596a2c1b7f5 ("mptcp: allow creating non-backup subflows") Cc: stable@vger.kernel.org Reviewed-by: Mat Martineau <martineau@kernel.org> Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org> Signed-off-by: Paolo Abeni <pabeni@redhat.com> [ Conflicts in subflow.c because the context has changed in commit b3ea6b272d79 ("mptcp: consolidate initial ack seq generation") and commit 5bc56388c74f ("mptcp: add port number check for MP_JOIN") which are not in this version. These commits are unrelated to this modification. ] Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
81 lines
2.5 KiB
C
Executable file
81 lines
2.5 KiB
C
Executable file
// 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("MPJoinSynBackupRx", MPTCP_MIB_JOINSYNBACKUPRX),
|
|
SNMP_MIB_ITEM("MPJoinSynAckRx", MPTCP_MIB_JOINSYNACKRX),
|
|
SNMP_MIB_ITEM("MPJoinSynAckBackupRx", MPTCP_MIB_JOINSYNACKBACKUPRX),
|
|
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_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),
|
|
SNMP_MIB_ITEM("AddAddr", MPTCP_MIB_ADDADDR),
|
|
SNMP_MIB_ITEM("EchoAdd", MPTCP_MIB_ECHOADD),
|
|
SNMP_MIB_ITEM("RmAddr", MPTCP_MIB_RMADDR),
|
|
SNMP_MIB_ITEM("RmSubflow", MPTCP_MIB_RMSUBFLOW),
|
|
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");
|
|
|
|
seq_putc(seq, '\n');
|
|
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');
|
|
}
|