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
nexedi
linux
Commits
24818d6e
Commit
24818d6e
authored
Jul 02, 2003
by
Hideaki Yoshifuji
Committed by
James Morris
Jul 02, 2003
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[NET] convert /proc/net/igmp to seq_file
parent
f16fd25c
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
159 additions
and
47 deletions
+159
-47
include/net/ip.h
include/net/ip.h
+1
-1
net/ipv4/igmp.c
net/ipv4/igmp.c
+157
-45
net/ipv4/ip_output.c
net/ipv4/ip_output.c
+1
-1
No files found.
include/net/ip.h
View file @
24818d6e
...
@@ -79,7 +79,7 @@ extern rwlock_t ip_ra_lock;
...
@@ -79,7 +79,7 @@ extern rwlock_t ip_ra_lock;
extern
void
ip_mc_dropsocket
(
struct
sock
*
);
extern
void
ip_mc_dropsocket
(
struct
sock
*
);
extern
void
ip_mc_dropdevice
(
struct
net_device
*
dev
);
extern
void
ip_mc_dropdevice
(
struct
net_device
*
dev
);
extern
int
i
p_mc_procinfo
(
char
*
,
char
**
,
off_t
,
int
);
extern
int
i
gmp_mc_proc_init
(
void
);
extern
int
ip_mcf_procinfo
(
char
*
,
char
**
,
off_t
,
int
);
extern
int
ip_mcf_procinfo
(
char
*
,
char
**
,
off_t
,
int
);
/*
/*
...
...
net/ipv4/igmp.c
View file @
24818d6e
...
@@ -99,7 +99,10 @@
...
@@ -99,7 +99,10 @@
#ifdef CONFIG_IP_MROUTE
#ifdef CONFIG_IP_MROUTE
#include <linux/mroute.h>
#include <linux/mroute.h>
#endif
#endif
#ifdef CONFIG_PROC_FS
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#endif
#define IP_MAX_MEMBERSHIPS 20
#define IP_MAX_MEMBERSHIPS 20
...
@@ -2090,65 +2093,162 @@ int ip_check_mc(struct in_device *in_dev, u32 mc_addr, u32 src_addr, u16 proto)
...
@@ -2090,65 +2093,162 @@ int ip_check_mc(struct in_device *in_dev, u32 mc_addr, u32 src_addr, u16 proto)
return
rv
;
return
rv
;
}
}
#if defined(CONFIG_PROC_FS)
struct
igmp_mc_iter_state
{
struct
net_device
*
dev
;
struct
in_device
*
in_dev
;
};
#define igmp_mc_seq_private(seq) ((struct igmp_mc_iter_state *)&seq->private)
int
ip_mc_procinfo
(
char
*
buffer
,
char
**
start
,
off_t
offset
,
int
length
)
static
inline
struct
ip_mc_list
*
igmp_mc_get_first
(
struct
seq_file
*
seq
)
{
{
off_t
pos
=
0
,
begin
=
0
;
struct
ip_mc_list
*
im
=
NULL
;
struct
ip_mc_list
*
im
;
struct
igmp_mc_iter_state
*
state
=
igmp_mc_seq_private
(
seq
);
int
len
=
0
;
struct
net_device
*
dev
;
len
=
sprintf
(
buffer
,
"Idx
\t
Device : Count Querier
\t
Group Users Timer
\t
Reporter
\n
"
);
for
(
state
->
dev
=
dev_base
,
state
->
in_dev
=
NULL
;
state
->
dev
;
state
->
dev
=
state
->
dev
->
next
)
{
struct
in_device
*
in_dev
;
in_dev
=
in_dev_get
(
state
->
dev
);
if
(
!
in_dev
)
continue
;
read_lock
(
&
in_dev
->
lock
);
im
=
in_dev
->
mc_list
;
if
(
im
)
{
state
->
in_dev
=
in_dev
;
break
;
}
read_unlock
(
&
in_dev
->
lock
);
}
return
im
;
}
static
struct
ip_mc_list
*
igmp_mc_get_next
(
struct
seq_file
*
seq
,
struct
ip_mc_list
*
im
)
{
struct
igmp_mc_iter_state
*
state
=
igmp_mc_seq_private
(
seq
);
im
=
im
->
next
;
while
(
!
im
)
{
if
(
likely
(
state
->
in_dev
!=
NULL
))
{
read_unlock
(
&
state
->
in_dev
->
lock
);
in_dev_put
(
state
->
in_dev
);
}
state
->
dev
=
state
->
dev
->
next
;
if
(
!
state
->
dev
)
{
state
->
in_dev
=
NULL
;
break
;
}
state
->
in_dev
=
in_dev_get
(
state
->
dev
);
if
(
!
state
->
in_dev
)
continue
;
read_lock
(
&
state
->
in_dev
->
lock
);
im
=
state
->
in_dev
->
mc_list
;
}
return
im
;
}
static
struct
ip_mc_list
*
igmp_mc_get_idx
(
struct
seq_file
*
seq
,
loff_t
pos
)
{
struct
ip_mc_list
*
im
=
igmp_mc_get_first
(
seq
);
if
(
im
)
while
(
pos
&&
(
im
=
igmp_mc_get_next
(
seq
,
im
))
!=
NULL
)
--
pos
;
return
pos
?
NULL
:
im
;
}
static
void
*
igmp_mc_seq_start
(
struct
seq_file
*
seq
,
loff_t
*
pos
)
{
read_lock
(
&
dev_base_lock
);
read_lock
(
&
dev_base_lock
);
for
(
dev
=
dev_base
;
dev
;
dev
=
dev
->
next
)
{
return
*
pos
?
igmp_mc_get_idx
(
seq
,
*
pos
)
:
(
void
*
)
1
;
struct
in_device
*
in_dev
=
in_dev_get
(
dev
);
}
char
*
querier
=
"NONE"
;
if
(
in_dev
==
NULL
)
static
void
*
igmp_mc_seq_next
(
struct
seq_file
*
seq
,
void
*
v
,
loff_t
*
pos
)
continue
;
{
struct
ip_mc_list
*
im
;
if
(
v
==
(
void
*
)
1
)
im
=
igmp_mc_get_first
(
seq
);
else
im
=
igmp_mc_get_next
(
seq
,
v
);
++*
pos
;
return
im
;
}
static
void
igmp_mc_seq_stop
(
struct
seq_file
*
seq
,
void
*
v
)
{
struct
igmp_mc_iter_state
*
state
=
igmp_mc_seq_private
(
seq
);
if
(
likely
(
state
->
in_dev
!=
NULL
))
{
read_unlock
(
&
state
->
in_dev
->
lock
);
in_dev_put
(
state
->
in_dev
);
}
read_unlock
(
&
dev_base_lock
);
}
static
int
igmp_mc_seq_show
(
struct
seq_file
*
seq
,
void
*
v
)
{
if
(
v
==
(
void
*
)
1
)
seq_printf
(
seq
,
"Idx
\t
Device : Count Querier
\t
Group Users Timer
\t
Reporter
\n
"
);
else
{
struct
ip_mc_list
*
im
=
(
struct
ip_mc_list
*
)
v
;
struct
igmp_mc_iter_state
*
state
=
igmp_mc_seq_private
(
seq
);
char
*
querier
;
#ifdef CONFIG_IP_MULTICAST
#ifdef CONFIG_IP_MULTICAST
querier
=
IGMP_V1_SEEN
(
in_dev
)
?
"V1"
:
"V2"
;
querier
=
IGMP_V1_SEEN
(
state
->
in_dev
)
?
"V1"
:
"V2"
;
#else
querier
=
"NONE"
;
#endif
#endif
len
+=
sprintf
(
buffer
+
len
,
"%d
\t
%-10s: %5d %7s
\n
"
,
if
(
state
->
in_dev
->
mc_list
==
im
)
{
dev
->
ifindex
,
dev
->
name
,
dev
->
mc_count
,
querier
);
seq_printf
(
seq
,
"%d
\t
%-10s: %5d %7s
\n
"
,
state
->
dev
->
ifindex
,
state
->
dev
->
name
,
state
->
dev
->
mc_count
,
querier
);
}
read_lock
(
&
in_dev
->
lock
);
seq_printf
(
seq
,
for
(
im
=
in_dev
->
mc_list
;
im
;
im
=
im
->
next
)
{
len
+=
sprintf
(
buffer
+
len
,
"
\t\t\t\t
%08lX %5d %d:%08lX
\t\t
%d
\n
"
,
"
\t\t\t\t
%08lX %5d %d:%08lX
\t\t
%d
\n
"
,
im
->
multiaddr
,
im
->
users
,
im
->
multiaddr
,
im
->
users
,
im
->
tm_running
,
im
->
timer
.
expires
-
jiffies
,
im
->
reporter
);
im
->
tm_running
,
im
->
timer
.
expires
-
jiffies
,
im
->
reporter
);
pos
=
begin
+
len
;
if
(
pos
<
offset
)
{
len
=
0
;
begin
=
pos
;
}
if
(
pos
>
offset
+
length
)
{
read_unlock
(
&
in_dev
->
lock
);
in_dev_put
(
in_dev
);
goto
done
;
}
}
read_unlock
(
&
in_dev
->
lock
);
in_dev_put
(
in_dev
);
}
}
done:
return
0
;
read_unlock
(
&
dev_base_lock
);
}
*
start
=
buffer
+
(
offset
-
begin
);
static
struct
seq_operations
igmp_mc_seq_ops
=
{
len
-=
(
offset
-
begin
);
.
start
=
igmp_mc_seq_start
,
if
(
len
>
length
)
.
next
=
igmp_mc_seq_next
,
len
=
length
;
.
stop
=
igmp_mc_seq_stop
,
if
(
len
<
0
)
.
show
=
igmp_mc_seq_show
,
len
=
0
;
};
return
len
;
static
int
igmp_mc_seq_open
(
struct
inode
*
inode
,
struct
file
*
file
)
{
struct
seq_file
*
seq
;
int
rc
=
-
ENOMEM
;
struct
igmp_mc_iter_state
*
s
=
kmalloc
(
sizeof
(
*
s
),
GFP_KERNEL
);
if
(
!
s
)
goto
out
;
rc
=
seq_open
(
file
,
&
igmp_mc_seq_ops
);
if
(
rc
)
goto
out_kfree
;
seq
=
file
->
private_data
;
seq
->
private
=
s
;
memset
(
s
,
0
,
sizeof
(
*
s
));
out:
return
rc
;
out_kfree:
kfree
(
s
);
goto
out
;
}
}
static
struct
file_operations
igmp_mc_seq_fops
=
{
.
owner
=
THIS_MODULE
,
.
open
=
igmp_mc_seq_open
,
.
read
=
seq_read
,
.
llseek
=
seq_lseek
,
.
release
=
seq_release_private
,
};
#endif
int
ip_mcf_procinfo
(
char
*
buffer
,
char
**
start
,
off_t
offset
,
int
length
)
int
ip_mcf_procinfo
(
char
*
buffer
,
char
**
start
,
off_t
offset
,
int
length
)
{
{
off_t
pos
=
0
,
begin
=
0
;
off_t
pos
=
0
,
begin
=
0
;
...
@@ -2214,3 +2314,15 @@ int ip_mcf_procinfo(char *buffer, char **start, off_t offset, int length)
...
@@ -2214,3 +2314,15 @@ int ip_mcf_procinfo(char *buffer, char **start, off_t offset, int length)
return
len
;
return
len
;
}
}
#ifdef CONFIG_PROC_FS
int
__init
igmp_mc_proc_init
(
void
)
{
struct
proc_dir_entry
*
p
;
p
=
create_proc_entry
(
"igmp"
,
S_IRUGO
,
proc_net
);
if
(
p
)
p
->
proc_fops
=
&
igmp_mc_seq_fops
;
return
0
;
}
#endif
net/ipv4/ip_output.c
View file @
24818d6e
...
@@ -1314,7 +1314,7 @@ void __init ip_init(void)
...
@@ -1314,7 +1314,7 @@ void __init ip_init(void)
inet_initpeers
();
inet_initpeers
();
#ifdef CONFIG_IP_MULTICAST
#ifdef CONFIG_IP_MULTICAST
proc_net_create
(
"igmp"
,
0
,
ip_mc_procinfo
);
igmp_mc_proc_init
(
);
#endif
#endif
proc_net_create
(
"mcfilter"
,
0
,
ip_mcf_procinfo
);
proc_net_create
(
"mcfilter"
,
0
,
ip_mcf_procinfo
);
}
}
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