From: NeilBrown <neilb@suse.de>
To: Andrew Morton <akpm@osdl.org>
Cc: nfs@lists.sourceforge.net, linux-kernel@vger.kernel.org
Subject: [PATCH 008 of 9] knfsd: Define new nfsdfs file: portlist - contains list of ports.
Date: Tue, 25 Jul 2006 11:55:02 +1000 [thread overview]
Message-ID: <1060725015502.21995@suse.de> (raw)
In-Reply-To: 20060725114207.21779.patches@notabene
This file will list all ports that nfsd has open.
Default when TCP enabled will be
ipv4 udp 0.0.0.0 2049
ipv4 tcp 0.0.0.0 2049
Later, the list of ports will be settable.
'portlist' chosen rather than 'ports', to avoid unnecessary confusion with
non-mainline patches which created 'ports' with different semantics.
Signed-off-by: Neil Brown <neilb@suse.de>
### Diffstat output
./fs/nfsd/nfsctl.c | 19 +++++++++++++++++++
./include/linux/sunrpc/svcsock.h | 1 +
./net/sunrpc/svcsock.c | 37 +++++++++++++++++++++++++++++++++++++
3 files changed, 57 insertions(+)
diff .prev/fs/nfsd/nfsctl.c ./fs/nfsd/nfsctl.c
--- .prev/fs/nfsd/nfsctl.c 2006-07-24 15:17:36.000000000 +1000
+++ ./fs/nfsd/nfsctl.c 2006-07-24 15:21:44.000000000 +1000
@@ -27,6 +27,7 @@
#include <linux/nfs.h>
#include <linux/nfsd_idmap.h>
#include <linux/sunrpc/svc.h>
+#include <linux/sunrpc/svcsock.h>
#include <linux/nfsd/nfsd.h>
#include <linux/nfsd/cache.h>
#include <linux/nfsd/xdr.h>
@@ -51,6 +52,7 @@ enum {
NFSD_Fh,
NFSD_Threads,
NFSD_Versions,
+ NFSD_Ports,
/*
* The below MUST come last. Otherwise we leave a hole in nfsd_files[]
* with !CONFIG_NFSD_V4 and simple_fill_super() goes oops
@@ -74,6 +76,7 @@ static ssize_t write_getfs(struct file *
static ssize_t write_filehandle(struct file *file, char *buf, size_t size);
static ssize_t write_threads(struct file *file, char *buf, size_t size);
static ssize_t write_versions(struct file *file, char *buf, size_t size);
+static ssize_t write_ports(struct file *file, char *buf, size_t size);
#ifdef CONFIG_NFSD_V4
static ssize_t write_leasetime(struct file *file, char *buf, size_t size);
static ssize_t write_recoverydir(struct file *file, char *buf, size_t size);
@@ -90,6 +93,7 @@ static ssize_t (*write_op[])(struct file
[NFSD_Fh] = write_filehandle,
[NFSD_Threads] = write_threads,
[NFSD_Versions] = write_versions,
+ [NFSD_Ports] = write_ports,
#ifdef CONFIG_NFSD_V4
[NFSD_Leasetime] = write_leasetime,
[NFSD_RecoveryDir] = write_recoverydir,
@@ -419,6 +423,20 @@ static ssize_t write_versions(struct fil
return len;
}
+static ssize_t write_ports(struct file *file, char *buf, size_t size)
+{
+ /* for now, ignore what was written and just
+ * return known ports
+ * AF proto address port
+ */
+ int len = 0;
+ lock_kernel();
+ if (nfsd_serv)
+ len = svc_sock_names(buf, nfsd_serv);
+ unlock_kernel();
+ return len;
+}
+
#ifdef CONFIG_NFSD_V4
extern time_t nfs4_leasetime(void);
@@ -482,6 +500,7 @@ static int nfsd_fill_super(struct super_
[NFSD_Fh] = {"filehandle", &transaction_ops, S_IWUSR|S_IRUSR},
[NFSD_Threads] = {"threads", &transaction_ops, S_IWUSR|S_IRUSR},
[NFSD_Versions] = {"versions", &transaction_ops, S_IWUSR|S_IRUSR},
+ [NFSD_Ports] = {"portlist", &transaction_ops, S_IWUSR|S_IRUGO},
#ifdef CONFIG_NFSD_V4
[NFSD_Leasetime] = {"nfsv4leasetime", &transaction_ops, S_IWUSR|S_IRUSR},
[NFSD_RecoveryDir] = {"nfsv4recoverydir", &transaction_ops, S_IWUSR|S_IRUSR},
diff .prev/include/linux/sunrpc/svcsock.h ./include/linux/sunrpc/svcsock.h
--- .prev/include/linux/sunrpc/svcsock.h 2006-07-24 15:21:44.000000000 +1000
+++ ./include/linux/sunrpc/svcsock.h 2006-07-24 15:21:44.000000000 +1000
@@ -61,5 +61,6 @@ int svc_recv(struct svc_serv *, struct
int svc_send(struct svc_rqst *);
void svc_drop(struct svc_rqst *);
void svc_sock_update_bufs(struct svc_serv *serv);
+int svc_sock_names(char *buf, struct svc_serv *serv);
#endif /* SUNRPC_SVCSOCK_H */
diff .prev/net/sunrpc/svcsock.c ./net/sunrpc/svcsock.c
--- .prev/net/sunrpc/svcsock.c 2006-07-24 15:21:44.000000000 +1000
+++ ./net/sunrpc/svcsock.c 2006-07-24 15:21:44.000000000 +1000
@@ -429,6 +429,43 @@ out:
}
/*
+ * Report socket names for nfsdfs
+ */
+int one_sock_name(char *buf, struct svc_sock *svsk)
+{
+ int len;
+ switch(svsk->sk_sk->sk_family) {
+ case AF_INET:
+ len = sprintf(buf, "ipv4 %s %u.%u.%u.%u %d\n",
+ svsk->sk_sk->sk_protocol==IPPROTO_UDP?
+ "udp" : "tcp",
+ NIPQUAD(inet_sk(svsk->sk_sk)->rcv_saddr),
+ inet_sk(svsk->sk_sk)->num);
+ break;
+ default: len = sprintf(buf, "*unknown-%d*\n",
+ svsk->sk_sk->sk_family);
+ }
+ return len;
+}
+
+int
+svc_sock_names(char *buf, struct svc_serv *serv)
+{
+ struct svc_sock *svsk;
+ int len = 0;
+
+ if (!serv) return 0;
+ spin_lock(&serv->sv_lock);
+ list_for_each_entry(svsk, &serv->sv_permsocks, sk_list) {
+ int onelen = one_sock_name(buf+len, svsk);
+ len += onelen;
+ }
+ spin_unlock(&serv->sv_lock);
+ return len;
+}
+EXPORT_SYMBOL(svc_sock_names);
+
+/*
* Check input queue length
*/
static int
next prev parent reply other threads:[~2006-07-25 1:58 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-07-25 1:54 [PATCH 000 of 9] knfsd: Introduction NeilBrown
2006-07-25 1:54 ` [PATCH 001 of 9] knfsd: knfsd: Add some missing newlines in printks NeilBrown
2006-07-25 1:54 ` [PATCH 002 of 9] knfsd: knfsd: Remove an unused variable from e_show() NeilBrown
2006-07-25 4:10 ` Josef Sipek
2006-07-25 4:20 ` Neil Brown
2006-07-25 4:24 ` [NFS] " Greg Banks
2006-07-25 4:32 ` Greg Banks
2006-07-25 4:36 ` Neil Brown
2006-07-25 5:53 ` Greg Banks
2006-07-25 1:54 ` [PATCH 003 of 9] knfsd: knfsd: Remove an unused variable from auth_unix_lookup() NeilBrown
2006-07-25 1:54 ` [PATCH 004 of 9] knfsd: Add a callback for when last rpc thread finishes NeilBrown
2006-07-25 1:54 ` [PATCH 005 of 9] knfsd: Be more selective in which sockets lockd listens on NeilBrown
2006-07-26 19:17 ` [NFS] " J. Bruce Fields
2006-07-28 2:32 ` Neil Brown
2006-07-25 1:54 ` [PATCH 006 of 9] knfsd: Remove nfsd_versbits as intermediate storage for desired versions NeilBrown
2006-07-26 19:34 ` [NFS] " J. Bruce Fields
2006-07-25 1:54 ` [PATCH 007 of 9] knfsd: Separate out some parts of nfsd_svc, which start nfs servers NeilBrown
2006-07-26 6:42 ` Andrew Morton
2006-07-25 1:55 ` NeilBrown [this message]
2006-07-25 1:55 ` [PATCH 009 of 9] knfsd: Allow sockets to be passed to nfsd via 'portlist' NeilBrown
2006-07-26 6:53 ` Andrew Morton
2006-07-26 20:41 ` [NFS] " J. Bruce Fields
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=1060725015502.21995@suse.de \
--to=neilb@suse.de \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nfs@lists.sourceforge.net \
/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).