Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
01daf811
Commit
01daf811
authored
Nov 12, 2002
by
Arnaldo Carvalho de Melo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
o ipv4: convert /proc/net/snmp to seq_file
parent
ce4982c9
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
76 additions
and
49 deletions
+76
-49
net/ipv4/proc.c
net/ipv4/proc.c
+76
-49
No files found.
net/ipv4/proc.c
View file @
01daf811
...
...
@@ -26,6 +26,7 @@
* Andi Kleen : Add support for open_requests and
* split functions for more readibility.
* Andi Kleen : Add support for /proc/net/netstat
* Arnaldo C. Melo : Convert to seq_file
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
...
...
@@ -115,52 +116,73 @@ static unsigned long fold_field(unsigned long *begin, int sz, int nr)
/*
* Called from the PROCfs module. This outputs /proc/net/snmp.
*/
int
snmp_get_info
(
char
*
buffer
,
char
**
start
,
off_t
offset
,
int
length
)
static
int
snmp_seq_show
(
struct
seq_file
*
seq
,
void
*
v
)
{
extern
int
sysctl_ip_default_ttl
;
int
len
,
i
;
len
=
sprintf
(
buffer
,
"Ip: Forwarding DefaultTTL InReceives InHdrErrors InAddrErrors ForwDatagrams InUnknownProtos InDiscards InDelivers OutRequests OutDiscards OutNoRoutes ReasmTimeout ReasmReqds ReasmOKs ReasmFails FragOKs FragFails FragCreates
\n
"
"Ip: %d %d"
,
ipv4_devconf
.
forwarding
?
1
:
2
,
sysctl_ip_default_ttl
);
for
(
i
=
0
;
i
<
offsetof
(
struct
ip_mib
,
__pad
)
/
sizeof
(
unsigned
long
);
i
++
)
len
+=
sprintf
(
buffer
+
len
,
" %lu"
,
fold_field
((
unsigned
long
*
)
ip_statistics
,
sizeof
(
struct
ip_mib
),
i
));
len
+=
sprintf
(
buffer
+
len
,
"
\n
Icmp: InMsgs InErrors InDestUnreachs InTimeExcds InParmProbs InSrcQuenchs InRedirects InEchos InEchoReps InTimestamps InTimestampReps InAddrMasks InAddrMaskReps OutMsgs OutErrors OutDestUnreachs OutTimeExcds OutParmProbs OutSrcQuenchs OutRedirects OutEchos OutEchoReps OutTimestamps OutTimestampReps OutAddrMasks OutAddrMaskReps
\n
"
"Icmp:"
);
for
(
i
=
0
;
i
<
offsetof
(
struct
icmp_mib
,
dummy
)
/
sizeof
(
unsigned
long
);
i
++
)
len
+=
sprintf
(
buffer
+
len
,
" %lu"
,
fold_field
((
unsigned
long
*
)
icmp_statistics
,
sizeof
(
struct
icmp_mib
),
i
));
len
+=
sprintf
(
buffer
+
len
,
"
\n
Tcp: RtoAlgorithm RtoMin RtoMax MaxConn ActiveOpens PassiveOpens AttemptFails EstabResets CurrEstab InSegs OutSegs RetransSegs InErrs OutRsts
\n
"
"Tcp:"
);
for
(
i
=
0
;
i
<
offsetof
(
struct
tcp_mib
,
__pad
)
/
sizeof
(
unsigned
long
);
i
++
)
len
+=
sprintf
(
buffer
+
len
,
" %lu"
,
fold_field
((
unsigned
long
*
)
tcp_statistics
,
sizeof
(
struct
tcp_mib
),
i
));
len
+=
sprintf
(
buffer
+
len
,
"
\n
Udp: InDatagrams NoPorts InErrors OutDatagrams
\n
"
int
i
;
seq_printf
(
seq
,
"Ip: Forwarding DefaultTTL InReceives InHdrErrors "
"InAddrErrors ForwDatagrams InUnknownProtos "
"InDiscards InDelivers OutRequests OutDiscards "
"OutNoRoutes ReasmTimeout ReasmReqds ReasmOKs "
"ReasmFails FragOKs FragFails FragCreates
\n
Ip: %d %d"
,
ipv4_devconf
.
forwarding
?
1
:
2
,
sysctl_ip_default_ttl
);
for
(
i
=
0
;
i
<
offsetof
(
struct
ip_mib
,
__pad
)
/
sizeof
(
unsigned
long
);
i
++
)
seq_printf
(
seq
,
" %lu"
,
fold_field
((
unsigned
long
*
)
ip_statistics
,
sizeof
(
struct
ip_mib
),
i
));
seq_printf
(
seq
,
"
\n
Icmp: InMsgs InErrors InDestUnreachs InTimeExcds "
"InParmProbs InSrcQuenchs InRedirects InEchos "
"InEchoReps InTimestamps InTimestampReps InAddrMasks "
"InAddrMaskReps OutMsgs OutErrors OutDestUnreachs "
"OutTimeExcds OutParmProbs OutSrcQuenchs OutRedirects "
"OutEchos OutEchoReps OutTimestamps OutTimestampReps "
"OutAddrMasks OutAddrMaskReps
\n
Icmp:"
);
for
(
i
=
0
;
i
<
offsetof
(
struct
icmp_mib
,
dummy
)
/
sizeof
(
unsigned
long
);
i
++
)
seq_printf
(
seq
,
" %lu"
,
fold_field
((
unsigned
long
*
)
icmp_statistics
,
sizeof
(
struct
icmp_mib
),
i
));
seq_printf
(
seq
,
"
\n
Tcp: RtoAlgorithm RtoMin RtoMax MaxConn ActiveOpens "
"PassiveOpens AttemptFails EstabResets CurrEstab "
"InSegs OutSegs RetransSegs InErrs OutRsts
\n
Tcp:"
);
for
(
i
=
0
;
i
<
offsetof
(
struct
tcp_mib
,
__pad
)
/
sizeof
(
unsigned
long
);
i
++
)
seq_printf
(
seq
,
" %lu"
,
fold_field
((
unsigned
long
*
)
tcp_statistics
,
sizeof
(
struct
tcp_mib
),
i
));
seq_printf
(
seq
,
"
\n
Udp: InDatagrams NoPorts InErrors OutDatagrams
\n
"
"Udp:"
);
for
(
i
=
0
;
i
<
offsetof
(
struct
udp_mib
,
__pad
)
/
sizeof
(
unsigned
long
);
i
++
)
len
+=
sprintf
(
buffer
+
len
,
" %lu"
,
fold_field
((
unsigned
long
*
)
udp_statistics
,
sizeof
(
struct
udp_mib
),
i
));
len
+=
sprintf
(
buffer
+
len
,
"
\n
"
);
for
(
i
=
0
;
i
<
offsetof
(
struct
udp_mib
,
__pad
)
/
sizeof
(
unsigned
long
);
i
++
)
seq_printf
(
seq
,
" %lu"
,
fold_field
((
unsigned
long
*
)
udp_statistics
,
sizeof
(
struct
udp_mib
),
i
));
if
(
offset
>=
len
)
{
*
start
=
buffer
;
seq_putc
(
seq
,
'\n'
);
return
0
;
}
*
start
=
buffer
+
offset
;
len
-=
offset
;
if
(
len
>
length
)
len
=
length
;
if
(
len
<
0
)
len
=
0
;
return
len
;
}
static
int
snmp_seq_open
(
struct
inode
*
inode
,
struct
file
*
file
)
{
return
single_open
(
file
,
snmp_seq_show
,
NULL
);
}
static
struct
file_operations
snmp_seq_fops
=
{
.
open
=
snmp_seq_open
,
.
read
=
seq_read
,
.
llseek
=
seq_lseek
,
.
release
=
single_release
,
};
/*
* Output /proc/net/netstat
*/
...
...
@@ -181,7 +203,8 @@ static int netstat_seq_show(struct seq_file *seq, void *v)
" TCPPureAcks TCPHPAcks"
" TCPRenoRecovery TCPSackRecovery"
" TCPSACKReneging"
" TCPFACKReorder TCPSACKReorder TCPRenoReorder TCPTSReorder"
" TCPFACKReorder TCPSACKReorder TCPRenoReorder"
" TCPTSReorder"
" TCPFullUndo TCPPartialUndo TCPDSACKUndo TCPLossUndo"
" TCPLoss TCPLostRetransmit"
" TCPRenoFailures TCPSackFailures TCPLossFailures"
...
...
@@ -189,14 +212,14 @@ static int netstat_seq_show(struct seq_file *seq, void *v)
" TCPTimeouts"
" TCPRenoRecoveryFail TCPSackRecoveryFail"
" TCPSchedulerFailed TCPRcvCollapsed"
" TCPDSACKOldSent TCPDSACKOfoSent TCPDSACKRecv TCPDSACKOfoRecv"
" TCPDSACKOldSent TCPDSACKOfoSent TCPDSACKRecv"
" TCPDSACKOfoRecv"
" TCPAbortOnSyn TCPAbortOnData TCPAbortOnClose"
" TCPAbortOnMemory TCPAbortOnTimeout TCPAbortOnLinger"
" TCPAbortFailed TCPMemoryPressures
\n
"
"TcpExt:"
);
for
(
i
=
0
;
i
<
offsetof
(
struct
linux_mib
,
__pad
)
/
sizeof
(
unsigned
long
);
i
++
)
i
<
offsetof
(
struct
linux_mib
,
__pad
)
/
sizeof
(
unsigned
long
);
i
++
)
seq_printf
(
seq
,
" %lu"
,
fold_field
((
unsigned
long
*
)
net_statistics
,
sizeof
(
struct
linux_mib
),
i
));
...
...
@@ -219,20 +242,24 @@ static struct file_operations netstat_seq_fops = {
int
__init
ip_misc_proc_init
(
void
)
{
int
rc
=
0
;
struct
proc_dir_entry
*
p
=
create_proc_entry
(
"netstat"
,
S_IRUGO
,
proc_net
)
;
struct
proc_dir_entry
*
p
;
p
=
create_proc_entry
(
"netstat"
,
S_IRUGO
,
proc_net
);
if
(
!
p
)
goto
out_netstat
;
p
->
proc_fops
=
&
netstat_seq_fops
;
if
(
!
proc_net_create
(
"snmp"
,
0
,
snmp_get_info
))
p
=
create_proc_entry
(
"snmp"
,
S_IRUGO
,
proc_net
);
if
(
!
p
)
goto
out_snmp
;
p
->
proc_fops
=
&
snmp_seq_fops
;
if
(
!
proc_net_create
(
"sockstat"
,
0
,
afinet_get_info
))
goto
out_sockstat
;
out:
return
rc
;
out_sockstat:
proc_net_remove
(
"snmp"
);
remove_proc_entry
(
"snmp"
,
proc_net
);
out_snmp:
remove_proc_entry
(
"netstat"
,
proc_net
);
out_netstat:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment