162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 262306a36Sopenharmony_ci 362306a36Sopenharmony_cienum linux_mptcp_mib_field { 462306a36Sopenharmony_ci MPTCP_MIB_NUM = 0, 562306a36Sopenharmony_ci MPTCP_MIB_MPCAPABLEPASSIVE, /* Received SYN with MP_CAPABLE */ 662306a36Sopenharmony_ci MPTCP_MIB_MPCAPABLEACTIVE, /* Sent SYN with MP_CAPABLE */ 762306a36Sopenharmony_ci MPTCP_MIB_MPCAPABLEACTIVEACK, /* Received SYN/ACK with MP_CAPABLE */ 862306a36Sopenharmony_ci MPTCP_MIB_MPCAPABLEPASSIVEACK, /* Received third ACK with MP_CAPABLE */ 962306a36Sopenharmony_ci MPTCP_MIB_MPCAPABLEPASSIVEFALLBACK,/* Server-side fallback during 3-way handshake */ 1062306a36Sopenharmony_ci MPTCP_MIB_MPCAPABLEACTIVEFALLBACK, /* Client-side fallback during 3-way handshake */ 1162306a36Sopenharmony_ci MPTCP_MIB_TOKENFALLBACKINIT, /* Could not init/allocate token */ 1262306a36Sopenharmony_ci MPTCP_MIB_RETRANSSEGS, /* Segments retransmitted at the MPTCP-level */ 1362306a36Sopenharmony_ci MPTCP_MIB_JOINNOTOKEN, /* Received MP_JOIN but the token was not found */ 1462306a36Sopenharmony_ci MPTCP_MIB_JOINSYNRX, /* Received a SYN + MP_JOIN */ 1562306a36Sopenharmony_ci MPTCP_MIB_JOINSYNACKRX, /* Received a SYN/ACK + MP_JOIN */ 1662306a36Sopenharmony_ci MPTCP_MIB_JOINSYNACKMAC, /* HMAC was wrong on SYN/ACK + MP_JOIN */ 1762306a36Sopenharmony_ci MPTCP_MIB_JOINACKRX, /* Received an ACK + MP_JOIN */ 1862306a36Sopenharmony_ci MPTCP_MIB_JOINACKMAC, /* HMAC was wrong on ACK + MP_JOIN */ 1962306a36Sopenharmony_ci MPTCP_MIB_DSSNOMATCH, /* Received a new mapping that did not match the previous one */ 2062306a36Sopenharmony_ci MPTCP_MIB_INFINITEMAPTX, /* Sent an infinite mapping */ 2162306a36Sopenharmony_ci MPTCP_MIB_INFINITEMAPRX, /* Received an infinite mapping */ 2262306a36Sopenharmony_ci MPTCP_MIB_DSSTCPMISMATCH, /* DSS-mapping did not map with TCP's sequence numbers */ 2362306a36Sopenharmony_ci MPTCP_MIB_DATACSUMERR, /* The data checksum fail */ 2462306a36Sopenharmony_ci MPTCP_MIB_OFOQUEUETAIL, /* Segments inserted into OoO queue tail */ 2562306a36Sopenharmony_ci MPTCP_MIB_OFOQUEUE, /* Segments inserted into OoO queue */ 2662306a36Sopenharmony_ci MPTCP_MIB_OFOMERGE, /* Segments merged in OoO queue */ 2762306a36Sopenharmony_ci MPTCP_MIB_NODSSWINDOW, /* Segments not in MPTCP windows */ 2862306a36Sopenharmony_ci MPTCP_MIB_DUPDATA, /* Segments discarded due to duplicate DSS */ 2962306a36Sopenharmony_ci MPTCP_MIB_ADDADDR, /* Received ADD_ADDR with echo-flag=0 */ 3062306a36Sopenharmony_ci MPTCP_MIB_ADDADDRTX, /* Sent ADD_ADDR with echo-flag=0 */ 3162306a36Sopenharmony_ci MPTCP_MIB_ADDADDRTXDROP, /* ADD_ADDR with echo-flag=0 not send due to 3262306a36Sopenharmony_ci * resource exhaustion 3362306a36Sopenharmony_ci */ 3462306a36Sopenharmony_ci MPTCP_MIB_ECHOADD, /* Received ADD_ADDR with echo-flag=1 */ 3562306a36Sopenharmony_ci MPTCP_MIB_ECHOADDTX, /* Send ADD_ADDR with echo-flag=1 */ 3662306a36Sopenharmony_ci MPTCP_MIB_ECHOADDTXDROP, /* ADD_ADDR with echo-flag=1 not send due 3762306a36Sopenharmony_ci * to resource exhaustion 3862306a36Sopenharmony_ci */ 3962306a36Sopenharmony_ci MPTCP_MIB_PORTADD, /* Received ADD_ADDR with a port-number */ 4062306a36Sopenharmony_ci MPTCP_MIB_ADDADDRDROP, /* Dropped incoming ADD_ADDR */ 4162306a36Sopenharmony_ci MPTCP_MIB_JOINPORTSYNRX, /* Received a SYN MP_JOIN with a different port-number */ 4262306a36Sopenharmony_ci MPTCP_MIB_JOINPORTSYNACKRX, /* Received a SYNACK MP_JOIN with a different port-number */ 4362306a36Sopenharmony_ci MPTCP_MIB_JOINPORTACKRX, /* Received an ACK MP_JOIN with a different port-number */ 4462306a36Sopenharmony_ci MPTCP_MIB_MISMATCHPORTSYNRX, /* Received a SYN MP_JOIN with a mismatched port-number */ 4562306a36Sopenharmony_ci MPTCP_MIB_MISMATCHPORTACKRX, /* Received an ACK MP_JOIN with a mismatched port-number */ 4662306a36Sopenharmony_ci MPTCP_MIB_RMADDR, /* Received RM_ADDR */ 4762306a36Sopenharmony_ci MPTCP_MIB_RMADDRDROP, /* Dropped incoming RM_ADDR */ 4862306a36Sopenharmony_ci MPTCP_MIB_RMADDRTX, /* Sent RM_ADDR */ 4962306a36Sopenharmony_ci MPTCP_MIB_RMADDRTXDROP, /* RM_ADDR not sent due to resource exhaustion */ 5062306a36Sopenharmony_ci MPTCP_MIB_RMSUBFLOW, /* Remove a subflow */ 5162306a36Sopenharmony_ci MPTCP_MIB_MPPRIOTX, /* Transmit a MP_PRIO */ 5262306a36Sopenharmony_ci MPTCP_MIB_MPPRIORX, /* Received a MP_PRIO */ 5362306a36Sopenharmony_ci MPTCP_MIB_MPFAILTX, /* Transmit a MP_FAIL */ 5462306a36Sopenharmony_ci MPTCP_MIB_MPFAILRX, /* Received a MP_FAIL */ 5562306a36Sopenharmony_ci MPTCP_MIB_MPFASTCLOSETX, /* Transmit a MP_FASTCLOSE */ 5662306a36Sopenharmony_ci MPTCP_MIB_MPFASTCLOSERX, /* Received a MP_FASTCLOSE */ 5762306a36Sopenharmony_ci MPTCP_MIB_MPRSTTX, /* Transmit a MP_RST */ 5862306a36Sopenharmony_ci MPTCP_MIB_MPRSTRX, /* Received a MP_RST */ 5962306a36Sopenharmony_ci MPTCP_MIB_RCVPRUNED, /* Incoming packet dropped due to memory limit */ 6062306a36Sopenharmony_ci MPTCP_MIB_SUBFLOWSTALE, /* Subflows entered 'stale' status */ 6162306a36Sopenharmony_ci MPTCP_MIB_SUBFLOWRECOVER, /* Subflows returned to active status after being stale */ 6262306a36Sopenharmony_ci MPTCP_MIB_SNDWNDSHARED, /* Subflow snd wnd is overridden by msk's one */ 6362306a36Sopenharmony_ci MPTCP_MIB_RCVWNDSHARED, /* Subflow rcv wnd is overridden by msk's one */ 6462306a36Sopenharmony_ci MPTCP_MIB_RCVWNDCONFLICTUPDATE, /* subflow rcv wnd is overridden by msk's one due to 6562306a36Sopenharmony_ci * conflict with another subflow while updating msk rcv wnd 6662306a36Sopenharmony_ci */ 6762306a36Sopenharmony_ci MPTCP_MIB_RCVWNDCONFLICT, /* Conflict with while updating msk rcv wnd */ 6862306a36Sopenharmony_ci MPTCP_MIB_CURRESTAB, /* Current established MPTCP connections */ 6962306a36Sopenharmony_ci __MPTCP_MIB_MAX 7062306a36Sopenharmony_ci}; 7162306a36Sopenharmony_ci 7262306a36Sopenharmony_ci#define LINUX_MIB_MPTCP_MAX __MPTCP_MIB_MAX 7362306a36Sopenharmony_cistruct mptcp_mib { 7462306a36Sopenharmony_ci unsigned long mibs[LINUX_MIB_MPTCP_MAX]; 7562306a36Sopenharmony_ci}; 7662306a36Sopenharmony_ci 7762306a36Sopenharmony_cistatic inline void MPTCP_ADD_STATS(struct net *net, 7862306a36Sopenharmony_ci enum linux_mptcp_mib_field field, 7962306a36Sopenharmony_ci int val) 8062306a36Sopenharmony_ci{ 8162306a36Sopenharmony_ci if (likely(net->mib.mptcp_statistics)) 8262306a36Sopenharmony_ci SNMP_ADD_STATS(net->mib.mptcp_statistics, field, val); 8362306a36Sopenharmony_ci} 8462306a36Sopenharmony_ci 8562306a36Sopenharmony_cistatic inline void MPTCP_INC_STATS(struct net *net, 8662306a36Sopenharmony_ci enum linux_mptcp_mib_field field) 8762306a36Sopenharmony_ci{ 8862306a36Sopenharmony_ci if (likely(net->mib.mptcp_statistics)) 8962306a36Sopenharmony_ci SNMP_INC_STATS(net->mib.mptcp_statistics, field); 9062306a36Sopenharmony_ci} 9162306a36Sopenharmony_ci 9262306a36Sopenharmony_cistatic inline void __MPTCP_INC_STATS(struct net *net, 9362306a36Sopenharmony_ci enum linux_mptcp_mib_field field) 9462306a36Sopenharmony_ci{ 9562306a36Sopenharmony_ci if (likely(net->mib.mptcp_statistics)) 9662306a36Sopenharmony_ci __SNMP_INC_STATS(net->mib.mptcp_statistics, field); 9762306a36Sopenharmony_ci} 9862306a36Sopenharmony_ci 9962306a36Sopenharmony_cistatic inline void MPTCP_DEC_STATS(struct net *net, 10062306a36Sopenharmony_ci enum linux_mptcp_mib_field field) 10162306a36Sopenharmony_ci{ 10262306a36Sopenharmony_ci if (likely(net->mib.mptcp_statistics)) 10362306a36Sopenharmony_ci SNMP_DEC_STATS(net->mib.mptcp_statistics, field); 10462306a36Sopenharmony_ci} 10562306a36Sopenharmony_ci 10662306a36Sopenharmony_cibool mptcp_mib_alloc(struct net *net); 107