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
1c7b149b
Commit
1c7b149b
authored
Nov 13, 2002
by
David S. Miller
Browse files
Options
Browse Files
Download
Plain Diff
Merge master.kernel.org:/home/acme/BK/net-2.5
into nuts.ninka.net:/home/davem/src/BK/net-2.5
parents
81b4c8d1
88de51ee
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
286 additions
and
210 deletions
+286
-210
include/linux/udp.h
include/linux/udp.h
+0
-3
include/net/ip_fib.h
include/net/ip_fib.h
+0
-3
include/net/udp.h
include/net/udp.h
+0
-2
net/ipv4/af_inet.c
net/ipv4/af_inet.c
+10
-6
net/ipv4/fib_hash.c
net/ipv4/fib_hash.c
+0
-12
net/ipv4/proc.c
net/ipv4/proc.c
+113
-97
net/ipv4/raw.c
net/ipv4/raw.c
+156
-59
net/ipv4/udp.c
net/ipv4/udp.c
+0
-12
net/socket.c
net/socket.c
+7
-16
No files found.
include/linux/udp.h
View file @
1c7b149b
...
...
@@ -57,7 +57,4 @@ struct udp_sock {
#define udp_sk(__sk) (&((struct udp_sock *)__sk)->udp)
extern
int
udp_proc_init
(
void
);
extern
void
udp_proc_exit
(
void
);
#endif
/* _LINUX_UDP_H */
include/net/ip_fib.h
View file @
1c7b149b
...
...
@@ -276,7 +276,4 @@ static inline void fib_res_put(struct fib_result *res)
#endif
}
extern
int
fib_proc_init
(
void
);
extern
void
fib_proc_exit
(
void
);
#endif
/* _NET_FIB_H */
include/net/udp.h
View file @
1c7b149b
...
...
@@ -76,6 +76,4 @@ extern struct udp_mib udp_statistics[NR_CPUS*2];
#define UDP_INC_STATS_BH(field) SNMP_INC_STATS_BH(udp_statistics, field)
#define UDP_INC_STATS_USER(field) SNMP_INC_STATS_USER(udp_statistics, field)
extern
int
udp_proc_init
(
void
);
#endif
/* _UDP_H */
net/ipv4/af_inet.c
View file @
1c7b149b
...
...
@@ -1160,16 +1160,20 @@ module_init(inet_init);
/* ------------------------------------------------------------------------ */
#ifdef CONFIG_PROC_FS
extern
int
ip_misc_proc_init
(
void
);
extern
int
raw_get_info
(
char
*
,
char
**
,
off_t
,
int
);
extern
int
tcp_get_info
(
char
*
,
char
**
,
off_t
,
int
);
extern
int
fib_proc_init
(
void
);
extern
void
fib_proc_exit
(
void
);
extern
int
ip_misc_proc_init
(
void
);
extern
int
raw_proc_init
(
void
);
extern
void
raw_proc_exit
(
void
);
extern
int
tcp_get_info
(
char
*
buffer
,
char
**
start
,
off_t
offset
,
int
length
);
extern
int
udp_proc_init
(
void
);
extern
void
udp_proc_exit
(
void
);
int
__init
ipv4_proc_init
(
void
)
{
int
rc
=
0
;
if
(
!
proc_net_create
(
"raw"
,
0
,
raw_get_info
))
if
(
raw_proc_init
(
))
goto
out_raw
;
if
(
!
proc_net_create
(
"tcp"
,
0
,
tcp_get_info
))
goto
out_tcp
;
...
...
@@ -1188,7 +1192,7 @@ int __init ipv4_proc_init(void)
out_udp:
proc_net_remove
(
"tcp"
);
out_tcp:
proc_net_remove
(
"raw"
);
raw_proc_exit
(
);
out_raw:
rc
=
-
ENOMEM
;
goto
out
;
...
...
net/ipv4/fib_hash.c
View file @
1c7b149b
...
...
@@ -1092,16 +1092,4 @@ void __init fib_proc_exit(void)
{
remove_proc_entry
(
"route"
,
proc_net
);
}
#else
/* CONFIG_PROC_FS */
int
__init
fib_proc_init
(
void
)
{
return
0
;
}
void
__init
fib_proc_exit
(
void
)
{
return
0
;
}
#endif
/* CONFIG_PROC_FS */
net/ipv4/proc.c
View file @
1c7b149b
...
...
@@ -23,30 +23,21 @@
* Alan Cox : Handle dead sockets properly.
* Gerhard Koerting : Show both timers
* Alan Cox : Allow inode to be NULL (kernel socket)
* Andi Kleen : Add support for open_requests and
* 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
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*/
#include <asm/system.h>
#include <linux/sched.h>
#include <linux/socket.h>
#include <linux/net.h>
#include <linux/un.h>
#include <linux/in.h>
#include <linux/param.h>
#include <linux/inet.h>
#include <linux/netdevice.h>
#include <net/ip.h>
#include <linux/types.h>
#include <net/icmp.h>
#include <net/protocol.h>
#include <net/tcp.h>
#include <net/udp.h>
#include <linux/skbuff.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <net/sock.h>
...
...
@@ -57,7 +48,7 @@ static int fold_prot_inuse(struct proto *proto)
int
res
=
0
;
int
cpu
;
for
(
cpu
=
0
;
cpu
<
NR_CPUS
;
cpu
++
)
for
(
cpu
=
0
;
cpu
<
NR_CPUS
;
cpu
++
)
res
+=
proto
->
stats
[
cpu
].
inuse
;
return
res
;
...
...
@@ -66,38 +57,35 @@ static int fold_prot_inuse(struct proto *proto)
/*
* Report socket allocation statistics [mea@utu.fi]
*/
int
afinet_get_info
(
char
*
buffer
,
char
**
start
,
off_t
offset
,
int
length
)
static
int
sockstat_seq_show
(
struct
seq_file
*
seq
,
void
*
v
)
{
/* From net/socket.c */
extern
int
socket_get_info
(
char
*
,
char
**
,
off_t
,
int
);
int
len
=
socket_get_info
(
buffer
,
start
,
offset
,
length
);
len
+=
sprintf
(
buffer
+
len
,
"TCP: inuse %d orphan %d tw %d alloc %d mem %d
\n
"
,
fold_prot_inuse
(
&
tcp_prot
),
atomic_read
(
&
tcp_orphan_count
),
tcp_tw_count
,
atomic_read
(
&
tcp_sockets_allocated
),
atomic_read
(
&
tcp_memory_allocated
));
len
+=
sprintf
(
buffer
+
len
,
"UDP: inuse %d
\n
"
,
fold_prot_inuse
(
&
udp_prot
));
len
+=
sprintf
(
buffer
+
len
,
"RAW: inuse %d
\n
"
,
fold_prot_inuse
(
&
raw_prot
));
len
+=
sprintf
(
buffer
+
len
,
"FRAG: inuse %d memory %d
\n
"
,
ip_frag_nqueues
,
atomic_read
(
&
ip_frag_mem
));
if
(
offset
>=
len
)
{
*
start
=
buffer
;
return
0
;
}
*
start
=
buffer
+
offset
;
len
-=
offset
;
if
(
len
>
length
)
len
=
length
;
if
(
len
<
0
)
len
=
0
;
return
len
;
/* From net/socket.c */
extern
void
socket_seq_show
(
struct
seq_file
*
seq
);
socket_seq_show
(
seq
);
seq_printf
(
seq
,
"TCP: inuse %d orphan %d tw %d alloc %d mem %d
\n
"
,
fold_prot_inuse
(
&
tcp_prot
),
atomic_read
(
&
tcp_orphan_count
),
tcp_tw_count
,
atomic_read
(
&
tcp_sockets_allocated
),
atomic_read
(
&
tcp_memory_allocated
));
seq_printf
(
seq
,
"UDP: inuse %d
\n
"
,
fold_prot_inuse
(
&
udp_prot
));
seq_printf
(
seq
,
"RAW: inuse %d
\n
"
,
fold_prot_inuse
(
&
raw_prot
));
seq_printf
(
seq
,
"FRAG: inuse %d memory %d
\n
"
,
ip_frag_nqueues
,
atomic_read
(
&
ip_frag_mem
));
return
0
;
}
static
int
sockstat_seq_open
(
struct
inode
*
inode
,
struct
file
*
file
)
{
return
single_open
(
file
,
sockstat_seq_show
,
NULL
);
}
static
struct
file_operations
sockstat_seq_fops
=
{
.
open
=
sockstat_seq_open
,
.
read
=
seq_read
,
.
llseek
=
seq_lseek
,
.
release
=
single_release
,
};
static
unsigned
long
fold_field
(
unsigned
long
*
begin
,
int
sz
,
int
nr
)
{
unsigned
long
res
=
0
;
...
...
@@ -105,63 +93,84 @@ static unsigned long fold_field(unsigned long *begin, int sz, int nr)
sz
/=
sizeof
(
unsigned
long
);
for
(
i
=
0
;
i
<
NR_CPUS
;
i
++
)
{
res
+=
begin
[
2
*
i
*
sz
+
nr
];
res
+=
begin
[(
2
*
i
+
1
)
*
sz
+
nr
];
for
(
i
=
0
;
i
<
NR_CPUS
;
i
++
)
{
res
+=
begin
[
2
*
i
*
sz
+
nr
];
res
+=
begin
[(
2
*
i
+
1
)
*
sz
+
nr
];
}
return
res
;
}
/*
/*
* 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
"
"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
"
);
if
(
offset
>=
len
)
{
*
start
=
buffer
;
return
0
;
}
*
start
=
buffer
+
offset
;
len
-=
offset
;
if
(
len
>
length
)
len
=
length
;
if
(
len
<
0
)
len
=
0
;
return
len
;
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
++
)
seq_printf
(
seq
,
" %lu"
,
fold_field
((
unsigned
long
*
)
udp_statistics
,
sizeof
(
struct
udp_mib
),
i
));
seq_putc
(
seq
,
'\n'
);
return
0
;
}
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
*/
static
int
netstat_seq_show
(
struct
seq_file
*
seq
,
void
*
v
)
...
...
@@ -181,7 +190,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 +199,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 +229,26 @@ 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
;
if
(
!
proc_net_create
(
"sockstat"
,
0
,
afinet_get_info
))
p
->
proc_fops
=
&
snmp_seq_fops
;
p
=
create_proc_entry
(
"sockstat"
,
S_IRUGO
,
proc_net
);
if
(
!
p
)
goto
out_sockstat
;
p
->
proc_fops
=
&
sockstat_seq_fops
;
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:
...
...
net/ipv4/raw.c
View file @
1c7b149b
...
...
@@ -40,31 +40,42 @@
*/
#include <linux/config.h>
#include <asm/system.h>
#include <asm/atomic.h>
#include <asm/byteorder.h>
#include <asm/current.h>
#include <asm/uaccess.h>
#include <asm/ioctls.h>
#include <linux/types.h>
#include <linux/sched.h>
#include <linux/stddef.h>
#include <linux/slab.h>
#include <linux/errno.h>
#include <linux/timer.h>
#include <linux/mm.h>
#include <linux/aio.h>
#include <linux/kernel.h>
#include <linux/fcntl.h>
#include <linux/spinlock.h>
#include <linux/sockios.h>
#include <linux/socket.h>
#include <linux/in.h>
#include <linux/inet.h>
#include <linux/netdevice.h>
#include <linux/
m
route.h>
#include <
net/tcp
.h>
#include <
net/protocol
.h>
#include <linux/
in_
route.h>
#include <
linux/route
.h>
#include <
linux/tcp
.h>
#include <linux/skbuff.h>
#include <net/dst.h>
#include <net/sock.h>
#include <linux/gfp.h>
#include <linux/ip.h>
#include <net/ip.h>
#include <net/icmp.h>
#include <net/udp.h>
#include <net/raw.h>
#include <net/snmp.h>
#include <net/inet_common.h>
#include <net/checksum.h>
#include <net/xfrm.h>
#include <linux/rtnetlink.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/netfilter.h>
#include <linux/netfilter_ipv4.h>
struct
sock
*
raw_v4_htable
[
RAWV4_HTABLE_SIZE
];
...
...
@@ -656,7 +667,95 @@ static int raw_ioctl(struct sock *sk, int cmd, unsigned long arg)
}
}
static
void
get_raw_sock
(
struct
sock
*
sp
,
char
*
tmpbuf
,
int
i
)
struct
proto
raw_prot
=
{
.
name
=
"RAW"
,
.
close
=
raw_close
,
.
connect
=
udp_connect
,
.
disconnect
=
udp_disconnect
,
.
ioctl
=
raw_ioctl
,
.
init
=
raw_init
,
.
setsockopt
=
raw_setsockopt
,
.
getsockopt
=
raw_getsockopt
,
.
sendmsg
=
raw_sendmsg
,
.
recvmsg
=
raw_recvmsg
,
.
bind
=
raw_bind
,
.
backlog_rcv
=
raw_rcv_skb
,
.
hash
=
raw_v4_hash
,
.
unhash
=
raw_v4_unhash
,
};
#ifdef CONFIG_PROC_FS
struct
raw_iter_state
{
int
bucket
;
};
#define raw_seq_private(seq) ((struct raw_iter_state *)&seq->private)
static
struct
sock
*
raw_get_first
(
struct
seq_file
*
seq
)
{
struct
sock
*
sk
=
NULL
;
struct
raw_iter_state
*
state
=
raw_seq_private
(
seq
);
for
(
state
->
bucket
=
0
;
state
->
bucket
<
RAWV4_HTABLE_SIZE
;
++
state
->
bucket
)
{
sk
=
raw_v4_htable
[
state
->
bucket
];
while
(
sk
&&
sk
->
family
!=
PF_INET
)
sk
=
sk
->
next
;
if
(
sk
)
break
;
}
return
sk
;
}
static
struct
sock
*
raw_get_next
(
struct
seq_file
*
seq
,
struct
sock
*
sk
)
{
struct
raw_iter_state
*
state
=
raw_seq_private
(
seq
);
do
{
sk
=
sk
->
next
;
try_again:
}
while
(
sk
&&
sk
->
family
!=
PF_INET
);
if
(
!
sk
&&
++
state
->
bucket
<
RAWV4_HTABLE_SIZE
)
{
sk
=
raw_v4_htable
[
state
->
bucket
];
goto
try_again
;
}
return
sk
;
}
static
struct
sock
*
raw_get_idx
(
struct
seq_file
*
seq
,
loff_t
pos
)
{
struct
sock
*
sk
=
raw_get_first
(
seq
);
if
(
sk
)
while
(
pos
&&
(
sk
=
raw_get_next
(
seq
,
sk
))
!=
NULL
)
--
pos
;
return
pos
?
NULL
:
sk
;
}
static
void
*
raw_seq_start
(
struct
seq_file
*
seq
,
loff_t
*
pos
)
{
read_lock
(
&
raw_v4_lock
);
return
*
pos
?
raw_get_idx
(
seq
,
*
pos
)
:
(
void
*
)
1
;
}
static
void
*
raw_seq_next
(
struct
seq_file
*
seq
,
void
*
v
,
loff_t
*
pos
)
{
struct
sock
*
sk
;
if
(
v
==
(
void
*
)
1
)
sk
=
raw_get_first
(
seq
);
else
sk
=
raw_get_next
(
seq
,
v
);
++*
pos
;
return
sk
;
}
static
void
raw_seq_stop
(
struct
seq_file
*
seq
,
void
*
v
)
{
read_unlock
(
&
raw_v4_lock
);
}
static
__inline__
char
*
get_raw_sock
(
struct
sock
*
sp
,
char
*
tmpbuf
,
int
i
)
{
struct
inet_opt
*
inet
=
inet_sk
(
sp
);
unsigned
int
dest
=
inet
->
daddr
,
...
...
@@ -668,65 +767,63 @@ static void get_raw_sock(struct sock *sp, char *tmpbuf, int i)
" %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p"
,
i
,
src
,
srcp
,
dest
,
destp
,
sp
->
state
,
atomic_read
(
&
sp
->
wmem_alloc
),
atomic_read
(
&
sp
->
rmem_alloc
),
0
,
0L
,
0
,
sock_i_uid
(
sp
),
0
,
sock_i_ino
(
sp
),
0
,
0L
,
0
,
sock_i_uid
(
sp
),
0
,
sock_i_ino
(
sp
),
atomic_read
(
&
sp
->
refcnt
),
sp
);
return
tmpbuf
;
}
int
raw_get_info
(
char
*
buffer
,
char
**
start
,
off_t
offset
,
int
length
)
static
int
raw_seq_show
(
struct
seq_file
*
seq
,
void
*
v
)
{
int
len
=
0
,
num
=
0
,
i
;
off_t
pos
=
128
;
off_t
begin
;
char
tmpbuf
[
129
];
if
(
offset
<
128
)
len
+=
sprintf
(
buffer
,
"%-127s
\n
"
,
if
(
v
==
(
void
*
)
1
)
seq_printf
(
seq
,
"%-127s
\n
"
,
" sl local_address rem_address st tx_queue "
"rx_queue tr tm->when retrnsmt uid timeout "
"inode"
);
read_lock
(
&
raw_v4_lock
);
for
(
i
=
0
;
i
<
RAWV4_HTABLE_SIZE
;
i
++
)
{
struct
sock
*
sk
;
for
(
sk
=
raw_v4_htable
[
i
];
sk
;
sk
=
sk
->
next
,
num
++
)
{
if
(
sk
->
family
!=
PF_INET
)
continue
;
pos
+=
128
;
if
(
pos
<=
offset
)
continue
;
get_raw_sock
(
sk
,
tmpbuf
,
i
);
len
+=
sprintf
(
buffer
+
len
,
"%-127s
\n
"
,
tmpbuf
);
if
(
len
>=
length
)
goto
out
;
}
else
{
struct
raw_iter_state
*
state
=
raw_seq_private
(
seq
);
seq_printf
(
seq
,
"%-127s
\n
"
,
get_raw_sock
(
v
,
tmpbuf
,
state
->
bucket
));
}
out:
read_unlock
(
&
raw_v4_lock
);
begin
=
len
-
(
pos
-
offset
);
*
start
=
buffer
+
begin
;
len
-=
begin
;
if
(
len
>
length
)
len
=
length
;
if
(
len
<
0
)
len
=
0
;
return
len
;
return
0
;
}
struct
proto
raw_prot
=
{
.
name
=
"RAW"
,
.
close
=
raw_close
,
.
connect
=
udp_connect
,
.
disconnect
=
udp_disconnect
,
.
ioctl
=
raw_ioctl
,
.
init
=
raw_init
,
.
setsockopt
=
raw_setsockopt
,
.
getsockopt
=
raw_getsockopt
,
.
sendmsg
=
raw_sendmsg
,
.
recvmsg
=
raw_recvmsg
,
.
bind
=
raw_bind
,
.
backlog_rcv
=
raw_rcv_skb
,
.
hash
=
raw_v4_hash
,
.
unhash
=
raw_v4_unhash
,
static
struct
seq_operations
raw_seq_ops
=
{
.
start
=
raw_seq_start
,
.
next
=
raw_seq_next
,
.
stop
=
raw_seq_stop
,
.
show
=
raw_seq_show
,
};
static
int
raw_seq_open
(
struct
inode
*
inode
,
struct
file
*
file
)
{
return
seq_open
(
file
,
&
raw_seq_ops
);
}
static
struct
file_operations
raw_seq_fops
=
{
.
open
=
raw_seq_open
,
.
read
=
seq_read
,
.
llseek
=
seq_lseek
,
.
release
=
seq_release
,
};
int
__init
raw_proc_init
(
void
)
{
struct
proc_dir_entry
*
p
;
int
rc
=
0
;
p
=
create_proc_entry
(
"raw"
,
S_IRUGO
,
proc_net
);
if
(
p
)
p
->
proc_fops
=
&
raw_seq_fops
;
else
rc
=
-
ENOMEM
;
return
rc
;
}
void
__init
raw_proc_exit
(
void
)
{
remove_proc_entry
(
"raw"
,
proc_net
);
}
#endif
/* CONFIG_PROC_FS */
net/ipv4/udp.c
View file @
1c7b149b
...
...
@@ -1377,16 +1377,4 @@ void __init udp_proc_exit(void)
{
remove_proc_entry
(
"udp"
,
proc_net
);
}
#else
/* CONFIG_PROC_FS */
int
__init
udp_proc_init
(
void
)
{
return
0
;
}
void
__init
udp_proc_exit
(
void
)
{
return
0
;
}
#endif
/* CONFIG_PROC_FS */
net/socket.c
View file @
1c7b149b
...
...
@@ -66,6 +66,7 @@
#include <linux/interrupt.h>
#include <linux/netdevice.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/wanrouter.h>
#include <linux/netlink.h>
#include <linux/rtnetlink.h>
...
...
@@ -1839,29 +1840,19 @@ void __init sock_init(void)
#endif
}
int
socket_get_info
(
char
*
buffer
,
char
**
start
,
off_t
offset
,
int
length
)
#ifdef CONFIG_PROC_FS
void
socket_seq_show
(
struct
seq_file
*
seq
)
{
int
len
,
cpu
;
int
cpu
;
int
counter
=
0
;
for
(
cpu
=
0
;
cpu
<
NR_CPUS
;
cpu
++
)
for
(
cpu
=
0
;
cpu
<
NR_CPUS
;
cpu
++
)
counter
+=
sockets_in_use
[
cpu
].
counter
;
/* It can be negative, by the way. 8) */
if
(
counter
<
0
)
counter
=
0
;
len
=
sprintf
(
buffer
,
"sockets: used %d
\n
"
,
counter
);
if
(
offset
>=
len
)
{
*
start
=
buffer
;
return
0
;
}
*
start
=
buffer
+
offset
;
len
-=
offset
;
if
(
len
>
length
)
len
=
length
;
if
(
len
<
0
)
len
=
0
;
return
len
;
seq_printf
(
seq
,
"sockets: used %d
\n
"
,
counter
);
}
#endif
/* CONFIG_PROC_FS */
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