2005-03-06 16:40:54

by G. Allen Morris III

[permalink] [raw]
Subject: Segfault in mountd -- fixed




-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs


2005-03-18 13:56:03

by G. Allen Morris III

[permalink] [raw]
Subject: Making /proc/fs/nfs/exports human friendly

On Sun, Mar 06, 2005 at 12:36:28PM -0500, G. Allen Morris III wrote:
> Neil,
>
> Neil the net rcp export cache should not be used directly for
> the /proc/nfs/exports output.
>
> I am pretty sure that all that needs to be done is to only display
> the rightmost element of the domain (client = strrchr(domain, ',')+1).
>
> I have a patch, but plan to clean it up before I send it to you.
>
> I just wanted to request comments on this problem for now.

Here is a patch. I don't expect this to be applied. I only wanted
feed back for now.

The last patch is to the nfs-utils to get the client name.

Rather than passing in the client name as a string it could be passed in
as an index to the correct entry in the domain.


===== fs/nfsd/export.c 1.95 vs edited =====
--- 1.95/fs/nfsd/export.c 2005-03-05 01:32:50 -05:00
+++ edited/fs/nfsd/export.c 2005-03-12 08:39:54 -05:00
@@ -95,6 +95,7 @@
}

static struct svc_expkey *svc_expkey_lookup(struct svc_expkey *, int);
+
static int expkey_parse(struct cache_detail *cd, char *mesg, int mlen)
{
/* client fsidtype fsid [path] */
@@ -280,6 +281,8 @@
dput(exp->ex_dentry);
mntput(exp->ex_mnt);
auth_domain_put(exp->ex_client);
+ if (exp->ex_client_name)
+ kfree(exp->ex_client_name);
kfree(exp);
}
}
@@ -342,7 +345,7 @@

static int svc_export_parse(struct cache_detail *cd, char *mesg, int mlen)
{
- /* client path expiry [flags anonuid anongid fsid] */
+ /* domain path expiry [flags anonuid anongid fsid client] */
char *buf;
int len;
int err;
@@ -382,6 +385,7 @@
exp.ex_client = dom;
exp.ex_mnt = nd.mnt;
exp.ex_dentry = nd.dentry;
+ exp.ex_client_name = NULL;

/* expiry */
err = -EINVAL;
@@ -416,6 +420,10 @@
if (err) goto out;
}

+ len = qword_get(&mesg, buf, PAGE_SIZE);
+ if (len) {
+ exp.ex_client_name = buf;
+ }
expp = svc_export_lookup(&exp, 1);
if (expp)
exp_put(expp);
@@ -455,6 +463,7 @@
seq_puts(m, ")\n");
return 0;
}
+
struct cache_detail svc_export_cache = {
.hash_size = EXPORT_HASHMAX,
.hash_table = export_table,
@@ -477,6 +486,17 @@
new->ex_client = item->ex_client;
new->ex_dentry = dget(item->ex_dentry);
new->ex_mnt = mntget(item->ex_mnt);
+ new->ex_client_name = NULL;
+ if (item->ex_client_name) {
+ int len;
+ char *s;
+
+ len = strlen(item->ex_client_name);
+ s = kmalloc(len+1, GFP_KERNEL);
+ if (s)
+ strcpy(s, item->ex_client_name);
+ new->ex_client_name = s;
+ }
}

static inline void svc_export_update(struct svc_export *new, struct svc_export *item)
@@ -485,6 +505,13 @@
new->ex_anon_uid = item->ex_anon_uid;
new->ex_anon_gid = item->ex_anon_gid;
new->ex_fsid = item->ex_fsid;
+ if (new->ex_client_name && item->ex_client_name) {
+ if (strcmp(new->ex_client_name, item->ex_client_name)) {
+ printk("svc_export_update both %s ~= %s\n", new->ex_client_name, item->ex_client_name);
+ }
+ } else if (item->ex_client_name) {
+ printk("svc_export_update new %p item %p\n", new->ex_client_name, item->ex_client_name);
+ }
}

static DefineSimpleCacheLookup(svc_export,1) /* allow inplace updates */
@@ -1037,6 +1064,42 @@
seq_printf(m, "%sanongid=%d", first++?",":"", anong);
}

+static int svc_export_display(struct seq_file *m,
+ struct cache_detail *cd,
+ struct cache_head *h)
+{
+ struct svc_export *exp ;
+
+ if (h ==NULL) {
+ seq_puts(m, "#path domain(flags)\n");
+ return 0;
+ }
+ exp = container_of(h, struct svc_export, h);
+ seq_path(m, exp->ex_mnt, exp->ex_dentry, " \t\n\\");
+ seq_putc(m, '\t');
+ if (exp->ex_client_name) {
+ seq_escape(m, exp->ex_client_name, " \t\n\\");
+ } else {
+ seq_escape(m, exp->ex_client->name, " \t\n\\");
+ }
+ seq_putc(m, '(');
+ if (test_bit(CACHE_VALID, &h->flags) &&
+ !test_bit(CACHE_NEGATIVE, &h->flags))
+ exp_flags(m, exp->ex_flags, exp->ex_fsid,
+ exp->ex_anon_uid, exp->ex_anon_gid);
+ seq_puts(m, ") #");
+ {
+ struct auth_domain *dom;
+ dom = auth_domain_find(exp->ex_client->name);
+ if (dom) {
+ auth_unix_list(m, dom);
+ auth_domain_put(dom);
+ }
+ }
+ seq_putc(m, '\n');
+ return 0;
+}
+
static int e_show(struct seq_file *m, void *p)
{
struct cache_head *cp = p;
@@ -1054,7 +1117,7 @@
if (cache_check(&svc_export_cache, &exp->h, NULL))
return 0;
if (cache_put(&exp->h, &svc_export_cache)) BUG();
- return svc_export_show(m, &svc_export_cache, cp);
+ return svc_export_display(m, &svc_export_cache, cp);
}

struct seq_operations nfs_exports_op = {
===== net/sunrpc/sunrpc_syms.c 1.35 vs edited =====
--- 1.35/net/sunrpc/sunrpc_syms.c 2005-03-05 01:32:49 -05:00
+++ edited/net/sunrpc/sunrpc_syms.c 2005-03-09 19:02:17 -05:00
@@ -107,6 +107,7 @@
EXPORT_SYMBOL(auth_unix_add_addr);
EXPORT_SYMBOL(auth_unix_forget_old);
EXPORT_SYMBOL(auth_unix_lookup);
+EXPORT_SYMBOL(auth_unix_list);
EXPORT_SYMBOL(cache_check);
EXPORT_SYMBOL(cache_flush);
EXPORT_SYMBOL(cache_purge);
===== net/sunrpc/svcauth_unix.c 1.37 vs edited =====
--- 1.37/net/sunrpc/svcauth_unix.c 2005-03-05 01:32:49 -05:00
+++ edited/net/sunrpc/svcauth_unix.c 2005-03-11 02:28:57 -05:00
@@ -296,6 +296,38 @@
return 0;
}

+int auth_unix_list(struct seq_file *m, struct auth_domain *dom)
+{
+ int n;
+ struct in_addr addr;
+
+ if (dom->flavour != RPC_AUTH_UNIX)
+ return 1;
+ for (n = 0; n < ip_map_cache.hash_size; n++) {
+ if (ip_map_cache.hash_table[n]) {
+ struct cache_head *h;
+ struct ip_map *im;
+ char *udom = "";
+
+ h = ip_map_cache.hash_table[n];
+ im = container_of(h, struct ip_map, h);
+ if (test_bit(CACHE_VALID, &h->flags) &&
+ !test_bit(CACHE_NEGATIVE, &h->flags))
+ udom = im->m_client->h.name;
+ if (!strcmp(udom, dom->name)) {
+ addr = im->m_addr;
+ seq_printf(m, " %d.%d.%d.%d",
+ htonl(addr.s_addr) >> 24 & 0xff,
+ htonl(addr.s_addr) >> 16 & 0xff,
+ htonl(addr.s_addr) >> 8 & 0xff,
+ htonl(addr.s_addr) >> 0 & 0xff
+ );
+ }
+ }
+ }
+ return 0;
+}
+
struct auth_domain *auth_unix_lookup(struct in_addr addr)
{
struct ip_map key, *ipm;
Index: support/nfs/nfsexport.c
===================================================================
RCS file: /cvsroot/nfs/nfs-utils/support/nfs/nfsexport.c,v
retrieving revision 1.4
diff -u -r1.4 nfsexport.c
--- support/nfs/nfsexport.c 4 Aug 2003 03:14:50 -0000 1.4
+++ support/nfs/nfsexport.c 18 Mar 2005 13:44:05 -0000
@@ -48,6 +48,7 @@
qword_printint(f, exp->ex_anon_uid);
qword_printint(f, exp->ex_anon_gid);
qword_printint(f, exp->ex_dev);
+ qword_print(f, exp->ex_client);
} else
qword_printint(f, 1);


Attachments:
(No filename) (7.75 kB)
signature.asc (189.00 B)
Digital signature
Download all attachments

2005-03-06 17:36:39

by G. Allen Morris III

[permalink] [raw]
Subject: /proc/fs/nfs/exports Broken

Neil,

Neil the net rcp export cache should not be used directly for
the /proc/nfs/exports output.

I am pretty sure that all that needs to be done is to only display
the rightmost element of the domain (client = strrchr(domain, ',')+1).

I have a patch, but plan to clean it up before I send it to you.

I just wanted to request comments on this problem for now.

G. Allen Morris III <[email protected]>



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

2005-03-06 20:30:55

by G. Allen Morris III

[permalink] [raw]
Subject: Re: /proc/fs/nfs/exports Broken

On Sun, Mar 06, 2005 at 12:36:28PM -0500, G. Allen Morris III wrote:
> Neil,
>
> Neil the net rcp export cache should not be used directly for
> the /proc/nfs/exports output.
>
> I am pretty sure that all that needs to be done is to only display
> the rightmost element of the domain (client = strrchr(domain, ',')+1).
>
> I have a patch, but plan to clean it up before I send it to you.
>
> I just wanted to request comments on this problem for now.

I can see that I am very wrong about how simple this is. I think that
extra data or code is needed to solve this problem.

Here are some questions:
1. do we need nfsd/exports at all? (No ones seems to have noticed that
the information it gives is not very human readable.)
2. If yes. What is it for? It seems to me it is needed to show what
export a given IP is mapped to.
3. Should exportfs have a switch that to display the kernel export
cache is some nice format or formats.

Allen Morris <[email protected]>


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

2005-03-06 23:24:52

by NeilBrown

[permalink] [raw]
Subject: Re: /proc/fs/nfs/exports Broken

On Sunday March 6, [email protected] wrote:
> On Sun, Mar 06, 2005 at 12:36:28PM -0500, G. Allen Morris III wrote:
> > Neil,
> >
> > Neil the net rcp export cache should not be used directly for
> > the /proc/nfs/exports output.
> >
> > I am pretty sure that all that needs to be done is to only display
> > the rightmost element of the domain (client = strrchr(domain, ',')+1).
> >
> > I have a patch, but plan to clean it up before I send it to you.
> >
> > I just wanted to request comments on this problem for now.
>
> I can see that I am very wrong about how simple this is. I think that
> extra data or code is needed to solve this problem.

You haven't been very clear about what the problem is, but I think I
can guess.

If a particular client (identified by IP address) maps to several
different identifiers that are in /etc/exports
e.g. '*' and 'W.X.Y.Z' and 'test-host.my.domain' and '@my-netgroup'
then the effective name for that client as listed in /etc/exports will
be the combination of all the identifiers, separated by commas.
In this example
*,W.X.Y.Z,test-host.by.domain,@my-netgroup

This apparently bothers you....

>
> Here are some questions:
> 1. do we need nfsd/exports at all? (No ones seems to have noticed that
> the information it gives is not very human readable.)

Yes. Anyone using an older nfs-utils or running without /proc/fs/nfsd
needs it.

> 2. If yes. What is it for? It seems to me it is needed to show what
> export a given IP is mapped to.

Well, it is useful to have a quick look at what is exported, and it
allows olders nfs-utils to iterate through all exports known to the
kernel and remove them.

> 3. Should exportfs have a switch that to display the kernel export
> cache is some nice format or formats.

I don't think there is anything particularly wrong with the format
(once you understand it). Can you convince me otherwise?

NeilBrown


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs