46
46
#include <net/sock.h>
47
47
#include <net/raw.h>
48
48
49
+ #define TCPUDP_MIB_MAX max_t(u32, UDP_MIB_MAX, TCP_MIB_MAX)
50
+
49
51
/*
50
52
* Report socket allocation statistics [[email protected] ]
51
53
*/
@@ -379,13 +381,15 @@ static void icmp_put(struct seq_file *seq)
379
381
/*
380
382
* Called from the PROCfs module. This outputs /proc/net/snmp.
381
383
*/
382
- static int snmp_seq_show (struct seq_file * seq , void * v )
384
+ static int snmp_seq_show_ipstats (struct seq_file * seq , void * v )
383
385
{
384
- int i ;
385
386
struct net * net = seq -> private ;
387
+ u64 buff64 [IPSTATS_MIB_MAX ];
388
+ int i ;
386
389
387
- seq_puts ( seq , "Ip: Forwarding DefaultTTL" );
390
+ memset ( buff64 , 0 , IPSTATS_MIB_MAX * sizeof ( u64 ) );
388
391
392
+ seq_puts (seq , "Ip: Forwarding DefaultTTL" );
389
393
for (i = 0 ; snmp4_ipstats_list [i ].name != NULL ; i ++ )
390
394
seq_printf (seq , " %s" , snmp4_ipstats_list [i ].name );
391
395
@@ -394,57 +398,77 @@ static int snmp_seq_show(struct seq_file *seq, void *v)
394
398
net -> ipv4 .sysctl_ip_default_ttl );
395
399
396
400
BUILD_BUG_ON (offsetof(struct ipstats_mib , mibs ) != 0 );
401
+ snmp_get_cpu_field64_batch (buff64 , snmp4_ipstats_list ,
402
+ net -> mib .ip_statistics ,
403
+ offsetof(struct ipstats_mib , syncp ));
397
404
for (i = 0 ; snmp4_ipstats_list [i ].name != NULL ; i ++ )
398
- seq_printf (seq , " %llu" ,
399
- snmp_fold_field64 (net -> mib .ip_statistics ,
400
- snmp4_ipstats_list [i ].entry ,
401
- offsetof(struct ipstats_mib , syncp )));
405
+ seq_printf (seq , " %llu" , buff64 [i ]);
402
406
403
- icmp_put (seq ); /* RFC 2011 compatibility */
404
- icmpmsg_put (seq );
407
+ return 0 ;
408
+ }
409
+
410
+ static int snmp_seq_show_tcp_udp (struct seq_file * seq , void * v )
411
+ {
412
+ unsigned long buff [TCPUDP_MIB_MAX ];
413
+ struct net * net = seq -> private ;
414
+ int i ;
415
+
416
+ memset (buff , 0 , TCPUDP_MIB_MAX * sizeof (unsigned long ));
405
417
406
418
seq_puts (seq , "\nTcp:" );
407
419
for (i = 0 ; snmp4_tcp_list [i ].name != NULL ; i ++ )
408
420
seq_printf (seq , " %s" , snmp4_tcp_list [i ].name );
409
421
410
422
seq_puts (seq , "\nTcp:" );
423
+ snmp_get_cpu_field_batch (buff , snmp4_tcp_list ,
424
+ net -> mib .tcp_statistics );
411
425
for (i = 0 ; snmp4_tcp_list [i ].name != NULL ; i ++ ) {
412
426
/* MaxConn field is signed, RFC 2012 */
413
427
if (snmp4_tcp_list [i ].entry == TCP_MIB_MAXCONN )
414
- seq_printf (seq , " %ld" ,
415
- snmp_fold_field (net -> mib .tcp_statistics ,
416
- snmp4_tcp_list [i ].entry ));
428
+ seq_printf (seq , " %ld" , buff [i ]);
417
429
else
418
- seq_printf (seq , " %lu" ,
419
- snmp_fold_field (net -> mib .tcp_statistics ,
420
- snmp4_tcp_list [i ].entry ));
430
+ seq_printf (seq , " %lu" , buff [i ]);
421
431
}
422
432
433
+ memset (buff , 0 , TCPUDP_MIB_MAX * sizeof (unsigned long ));
434
+
435
+ snmp_get_cpu_field_batch (buff , snmp4_udp_list ,
436
+ net -> mib .udp_statistics );
423
437
seq_puts (seq , "\nUdp:" );
424
438
for (i = 0 ; snmp4_udp_list [i ].name != NULL ; i ++ )
425
439
seq_printf (seq , " %s" , snmp4_udp_list [i ].name );
426
-
427
440
seq_puts (seq , "\nUdp:" );
428
441
for (i = 0 ; snmp4_udp_list [i ].name != NULL ; i ++ )
429
- seq_printf (seq , " %lu" ,
430
- snmp_fold_field ( net -> mib . udp_statistics ,
431
- snmp4_udp_list [ i ]. entry ));
442
+ seq_printf (seq , " %lu" , buff [ i ]);
443
+
444
+ memset ( buff , 0 , TCPUDP_MIB_MAX * sizeof ( unsigned long ));
432
445
433
446
/* the UDP and UDP-Lite MIBs are the same */
434
447
seq_puts (seq , "\nUdpLite:" );
448
+ snmp_get_cpu_field_batch (buff , snmp4_udp_list ,
449
+ net -> mib .udplite_statistics );
435
450
for (i = 0 ; snmp4_udp_list [i ].name != NULL ; i ++ )
436
451
seq_printf (seq , " %s" , snmp4_udp_list [i ].name );
437
-
438
452
seq_puts (seq , "\nUdpLite:" );
439
453
for (i = 0 ; snmp4_udp_list [i ].name != NULL ; i ++ )
440
- seq_printf (seq , " %lu" ,
441
- snmp_fold_field (net -> mib .udplite_statistics ,
442
- snmp4_udp_list [i ].entry ));
454
+ seq_printf (seq , " %lu" , buff [i ]);
443
455
444
456
seq_putc (seq , '\n' );
445
457
return 0 ;
446
458
}
447
459
460
+ static int snmp_seq_show (struct seq_file * seq , void * v )
461
+ {
462
+ snmp_seq_show_ipstats (seq , v );
463
+
464
+ icmp_put (seq ); /* RFC 2011 compatibility */
465
+ icmpmsg_put (seq );
466
+
467
+ snmp_seq_show_tcp_udp (seq , v );
468
+
469
+ return 0 ;
470
+ }
471
+
448
472
static int snmp_seq_open (struct inode * inode , struct file * file )
449
473
{
450
474
return single_open_net (inode , file , snmp_seq_show );
0 commit comments