1fc518953SFlorian Westphal /* SPDX-License-Identifier: GPL-2.0-or-later */
2fc518953SFlorian Westphal
3fc518953SFlorian Westphal enum linux_mptcp_mib_field {
4fc518953SFlorian Westphal MPTCP_MIB_NUM = 0,
5fc518953SFlorian Westphal MPTCP_MIB_MPCAPABLEPASSIVE, /* Received SYN with MP_CAPABLE */
65695eb88SPaolo Abeni MPTCP_MIB_MPCAPABLEACTIVE, /* Sent SYN with MP_CAPABLE */
75695eb88SPaolo Abeni MPTCP_MIB_MPCAPABLEACTIVEACK, /* Received SYN/ACK with MP_CAPABLE */
8fc518953SFlorian Westphal MPTCP_MIB_MPCAPABLEPASSIVEACK, /* Received third ACK with MP_CAPABLE */
9fc518953SFlorian Westphal MPTCP_MIB_MPCAPABLEPASSIVEFALLBACK,/* Server-side fallback during 3-way handshake */
10fc518953SFlorian Westphal MPTCP_MIB_MPCAPABLEACTIVEFALLBACK, /* Client-side fallback during 3-way handshake */
11*37d9305cSPaolo Abeni MPTCP_MIB_MPCAPABLEENDPATTEMPT, /* Prohibited MPC to port-based endp */
12a16195e3SPaolo Abeni MPTCP_MIB_TOKENFALLBACKINIT, /* Could not init/allocate token */
13fc518953SFlorian Westphal MPTCP_MIB_RETRANSSEGS, /* Segments retransmitted at the MPTCP-level */
14fc518953SFlorian Westphal MPTCP_MIB_JOINNOTOKEN, /* Received MP_JOIN but the token was not found */
15fc518953SFlorian Westphal MPTCP_MIB_JOINSYNRX, /* Received a SYN + MP_JOIN */
166721cbaaSMatthieu Baerts (NGI0) MPTCP_MIB_JOINSYNBACKUPRX, /* Received a SYN + MP_JOIN + backup flag */
17fc518953SFlorian Westphal MPTCP_MIB_JOINSYNACKRX, /* Received a SYN/ACK + MP_JOIN */
186721cbaaSMatthieu Baerts (NGI0) MPTCP_MIB_JOINSYNACKBACKUPRX, /* Received a SYN/ACK + MP_JOIN + backup flag */
19fc518953SFlorian Westphal MPTCP_MIB_JOINSYNACKMAC, /* HMAC was wrong on SYN/ACK + MP_JOIN */
20fc518953SFlorian Westphal MPTCP_MIB_JOINACKRX, /* Received an ACK + MP_JOIN */
21fc518953SFlorian Westphal MPTCP_MIB_JOINACKMAC, /* HMAC was wrong on ACK + MP_JOIN */
22fc518953SFlorian Westphal MPTCP_MIB_DSSNOMATCH, /* Received a new mapping that did not match the previous one */
23b8be15d1SPaolo Abeni MPTCP_MIB_DSSCORRUPTIONFALLBACK,/* DSS corruption detected, fallback */
24b8be15d1SPaolo Abeni MPTCP_MIB_DSSCORRUPTIONRESET, /* DSS corruption detected, MPJ subflow reset */
25104125b8SGeliang Tang MPTCP_MIB_INFINITEMAPTX, /* Sent an infinite mapping */
26fc518953SFlorian Westphal MPTCP_MIB_INFINITEMAPRX, /* Received an infinite mapping */
2706285da9SPaolo Abeni MPTCP_MIB_DSSTCPMISMATCH, /* DSS-mapping did not map with TCP's sequence numbers */
28fe3ab1cbSGeliang Tang MPTCP_MIB_DATACSUMERR, /* The data checksum fail */
2906242e44SPaolo Abeni MPTCP_MIB_OFOQUEUETAIL, /* Segments inserted into OoO queue tail */
3006242e44SPaolo Abeni MPTCP_MIB_OFOQUEUE, /* Segments inserted into OoO queue */
3106242e44SPaolo Abeni MPTCP_MIB_OFOMERGE, /* Segments merged in OoO queue */
3206242e44SPaolo Abeni MPTCP_MIB_NODSSWINDOW, /* Segments not in MPTCP windows */
3306242e44SPaolo Abeni MPTCP_MIB_DUPDATA, /* Segments discarded due to duplicate DSS */
34a877de06SGeliang Tang MPTCP_MIB_ADDADDR, /* Received ADD_ADDR with echo-flag=0 */
3545b1a122SPaolo Abeni MPTCP_MIB_ADDADDRTX, /* Sent ADD_ADDR with echo-flag=0 */
3645b1a122SPaolo Abeni MPTCP_MIB_ADDADDRTXDROP, /* ADD_ADDR with echo-flag=0 not send due to
3745b1a122SPaolo Abeni * resource exhaustion
3845b1a122SPaolo Abeni */
39a877de06SGeliang Tang MPTCP_MIB_ECHOADD, /* Received ADD_ADDR with echo-flag=1 */
4045b1a122SPaolo Abeni MPTCP_MIB_ECHOADDTX, /* Send ADD_ADDR with echo-flag=1 */
4145b1a122SPaolo Abeni MPTCP_MIB_ECHOADDTXDROP, /* ADD_ADDR with echo-flag=1 not send due
4245b1a122SPaolo Abeni * to resource exhaustion
4345b1a122SPaolo Abeni */
442fbdd9eaSGeliang Tang MPTCP_MIB_PORTADD, /* Received ADD_ADDR with a port-number */
45f73c1194SPaolo Abeni MPTCP_MIB_ADDADDRDROP, /* Dropped incoming ADD_ADDR */
462fbdd9eaSGeliang Tang MPTCP_MIB_JOINPORTSYNRX, /* Received a SYN MP_JOIN with a different port-number */
472fbdd9eaSGeliang Tang MPTCP_MIB_JOINPORTSYNACKRX, /* Received a SYNACK MP_JOIN with a different port-number */
482fbdd9eaSGeliang Tang MPTCP_MIB_JOINPORTACKRX, /* Received an ACK MP_JOIN with a different port-number */
492fbdd9eaSGeliang Tang MPTCP_MIB_MISMATCHPORTSYNRX, /* Received a SYN MP_JOIN with a mismatched port-number */
502fbdd9eaSGeliang Tang MPTCP_MIB_MISMATCHPORTACKRX, /* Received an ACK MP_JOIN with a mismatched port-number */
517a7e52e3SGeliang Tang MPTCP_MIB_RMADDR, /* Received RM_ADDR */
52f73c1194SPaolo Abeni MPTCP_MIB_RMADDRDROP, /* Dropped incoming RM_ADDR */
5345b1a122SPaolo Abeni MPTCP_MIB_RMADDRTX, /* Sent RM_ADDR */
5445b1a122SPaolo Abeni MPTCP_MIB_RMADDRTXDROP, /* RM_ADDR not sent due to resource exhaustion */
557a7e52e3SGeliang Tang MPTCP_MIB_RMSUBFLOW, /* Remove a subflow */
560be2ac28SGeliang Tang MPTCP_MIB_MPPRIOTX, /* Transmit a MP_PRIO */
570be2ac28SGeliang Tang MPTCP_MIB_MPPRIORX, /* Received a MP_PRIO */
58eb7f3365SGeliang Tang MPTCP_MIB_MPFAILTX, /* Transmit a MP_FAIL */
59eb7f3365SGeliang Tang MPTCP_MIB_MPFAILRX, /* Received a MP_FAIL */
601e75629cSGeliang Tang MPTCP_MIB_MPFASTCLOSETX, /* Transmit a MP_FASTCLOSE */
611e75629cSGeliang Tang MPTCP_MIB_MPFASTCLOSERX, /* Received a MP_FASTCLOSE */
62e40dd439SGeliang Tang MPTCP_MIB_MPRSTTX, /* Transmit a MP_RST */
63e40dd439SGeliang Tang MPTCP_MIB_MPRSTRX, /* Received a MP_RST */
64ce599c51SPaolo Abeni MPTCP_MIB_RCVPRUNED, /* Incoming packet dropped due to memory limit */
65fc1b4e3bSPaolo Abeni MPTCP_MIB_SUBFLOWSTALE, /* Subflows entered 'stale' status */
66fc1b4e3bSPaolo Abeni MPTCP_MIB_SUBFLOWRECOVER, /* Subflows returned to active status after being stale */
6792be2f52SPaolo Abeni MPTCP_MIB_SNDWNDSHARED, /* Subflow snd wnd is overridden by msk's one */
6838acb626SPaolo Abeni MPTCP_MIB_RCVWNDSHARED, /* Subflow rcv wnd is overridden by msk's one */
6938acb626SPaolo Abeni MPTCP_MIB_RCVWNDCONFLICTUPDATE, /* subflow rcv wnd is overridden by msk's one due to
7038acb626SPaolo Abeni * conflict with another subflow while updating msk rcv wnd
7138acb626SPaolo Abeni */
7238acb626SPaolo Abeni MPTCP_MIB_RCVWNDCONFLICT, /* Conflict with while updating msk rcv wnd */
7356557547SGeliang Tang MPTCP_MIB_CURRESTAB, /* Current established MPTCP connections */
74fc518953SFlorian Westphal __MPTCP_MIB_MAX
75fc518953SFlorian Westphal };
76fc518953SFlorian Westphal
77fc518953SFlorian Westphal #define LINUX_MIB_MPTCP_MAX __MPTCP_MIB_MAX
78fc518953SFlorian Westphal struct mptcp_mib {
79fc518953SFlorian Westphal unsigned long mibs[LINUX_MIB_MPTCP_MAX];
80fc518953SFlorian Westphal };
81fc518953SFlorian Westphal
MPTCP_ADD_STATS(struct net * net,enum linux_mptcp_mib_field field,int val)8245b1a122SPaolo Abeni static inline void MPTCP_ADD_STATS(struct net *net,
8345b1a122SPaolo Abeni enum linux_mptcp_mib_field field,
8445b1a122SPaolo Abeni int val)
8545b1a122SPaolo Abeni {
8645b1a122SPaolo Abeni if (likely(net->mib.mptcp_statistics))
8745b1a122SPaolo Abeni SNMP_ADD_STATS(net->mib.mptcp_statistics, field, val);
8845b1a122SPaolo Abeni }
8945b1a122SPaolo Abeni
MPTCP_INC_STATS(struct net * net,enum linux_mptcp_mib_field field)90fc518953SFlorian Westphal static inline void MPTCP_INC_STATS(struct net *net,
91fc518953SFlorian Westphal enum linux_mptcp_mib_field field)
92fc518953SFlorian Westphal {
93fc518953SFlorian Westphal if (likely(net->mib.mptcp_statistics))
94fc518953SFlorian Westphal SNMP_INC_STATS(net->mib.mptcp_statistics, field);
95fc518953SFlorian Westphal }
96fc518953SFlorian Westphal
__MPTCP_INC_STATS(struct net * net,enum linux_mptcp_mib_field field)97fc518953SFlorian Westphal static inline void __MPTCP_INC_STATS(struct net *net,
98fc518953SFlorian Westphal enum linux_mptcp_mib_field field)
99fc518953SFlorian Westphal {
100fc518953SFlorian Westphal if (likely(net->mib.mptcp_statistics))
101fc518953SFlorian Westphal __SNMP_INC_STATS(net->mib.mptcp_statistics, field);
102fc518953SFlorian Westphal }
103fc518953SFlorian Westphal
MPTCP_DEC_STATS(struct net * net,enum linux_mptcp_mib_field field)10456557547SGeliang Tang static inline void MPTCP_DEC_STATS(struct net *net,
10556557547SGeliang Tang enum linux_mptcp_mib_field field)
10656557547SGeliang Tang {
10756557547SGeliang Tang if (likely(net->mib.mptcp_statistics))
10856557547SGeliang Tang SNMP_DEC_STATS(net->mib.mptcp_statistics, field);
10956557547SGeliang Tang }
11056557547SGeliang Tang
111fc518953SFlorian Westphal bool mptcp_mib_alloc(struct net *net);
112