mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
sctp: Make the proc files per network namespace.
- Convert all of the files under /proc/net/sctp to be per network namespace. - Don't print anything for /proc/net/sctp/snmp except in the initial network namespaces as the snmp counters still have to be converted to be per network namespace. Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com> Acked-by: Vlad Yasevich <vyasevich@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
632c928a6a
commit
13d782f6b4
5 changed files with 97 additions and 85 deletions
|
@ -80,8 +80,12 @@ static const struct snmp_mib sctp_snmp_list[] = {
|
|||
/* Display sctp snmp mib statistics(/proc/net/sctp/snmp). */
|
||||
static int sctp_snmp_seq_show(struct seq_file *seq, void *v)
|
||||
{
|
||||
struct net *net = seq->private;
|
||||
int i;
|
||||
|
||||
if (!net_eq(net, &init_net))
|
||||
return 0;
|
||||
|
||||
for (i = 0; sctp_snmp_list[i].name != NULL; i++)
|
||||
seq_printf(seq, "%-32s\t%ld\n", sctp_snmp_list[i].name,
|
||||
snmp_fold_field((void __percpu **)sctp_statistics,
|
||||
|
@ -93,7 +97,7 @@ static int sctp_snmp_seq_show(struct seq_file *seq, void *v)
|
|||
/* Initialize the seq file operations for 'snmp' object. */
|
||||
static int sctp_snmp_seq_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
return single_open(file, sctp_snmp_seq_show, NULL);
|
||||
return single_open_net(inode, file, sctp_snmp_seq_show);
|
||||
}
|
||||
|
||||
static const struct file_operations sctp_snmp_seq_fops = {
|
||||
|
@ -105,11 +109,12 @@ static const struct file_operations sctp_snmp_seq_fops = {
|
|||
};
|
||||
|
||||
/* Set up the proc fs entry for 'snmp' object. */
|
||||
int __init sctp_snmp_proc_init(void)
|
||||
int __net_init sctp_snmp_proc_init(struct net *net)
|
||||
{
|
||||
struct proc_dir_entry *p;
|
||||
|
||||
p = proc_create("snmp", S_IRUGO, proc_net_sctp, &sctp_snmp_seq_fops);
|
||||
p = proc_create("snmp", S_IRUGO, net->sctp.proc_net_sctp,
|
||||
&sctp_snmp_seq_fops);
|
||||
if (!p)
|
||||
return -ENOMEM;
|
||||
|
||||
|
@ -117,9 +122,9 @@ int __init sctp_snmp_proc_init(void)
|
|||
}
|
||||
|
||||
/* Cleanup the proc fs entry for 'snmp' object. */
|
||||
void sctp_snmp_proc_exit(void)
|
||||
void sctp_snmp_proc_exit(struct net *net)
|
||||
{
|
||||
remove_proc_entry("snmp", proc_net_sctp);
|
||||
remove_proc_entry("snmp", net->sctp.proc_net_sctp);
|
||||
}
|
||||
|
||||
/* Dump local addresses of an association/endpoint. */
|
||||
|
@ -197,6 +202,7 @@ static void * sctp_eps_seq_next(struct seq_file *seq, void *v, loff_t *pos)
|
|||
/* Display sctp endpoints (/proc/net/sctp/eps). */
|
||||
static int sctp_eps_seq_show(struct seq_file *seq, void *v)
|
||||
{
|
||||
struct seq_net_private *priv = seq->private;
|
||||
struct sctp_hashbucket *head;
|
||||
struct sctp_ep_common *epb;
|
||||
struct sctp_endpoint *ep;
|
||||
|
@ -213,6 +219,8 @@ static int sctp_eps_seq_show(struct seq_file *seq, void *v)
|
|||
sctp_for_each_hentry(epb, node, &head->chain) {
|
||||
ep = sctp_ep(epb);
|
||||
sk = epb->sk;
|
||||
if (!net_eq(sock_net(sk), priv->net))
|
||||
continue;
|
||||
seq_printf(seq, "%8pK %8pK %-3d %-3d %-4d %-5d %5d %5lu ", ep, sk,
|
||||
sctp_sk(sk)->type, sk->sk_state, hash,
|
||||
epb->bind_addr.port,
|
||||
|
@ -238,7 +246,8 @@ static const struct seq_operations sctp_eps_ops = {
|
|||
/* Initialize the seq file operations for 'eps' object. */
|
||||
static int sctp_eps_seq_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
return seq_open(file, &sctp_eps_ops);
|
||||
return seq_open_net(inode, file, &sctp_eps_ops,
|
||||
sizeof(struct seq_net_private));
|
||||
}
|
||||
|
||||
static const struct file_operations sctp_eps_seq_fops = {
|
||||
|
@ -249,11 +258,12 @@ static const struct file_operations sctp_eps_seq_fops = {
|
|||
};
|
||||
|
||||
/* Set up the proc fs entry for 'eps' object. */
|
||||
int __init sctp_eps_proc_init(void)
|
||||
int __net_init sctp_eps_proc_init(struct net *net)
|
||||
{
|
||||
struct proc_dir_entry *p;
|
||||
|
||||
p = proc_create("eps", S_IRUGO, proc_net_sctp, &sctp_eps_seq_fops);
|
||||
p = proc_create("eps", S_IRUGO, net->sctp.proc_net_sctp,
|
||||
&sctp_eps_seq_fops);
|
||||
if (!p)
|
||||
return -ENOMEM;
|
||||
|
||||
|
@ -261,9 +271,9 @@ int __init sctp_eps_proc_init(void)
|
|||
}
|
||||
|
||||
/* Cleanup the proc fs entry for 'eps' object. */
|
||||
void sctp_eps_proc_exit(void)
|
||||
void sctp_eps_proc_exit(struct net *net)
|
||||
{
|
||||
remove_proc_entry("eps", proc_net_sctp);
|
||||
remove_proc_entry("eps", net->sctp.proc_net_sctp);
|
||||
}
|
||||
|
||||
|
||||
|
@ -300,6 +310,7 @@ static void * sctp_assocs_seq_next(struct seq_file *seq, void *v, loff_t *pos)
|
|||
/* Display sctp associations (/proc/net/sctp/assocs). */
|
||||
static int sctp_assocs_seq_show(struct seq_file *seq, void *v)
|
||||
{
|
||||
struct seq_net_private *priv = seq->private;
|
||||
struct sctp_hashbucket *head;
|
||||
struct sctp_ep_common *epb;
|
||||
struct sctp_association *assoc;
|
||||
|
@ -316,6 +327,8 @@ static int sctp_assocs_seq_show(struct seq_file *seq, void *v)
|
|||
sctp_for_each_hentry(epb, node, &head->chain) {
|
||||
assoc = sctp_assoc(epb);
|
||||
sk = epb->sk;
|
||||
if (!net_eq(sock_net(sk), priv->net))
|
||||
continue;
|
||||
seq_printf(seq,
|
||||
"%8pK %8pK %-3d %-3d %-2d %-4d "
|
||||
"%4d %8d %8d %7d %5lu %-5d %5d ",
|
||||
|
@ -354,7 +367,8 @@ static const struct seq_operations sctp_assoc_ops = {
|
|||
/* Initialize the seq file operations for 'assocs' object. */
|
||||
static int sctp_assocs_seq_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
return seq_open(file, &sctp_assoc_ops);
|
||||
return seq_open_net(inode, file, &sctp_assoc_ops,
|
||||
sizeof(struct seq_net_private));
|
||||
}
|
||||
|
||||
static const struct file_operations sctp_assocs_seq_fops = {
|
||||
|
@ -365,11 +379,11 @@ static const struct file_operations sctp_assocs_seq_fops = {
|
|||
};
|
||||
|
||||
/* Set up the proc fs entry for 'assocs' object. */
|
||||
int __init sctp_assocs_proc_init(void)
|
||||
int __net_init sctp_assocs_proc_init(struct net *net)
|
||||
{
|
||||
struct proc_dir_entry *p;
|
||||
|
||||
p = proc_create("assocs", S_IRUGO, proc_net_sctp,
|
||||
p = proc_create("assocs", S_IRUGO, net->sctp.proc_net_sctp,
|
||||
&sctp_assocs_seq_fops);
|
||||
if (!p)
|
||||
return -ENOMEM;
|
||||
|
@ -378,9 +392,9 @@ int __init sctp_assocs_proc_init(void)
|
|||
}
|
||||
|
||||
/* Cleanup the proc fs entry for 'assocs' object. */
|
||||
void sctp_assocs_proc_exit(void)
|
||||
void sctp_assocs_proc_exit(struct net *net)
|
||||
{
|
||||
remove_proc_entry("assocs", proc_net_sctp);
|
||||
remove_proc_entry("assocs", net->sctp.proc_net_sctp);
|
||||
}
|
||||
|
||||
static void *sctp_remaddr_seq_start(struct seq_file *seq, loff_t *pos)
|
||||
|
@ -412,6 +426,7 @@ static void sctp_remaddr_seq_stop(struct seq_file *seq, void *v)
|
|||
|
||||
static int sctp_remaddr_seq_show(struct seq_file *seq, void *v)
|
||||
{
|
||||
struct seq_net_private *priv = seq->private;
|
||||
struct sctp_hashbucket *head;
|
||||
struct sctp_ep_common *epb;
|
||||
struct sctp_association *assoc;
|
||||
|
@ -426,6 +441,8 @@ static int sctp_remaddr_seq_show(struct seq_file *seq, void *v)
|
|||
sctp_local_bh_disable();
|
||||
read_lock(&head->lock);
|
||||
sctp_for_each_hentry(epb, node, &head->chain) {
|
||||
if (!net_eq(sock_net(epb->sk), priv->net))
|
||||
continue;
|
||||
assoc = sctp_assoc(epb);
|
||||
list_for_each_entry(tsp, &assoc->peer.transport_addr_list,
|
||||
transports) {
|
||||
|
@ -489,14 +506,15 @@ static const struct seq_operations sctp_remaddr_ops = {
|
|||
};
|
||||
|
||||
/* Cleanup the proc fs entry for 'remaddr' object. */
|
||||
void sctp_remaddr_proc_exit(void)
|
||||
void sctp_remaddr_proc_exit(struct net *net)
|
||||
{
|
||||
remove_proc_entry("remaddr", proc_net_sctp);
|
||||
remove_proc_entry("remaddr", net->sctp.proc_net_sctp);
|
||||
}
|
||||
|
||||
static int sctp_remaddr_seq_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
return seq_open(file, &sctp_remaddr_ops);
|
||||
return seq_open_net(inode, file, &sctp_remaddr_ops,
|
||||
sizeof(struct seq_net_private));
|
||||
}
|
||||
|
||||
static const struct file_operations sctp_remaddr_seq_fops = {
|
||||
|
@ -506,11 +524,12 @@ static const struct file_operations sctp_remaddr_seq_fops = {
|
|||
.release = seq_release,
|
||||
};
|
||||
|
||||
int __init sctp_remaddr_proc_init(void)
|
||||
int __net_init sctp_remaddr_proc_init(struct net *net)
|
||||
{
|
||||
struct proc_dir_entry *p;
|
||||
|
||||
p = proc_create("remaddr", S_IRUGO, proc_net_sctp, &sctp_remaddr_seq_fops);
|
||||
p = proc_create("remaddr", S_IRUGO, net->sctp.proc_net_sctp,
|
||||
&sctp_remaddr_seq_fops);
|
||||
if (!p)
|
||||
return -ENOMEM;
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue