1 /* 2 * 3 * SNMP MIB entries for the IP subsystem. 4 * 5 * Alan Cox <gw4pts@gw4pts.ampr.org> 6 * 7 * We don't chose to implement SNMP in the kernel (this would 8 * be silly as SNMP is a pain in the backside in places). We do 9 * however need to collect the MIB statistics and export them 10 * out of /proc (eventually) 11 * 12 * This program is free software; you can redistribute it and/or 13 * modify it under the terms of the GNU General Public License 14 * as published by the Free Software Foundation; either version 15 * 2 of the License, or (at your option) any later version. 16 * 17 * $Id: snmp.h,v 1.19 2001/06/14 13:40:46 davem Exp $ 18 * 19 */ 20 21 #ifndef _SNMP_H 22 #define _SNMP_H 23 24 #include <linux/cache.h> 25 26 /* 27 * We use all unsigned longs. Linux will soon be so reliable that even these 28 * will rapidly get too small 8-). Seriously consider the IpInReceives count 29 * on the 20Gb/s + networks people expect in a few years time! 30 */ 31 32 /* 33 * The rule for padding: 34 * Best is power of two because then the right structure can be found by a simple 35 * shift. The structure should be always cache line aligned. 36 * gcc needs n=alignto(cachelinesize, popcnt(sizeof(bla_mib))) shift/add instructions 37 * to emulate multiply in case it is not power-of-two. Currently n is always <=3 for 38 * all sizes so simple cache line alignment is enough. 39 * 40 * The best solution would be a global CPU local area , especially on 64 and 128byte 41 * cacheline machine it makes a *lot* of sense -AK 42 */ 43 44 45 /* 46 * RFC 1213: MIB-II 47 * RFC 2011 (updates 1213): SNMPv2-MIB-IP 48 * RFC 2863: Interfaces Group MIB 49 */ 50 struct ip_mib 51 { 52 unsigned long IpInReceives; 53 unsigned long IpInHdrErrors; 54 unsigned long IpInAddrErrors; 55 unsigned long IpForwDatagrams; 56 unsigned long IpInUnknownProtos; 57 unsigned long IpInDiscards; 58 unsigned long IpInDelivers; 59 unsigned long IpOutRequests; 60 unsigned long IpOutDiscards; 61 unsigned long IpOutNoRoutes; 62 unsigned long IpReasmTimeout; 63 unsigned long IpReasmReqds; 64 unsigned long IpReasmOKs; 65 unsigned long IpReasmFails; 66 unsigned long IpFragOKs; 67 unsigned long IpFragFails; 68 unsigned long IpFragCreates; 69 unsigned long __pad[0]; 70 } ____cacheline_aligned; 71 72 /* 73 * RFC 2465: IPv6 MIB: General Group 74 */ 75 struct ipv6_mib 76 { 77 unsigned long Ip6InReceives; 78 unsigned long Ip6InHdrErrors; 79 unsigned long Ip6InTooBigErrors; 80 unsigned long Ip6InNoRoutes; 81 unsigned long Ip6InAddrErrors; 82 unsigned long Ip6InUnknownProtos; 83 unsigned long Ip6InTruncatedPkts; 84 unsigned long Ip6InDiscards; 85 unsigned long Ip6InDelivers; 86 unsigned long Ip6OutForwDatagrams; 87 unsigned long Ip6OutRequests; 88 unsigned long Ip6OutDiscards; 89 unsigned long Ip6OutNoRoutes; 90 unsigned long Ip6ReasmTimeout; 91 unsigned long Ip6ReasmReqds; 92 unsigned long Ip6ReasmOKs; 93 unsigned long Ip6ReasmFails; 94 unsigned long Ip6FragOKs; 95 unsigned long Ip6FragFails; 96 unsigned long Ip6FragCreates; 97 unsigned long Ip6InMcastPkts; 98 unsigned long Ip6OutMcastPkts; 99 unsigned long __pad[0]; 100 } ____cacheline_aligned; 101 102 /* 103 * RFC 1213: MIB-II ICMP Group 104 * RFC 2011 (updates 1213): SNMPv2 MIB for IP: ICMP group 105 */ 106 struct icmp_mib 107 { 108 unsigned long IcmpInMsgs; 109 unsigned long IcmpInErrors; 110 unsigned long IcmpInDestUnreachs; 111 unsigned long IcmpInTimeExcds; 112 unsigned long IcmpInParmProbs; 113 unsigned long IcmpInSrcQuenchs; 114 unsigned long IcmpInRedirects; 115 unsigned long IcmpInEchos; 116 unsigned long IcmpInEchoReps; 117 unsigned long IcmpInTimestamps; 118 unsigned long IcmpInTimestampReps; 119 unsigned long IcmpInAddrMasks; 120 unsigned long IcmpInAddrMaskReps; 121 unsigned long IcmpOutMsgs; 122 unsigned long IcmpOutErrors; 123 unsigned long IcmpOutDestUnreachs; 124 unsigned long IcmpOutTimeExcds; 125 unsigned long IcmpOutParmProbs; 126 unsigned long IcmpOutSrcQuenchs; 127 unsigned long IcmpOutRedirects; 128 unsigned long IcmpOutEchos; 129 unsigned long IcmpOutEchoReps; 130 unsigned long IcmpOutTimestamps; 131 unsigned long IcmpOutTimestampReps; 132 unsigned long IcmpOutAddrMasks; 133 unsigned long IcmpOutAddrMaskReps; 134 unsigned long dummy; 135 unsigned long __pad[0]; 136 } ____cacheline_aligned; 137 138 /* 139 * RFC 2466: ICMPv6-MIB 140 */ 141 struct icmpv6_mib 142 { 143 unsigned long Icmp6InMsgs; 144 unsigned long Icmp6InErrors; 145 146 unsigned long Icmp6InDestUnreachs; 147 unsigned long Icmp6InPktTooBigs; 148 unsigned long Icmp6InTimeExcds; 149 unsigned long Icmp6InParmProblems; 150 151 unsigned long Icmp6InEchos; 152 unsigned long Icmp6InEchoReplies; 153 unsigned long Icmp6InGroupMembQueries; 154 unsigned long Icmp6InGroupMembResponses; 155 unsigned long Icmp6InGroupMembReductions; 156 unsigned long Icmp6InRouterSolicits; 157 unsigned long Icmp6InRouterAdvertisements; 158 unsigned long Icmp6InNeighborSolicits; 159 unsigned long Icmp6InNeighborAdvertisements; 160 unsigned long Icmp6InRedirects; 161 162 unsigned long Icmp6OutMsgs; 163 164 unsigned long Icmp6OutDestUnreachs; 165 unsigned long Icmp6OutPktTooBigs; 166 unsigned long Icmp6OutTimeExcds; 167 unsigned long Icmp6OutParmProblems; 168 169 unsigned long Icmp6OutEchoReplies; 170 unsigned long Icmp6OutRouterSolicits; 171 unsigned long Icmp6OutNeighborSolicits; 172 unsigned long Icmp6OutNeighborAdvertisements; 173 unsigned long Icmp6OutRedirects; 174 unsigned long Icmp6OutGroupMembResponses; 175 unsigned long Icmp6OutGroupMembReductions; 176 unsigned long __pad[0]; 177 } ____cacheline_aligned; 178 179 /* 180 * RFC 1213: MIB-II TCP group 181 * RFC 2012 (updates 1213): SNMPv2-MIB-TCP 182 */ 183 struct tcp_mib 184 { 185 unsigned long TcpRtoAlgorithm; 186 unsigned long TcpRtoMin; 187 unsigned long TcpRtoMax; 188 unsigned long TcpMaxConn; 189 unsigned long TcpActiveOpens; 190 unsigned long TcpPassiveOpens; 191 unsigned long TcpAttemptFails; 192 unsigned long TcpEstabResets; 193 unsigned long TcpCurrEstab; 194 unsigned long TcpInSegs; 195 unsigned long TcpOutSegs; 196 unsigned long TcpRetransSegs; 197 unsigned long TcpInErrs; 198 unsigned long TcpOutRsts; 199 unsigned long __pad[0]; 200 } ____cacheline_aligned; 201 202 /* 203 * RFC 1213: MIB-II UDP group 204 * RFC 2013 (updates 1213): SNMPv2-MIB-UDP 205 */ 206 struct udp_mib 207 { 208 unsigned long UdpInDatagrams; 209 unsigned long UdpNoPorts; 210 unsigned long UdpInErrors; 211 unsigned long UdpOutDatagrams; 212 unsigned long __pad[0]; 213 } ____cacheline_aligned; 214 215 /* draft-ietf-sigtran-sctp-mib-07.txt */ 216 struct sctp_mib 217 { 218 unsigned long SctpCurrEstab; 219 unsigned long SctpActiveEstabs; 220 unsigned long SctpPassiveEstabs; 221 unsigned long SctpAborteds; 222 unsigned long SctpShutdowns; 223 unsigned long SctpOutOfBlues; 224 unsigned long SctpChecksumErrors; 225 unsigned long SctpOutCtrlChunks; 226 unsigned long SctpOutOrderChunks; 227 unsigned long SctpOutUnorderChunks; 228 unsigned long SctpInCtrlChunks; 229 unsigned long SctpInOrderChunks; 230 unsigned long SctpInUnorderChunks; 231 unsigned long SctpFragUsrMsgs; 232 unsigned long SctpReasmUsrMsgs; 233 unsigned long SctpOutSCTPPacks; 234 unsigned long SctpInSCTPPacks; 235 unsigned long SctpRtoAlgorithm; 236 unsigned long SctpRtoMin; 237 unsigned long SctpRtoMax; 238 unsigned long SctpRtoInitial; 239 unsigned long SctpValCookieLife; 240 unsigned long SctpMaxInitRetr; 241 unsigned long __pad[0]; 242 }; 243 244 struct linux_mib 245 { 246 unsigned long SyncookiesSent; 247 unsigned long SyncookiesRecv; 248 unsigned long SyncookiesFailed; 249 unsigned long EmbryonicRsts; 250 unsigned long PruneCalled; 251 unsigned long RcvPruned; 252 unsigned long OfoPruned; 253 unsigned long OutOfWindowIcmps; 254 unsigned long LockDroppedIcmps; 255 unsigned long ArpFilter; 256 unsigned long TimeWaited; 257 unsigned long TimeWaitRecycled; 258 unsigned long TimeWaitKilled; 259 unsigned long PAWSPassiveRejected; 260 unsigned long PAWSActiveRejected; 261 unsigned long PAWSEstabRejected; 262 unsigned long DelayedACKs; 263 unsigned long DelayedACKLocked; 264 unsigned long DelayedACKLost; 265 unsigned long ListenOverflows; 266 unsigned long ListenDrops; 267 unsigned long TCPPrequeued; 268 unsigned long TCPDirectCopyFromBacklog; 269 unsigned long TCPDirectCopyFromPrequeue; 270 unsigned long TCPPrequeueDropped; 271 unsigned long TCPHPHits; 272 unsigned long TCPHPHitsToUser; 273 unsigned long TCPPureAcks; 274 unsigned long TCPHPAcks; 275 unsigned long TCPRenoRecovery; 276 unsigned long TCPSackRecovery; 277 unsigned long TCPSACKReneging; 278 unsigned long TCPFACKReorder; 279 unsigned long TCPSACKReorder; 280 unsigned long TCPRenoReorder; 281 unsigned long TCPTSReorder; 282 unsigned long TCPFullUndo; 283 unsigned long TCPPartialUndo; 284 unsigned long TCPDSACKUndo; 285 unsigned long TCPLossUndo; 286 unsigned long TCPLoss; 287 unsigned long TCPLostRetransmit; 288 unsigned long TCPRenoFailures; 289 unsigned long TCPSackFailures; 290 unsigned long TCPLossFailures; 291 unsigned long TCPFastRetrans; 292 unsigned long TCPForwardRetrans; 293 unsigned long TCPSlowStartRetrans; 294 unsigned long TCPTimeouts; 295 unsigned long TCPRenoRecoveryFail; 296 unsigned long TCPSackRecoveryFail; 297 unsigned long TCPSchedulerFailed; 298 unsigned long TCPRcvCollapsed; 299 unsigned long TCPDSACKOldSent; 300 unsigned long TCPDSACKOfoSent; 301 unsigned long TCPDSACKRecv; 302 unsigned long TCPDSACKOfoRecv; 303 unsigned long TCPAbortOnSyn; 304 unsigned long TCPAbortOnData; 305 unsigned long TCPAbortOnClose; 306 unsigned long TCPAbortOnMemory; 307 unsigned long TCPAbortOnTimeout; 308 unsigned long TCPAbortOnLinger; 309 unsigned long TCPAbortFailed; 310 unsigned long TCPMemoryPressures; 311 unsigned long __pad[0]; 312 } ____cacheline_aligned; 313 314 315 /* 316 * FIXME: On x86 and some other CPUs the split into user and softirq parts is not needed because 317 * addl $1,memory is atomic against interrupts (but atomic_inc would be overkill because of the lock 318 * cycles). Wants new nonlocked_atomic_inc() primitives -AK 319 */ 320 #define SNMP_INC_STATS(mib, field) ((mib)[2*smp_processor_id()+!in_softirq()].field++) 321 #define SNMP_INC_STATS_BH(mib, field) ((mib)[2*smp_processor_id()].field++) 322 #define SNMP_INC_STATS_USER(mib, field) ((mib)[2*smp_processor_id()+1].field++) 323 #define SNMP_ADD_STATS_BH(mib, field, addend) \ 324 ((mib)[2*smp_processor_id()].field += addend) 325 #define SNMP_ADD_STATS_USER(mib, field, addend) \ 326 ((mib)[2*smp_processor_id()+1].field += addend) 327 #endif 328