From: "Denis V. Lunev" <den@openvz.org>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, "Denis V. Lunev" <den@openvz.org>
Subject: [PATCH] [TCP]: Cleanup /proc/tcp[6] creation/removal.
Date: Tue, 8 Apr 2008 17:29:50 +0400 [thread overview]
Message-ID: <1207661392-13570-4-git-send-email-den@openvz.org> (raw)
In-Reply-To: <1207661318.7171.22.camel@iris.sw.ru>
Replace seq_open with seq_open_net and remove tcp_seq_release
completely. seq_release_net will do this job just fine.
Signed-off-by: Denis V. Lunev <den@openvz.org>
---
net/ipv4/tcp_ipv4.c | 41 +++++++----------------------------------
1 files changed, 7 insertions(+), 34 deletions(-)
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 0d0e220..287af10 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -2212,46 +2212,19 @@ static void tcp_seq_stop(struct seq_file *seq, void *v)
static int tcp_seq_open(struct inode *inode, struct file *file)
{
struct tcp_seq_afinfo *afinfo = PDE(inode)->data;
- struct seq_file *seq;
struct tcp_iter_state *s;
- struct net *net;
- int rc;
+ int err;
if (unlikely(afinfo == NULL))
return -EINVAL;
- s = kzalloc(sizeof(*s), GFP_KERNEL);
- if (!s)
- return -ENOMEM;
-
- rc = -ENXIO;
- net = get_proc_net(inode);
- if (!net)
- goto out_kfree;
+ err = seq_open_net(inode, file, &afinfo->seq_ops,
+ sizeof(struct tcp_iter_state));
+ if (err < 0)
+ return err;
+ s = ((struct seq_file *)file->private_data)->private;
s->family = afinfo->family;
- s->p.net = net;
-
- rc = seq_open(file, &afinfo->seq_ops);
- if (rc)
- goto out_put_net;
- seq = file->private_data;
- seq->private = s;
-out:
- return rc;
-out_put_net:
- put_net(net);
-out_kfree:
- kfree(s);
- goto out;
-}
-
-static int tcp_seq_release(struct inode *inode, struct file *file)
-{
- struct seq_file *seq = file->private_data;
-
- put_net(seq_file_net(seq));
- seq_release_private(inode, file);
return 0;
}
@@ -2264,7 +2237,7 @@ int tcp_proc_register(struct net *net, struct tcp_seq_afinfo *afinfo)
afinfo->seq_fops->open = tcp_seq_open;
afinfo->seq_fops->read = seq_read;
afinfo->seq_fops->llseek = seq_lseek;
- afinfo->seq_fops->release = tcp_seq_release;
+ afinfo->seq_fops->release = seq_release_net;
afinfo->seq_ops.start = tcp_seq_start;
afinfo->seq_ops.next = tcp_seq_next;
--
1.5.3.rc5
next prev parent reply other threads:[~2008-04-08 13:29 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-08 13:28 [TCP 0/6 net-2.6.26]: tcp_proc_register simplification Denis V. Lunev
2008-04-08 13:29 ` [PATCH] [TCP]: Replace struct net on tcp_iter_state with seq_net_private Denis V. Lunev
2008-04-08 13:29 ` [PATCH] [TCP]: No need to check afinfo != NULL in tcp_proc_(un)register Denis V. Lunev
2008-04-08 13:29 ` [PATCH] [TCP]: Move seq_ops from tcp_iter_state to tcp_seq_afinfo Denis V. Lunev
2008-04-08 13:29 ` Denis V. Lunev [this message]
2008-04-08 13:29 ` [PATCH] [TCP]: Place file operations directly into tcp_seq_afinfo Denis V. Lunev
2008-04-08 13:29 ` [PATCH] [TCP]: Remove owner from tcp_seq_afinfo Denis V. Lunev
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1207661392-13570-4-git-send-email-den@openvz.org \
--to=den@openvz.org \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).