/* SPDX-License-Identifier: GPL-2.0-or-later */12#include <net/inet_common.h>34enum linux_mptcp_mib_field {5MPTCP_MIB_NUM = 0,6MPTCP_MIB_MPCAPABLEPASSIVE, /* Received SYN with MP_CAPABLE */7MPTCP_MIB_MPCAPABLEACTIVE, /* Sent SYN with MP_CAPABLE */8MPTCP_MIB_MPCAPABLEACTIVEACK, /* Received SYN/ACK with MP_CAPABLE */9MPTCP_MIB_MPCAPABLEPASSIVEACK, /* Received third ACK with MP_CAPABLE */10MPTCP_MIB_MPCAPABLEPASSIVEFALLBACK,/* Server-side fallback during 3-way handshake */11MPTCP_MIB_MPCAPABLEACTIVEFALLBACK, /* Client-side fallback during 3-way handshake */12MPTCP_MIB_MPCAPABLEACTIVEDROP, /* Client-side fallback due to a MPC drop */13MPTCP_MIB_MPCAPABLEACTIVEDISABLED, /* Client-side disabled due to past issues */14MPTCP_MIB_MPCAPABLEENDPATTEMPT, /* Prohibited MPC to port-based endp */15MPTCP_MIB_TOKENFALLBACKINIT, /* Could not init/allocate token */16MPTCP_MIB_RETRANSSEGS, /* Segments retransmitted at the MPTCP-level */17MPTCP_MIB_JOINNOTOKEN, /* Received MP_JOIN but the token was not found */18MPTCP_MIB_JOINSYNRX, /* Received a SYN + MP_JOIN */19MPTCP_MIB_JOINSYNBACKUPRX, /* Received a SYN + MP_JOIN + backup flag */20MPTCP_MIB_JOINSYNACKRX, /* Received a SYN/ACK + MP_JOIN */21MPTCP_MIB_JOINSYNACKBACKUPRX, /* Received a SYN/ACK + MP_JOIN + backup flag */22MPTCP_MIB_JOINSYNACKMAC, /* HMAC was wrong on SYN/ACK + MP_JOIN */23MPTCP_MIB_JOINACKRX, /* Received an ACK + MP_JOIN */24MPTCP_MIB_JOINACKMAC, /* HMAC was wrong on ACK + MP_JOIN */25MPTCP_MIB_JOINREJECTED, /* The PM rejected the JOIN request */26MPTCP_MIB_JOINSYNTX, /* Sending a SYN + MP_JOIN */27MPTCP_MIB_JOINSYNTXCREATSKERR, /* Not able to create a socket when sending a SYN + MP_JOIN */28MPTCP_MIB_JOINSYNTXBINDERR, /* Not able to bind() the address when sending a SYN + MP_JOIN */29MPTCP_MIB_JOINSYNTXCONNECTERR, /* Not able to connect() when sending a SYN + MP_JOIN */30MPTCP_MIB_DSSNOMATCH, /* Received a new mapping that did not match the previous one */31MPTCP_MIB_DSSCORRUPTIONFALLBACK,/* DSS corruption detected, fallback */32MPTCP_MIB_DSSCORRUPTIONRESET, /* DSS corruption detected, MPJ subflow reset */33MPTCP_MIB_INFINITEMAPTX, /* Sent an infinite mapping */34MPTCP_MIB_INFINITEMAPRX, /* Received an infinite mapping */35MPTCP_MIB_DSSTCPMISMATCH, /* DSS-mapping did not map with TCP's sequence numbers */36MPTCP_MIB_DATACSUMERR, /* The data checksum fail */37MPTCP_MIB_OFOQUEUETAIL, /* Segments inserted into OoO queue tail */38MPTCP_MIB_OFOQUEUE, /* Segments inserted into OoO queue */39MPTCP_MIB_OFOMERGE, /* Segments merged in OoO queue */40MPTCP_MIB_NODSSWINDOW, /* Segments not in MPTCP windows */41MPTCP_MIB_DUPDATA, /* Segments discarded due to duplicate DSS */42MPTCP_MIB_ADDADDR, /* Received ADD_ADDR with echo-flag=0 */43MPTCP_MIB_ADDADDRTX, /* Sent ADD_ADDR with echo-flag=0 */44MPTCP_MIB_ADDADDRTXDROP, /* ADD_ADDR with echo-flag=0 not send due to45* resource exhaustion46*/47MPTCP_MIB_ECHOADD, /* Received ADD_ADDR with echo-flag=1 */48MPTCP_MIB_ECHOADDTX, /* Send ADD_ADDR with echo-flag=1 */49MPTCP_MIB_ECHOADDTXDROP, /* ADD_ADDR with echo-flag=1 not send due50* to resource exhaustion51*/52MPTCP_MIB_PORTADD, /* Received ADD_ADDR with a port-number */53MPTCP_MIB_ADDADDRDROP, /* Dropped incoming ADD_ADDR */54MPTCP_MIB_JOINPORTSYNRX, /* Received a SYN MP_JOIN with a different port-number */55MPTCP_MIB_JOINPORTSYNACKRX, /* Received a SYNACK MP_JOIN with a different port-number */56MPTCP_MIB_JOINPORTACKRX, /* Received an ACK MP_JOIN with a different port-number */57MPTCP_MIB_MISMATCHPORTSYNRX, /* Received a SYN MP_JOIN with a mismatched port-number */58MPTCP_MIB_MISMATCHPORTACKRX, /* Received an ACK MP_JOIN with a mismatched port-number */59MPTCP_MIB_RMADDR, /* Received RM_ADDR */60MPTCP_MIB_RMADDRDROP, /* Dropped incoming RM_ADDR */61MPTCP_MIB_RMADDRTX, /* Sent RM_ADDR */62MPTCP_MIB_RMADDRTXDROP, /* RM_ADDR not sent due to resource exhaustion */63MPTCP_MIB_RMSUBFLOW, /* Remove a subflow */64MPTCP_MIB_MPPRIOTX, /* Transmit a MP_PRIO */65MPTCP_MIB_MPPRIORX, /* Received a MP_PRIO */66MPTCP_MIB_MPFAILTX, /* Transmit a MP_FAIL */67MPTCP_MIB_MPFAILRX, /* Received a MP_FAIL */68MPTCP_MIB_MPFASTCLOSETX, /* Transmit a MP_FASTCLOSE */69MPTCP_MIB_MPFASTCLOSERX, /* Received a MP_FASTCLOSE */70MPTCP_MIB_MPRSTTX, /* Transmit a MP_RST */71MPTCP_MIB_MPRSTRX, /* Received a MP_RST */72MPTCP_MIB_RCVPRUNED, /* Incoming packet dropped due to memory limit */73MPTCP_MIB_SUBFLOWSTALE, /* Subflows entered 'stale' status */74MPTCP_MIB_SUBFLOWRECOVER, /* Subflows returned to active status after being stale */75MPTCP_MIB_SNDWNDSHARED, /* Subflow snd wnd is overridden by msk's one */76MPTCP_MIB_RCVWNDSHARED, /* Subflow rcv wnd is overridden by msk's one */77MPTCP_MIB_RCVWNDCONFLICTUPDATE, /* subflow rcv wnd is overridden by msk's one due to78* conflict with another subflow while updating msk rcv wnd79*/80MPTCP_MIB_RCVWNDCONFLICT, /* Conflict with while updating msk rcv wnd */81MPTCP_MIB_CURRESTAB, /* Current established MPTCP connections */82MPTCP_MIB_BLACKHOLE, /* A blackhole has been detected */83MPTCP_MIB_MPCAPABLEDATAFALLBACK, /* Missing DSS/MPC+data on first84* established packet85*/86MPTCP_MIB_MD5SIGFALLBACK, /* Conflicting TCP option enabled */87MPTCP_MIB_DSSFALLBACK, /* Bad or missing DSS */88MPTCP_MIB_SIMULTCONNFALLBACK, /* Simultaneous connect */89MPTCP_MIB_FALLBACKFAILED, /* Can't fallback due to msk status */90__MPTCP_MIB_MAX91};9293#define LINUX_MIB_MPTCP_MAX __MPTCP_MIB_MAX94struct mptcp_mib {95unsigned long mibs[LINUX_MIB_MPTCP_MAX];96};9798static inline void MPTCP_ADD_STATS(struct net *net,99enum linux_mptcp_mib_field field,100int val)101{102if (likely(net->mib.mptcp_statistics))103SNMP_ADD_STATS(net->mib.mptcp_statistics, field, val);104}105106static inline void MPTCP_INC_STATS(struct net *net,107enum linux_mptcp_mib_field field)108{109if (likely(net->mib.mptcp_statistics))110SNMP_INC_STATS(net->mib.mptcp_statistics, field);111}112113static inline void __MPTCP_INC_STATS(struct net *net,114enum linux_mptcp_mib_field field)115{116if (likely(net->mib.mptcp_statistics))117__SNMP_INC_STATS(net->mib.mptcp_statistics, field);118}119120static inline void MPTCP_DEC_STATS(struct net *net,121enum linux_mptcp_mib_field field)122{123if (likely(net->mib.mptcp_statistics))124SNMP_DEC_STATS(net->mib.mptcp_statistics, field);125}126127bool mptcp_mib_alloc(struct net *net);128129130