From danny@cs.huji.ac.il  Fri Jul  7 08:18:37 2006
Return-Path: <danny@cs.huji.ac.il>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 369D316A4DA
	for <FreeBSD-gnats-submit@freebsd.org>; Fri,  7 Jul 2006 08:18:37 +0000 (UTC)
	(envelope-from danny@cs.huji.ac.il)
Received: from cs1.cs.huji.ac.il (cs1.cs.huji.ac.il [132.65.16.10])
	by mx1.FreeBSD.org (Postfix) with ESMTP id A023743D5A
	for <FreeBSD-gnats-submit@freebsd.org>; Fri,  7 Jul 2006 08:18:36 +0000 (GMT)
	(envelope-from danny@cs.huji.ac.il)
Received: from bsd.cs.huji.ac.il ([132.65.16.112])
	by cs1.cs.huji.ac.il with esmtp
	id 1FylXn-000BCt-1A
	for FreeBSD-gnats-submit@freebsd.org; Fri, 07 Jul 2006 11:18:35 +0300
Received: from danny by bsd.cs.huji.ac.il with local (Exim 4.60)
	(envelope-from <danny@cs.huji.ac.il>)
	id 1FylXm-000Dfo-VU
	for FreeBSD-gnats-submit@freebsd.org; Fri, 07 Jul 2006 11:18:34 +0300
Message-Id: <E1FylXm-000Dfo-VU@bsd.cs.huji.ac.il>
Date: Fri, 07 Jul 2006 11:18:34 +0300
From: Danny Braniss <danny@cs.huji.ac.il>
Reply-To: Danny Braniss <danny@cs.huji.ac.il>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: mountd reload fails
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         99873
>Category:       bin
>Synopsis:       [patch] mountd(8) reload fails
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    rodrigc
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Jul 07 08:20:13 GMT 2006
>Closed-Date:    Mon Sep 25 19:38:05 GMT 2006
>Last-Modified:  Mon Sep 25 19:38:05 GMT 2006
>Originator:     Danny Braniss
>Release:        FreeBSD 6.1-STABLE
>Organization:
>Environment:
System: FreeBSD bsd 6.1-STABLE FreeBSD 6.1-STABLE #6: Fri Jun 16 12:50:38 IDT 2006 danny@bsd:/r+d/obj/bsd/r+d/6.1/src/sys/HUJI amd64

>Description:
	/usr/src/usr.sbin/mountd/mountd.c
	in get_exportlist():
	The loop to un-export all exported file systems does not
	increment the fsp pointer when continue is called, thus
	not realy unexporting all files, causing problems when
	updating. This uncovered another problem, with the very
	first if(..) in the loop.
>How-To-Repeat:
	the problem appears when you have a nfs mounted file system
	preferably before local file systems, hence on a nfs-root
	it's immediately noticed.
	type '/etc/rc.d/mountd reload' and see your local exported
	files/filesystems unexported.
>Fix:
	one suggestion:

--- /r+d/6.1/src/usr.sbin/mountd/mountd.c       Fri Jun 16 09:42:42 2006
+++ ./mountd.c  Fri Jul  7 11:03:40 2006
@@ -1012,7 +1012,7 @@
                build_iovec(&iov, &iovlen, "export", &export, sizeof(export));
        }
 
-       for (i = 0; i < num; i++) {
+       for (i = 0; i < num; i++, fsp++) {
                if (getvfsbyname(fsp->f_fstypename, &vfc) != 0) {
                        syslog(LOG_ERR, "getvfsbyname() failed for %s",
                            fsp->f_fstypename);
@@ -1049,7 +1049,6 @@
                            "can't delete exports for %s: %m",
                            fsp->f_mntonname);
                }
-               fsp++;
        }
 
        if (iov != NULL) {
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->rodrigc 
Responsible-Changed-By: rodrigc 
Responsible-Changed-When: Fri Jul 7 19:27:38 UTC 2006 
Responsible-Changed-Why:  
Does this patch, which is a slight variation of your patch work for you? 

Index: mountd.c 
=================================================================== 
RCS file: /home/ncvs/src/usr.sbin/mountd/mountd.c,v 
retrieving revision 1.87 
diff -u -u -r1.87 mountd.c 
--- mountd.c	6 Jun 2006 21:56:49 -0000	1.87 
+++ mountd.c	7 Jul 2006 19:26:43 -0000 
@@ -963,7 +963,7 @@ 
struct export_args export; 
struct dirlist *dirhead; 
struct iovec *iov; 
-	struct statfs fsb, *fsp; 
+	struct statfs fsb, *fsp, *mntbufp; 
struct xucred anon; 
struct xvfsconf vfc; 
char *cp, *endcp, *dirp, *hst, *usr, *dom, savedc; 
@@ -1001,10 +1001,9 @@ 
/* 
* And delete exports that are in the kernel for all local 
* filesystems. 
-	 * XXX: Should know how to handle all local exportable filesystems 
-	 *      instead of just "ufs". 
+	 * XXX: Should know how to handle all local exportable filesystems. 
*/ 
-	num = getmntinfo(&fsp, MNT_NOWAIT); 
+	num = getmntinfo(&mntbufp, MNT_NOWAIT); 

if (num > 0) { 
build_iovec(&iov, &iovlen, "fstype", NULL, 0); 
@@ -1016,6 +1015,7 @@ 
} 

for (i = 0; i < num; i++) { 
+		fsp = &mntbufp[i]; 
if (getvfsbyname(fsp->f_fstypename, &vfc) != 0) { 
syslog(LOG_ERR, "getvfsbyname() failed for %s", 
fsp->f_fstypename); 
@@ -1052,7 +1052,6 @@ 
"can't delete exports for %s: %m %s", 
fsp->f_mntonname, errmsg); 
} 
-		fsp++; 
} 

if (iov != NULL) { 

http://www.freebsd.org/cgi/query-pr.cgi?pr=99873 
State-Changed-From-To: open->feedback 
State-Changed-By: rodrigc 
State-Changed-When: Fri Jul 7 19:30:15 UTC 2006 
State-Changed-Why:  


http://www.freebsd.org/cgi/query-pr.cgi?pr=99873 

From: Danny Braniss <danny@cs.huji.ac.il>
To: Craig Rodrigues <rodrigc@FreeBSD.org>
Cc: bug-followup@FreeBSD.org
Subject: Re: bin/99873: [patch] mountd(8) reload fails 
Date: Sat, 08 Jul 2006 08:44:23 +0300

 > Synopsis: [patch] mountd(8) reload fails
 > 
 > State-Changed-From-To: open->feedback
 > State-Changed-By: rodrigc
 > State-Changed-When: Fri Jul 7 19:30:15 UTC 2006
 > State-Changed-Why: 
 > 
 > 
 > http://www.freebsd.org/cgi/query-pr.cgi?pr=99873
 
 the patch will work, but adds a variable for no real reason.
 mountd is already a quiet offuscated piece of code, simplifying
 it would be niece.
 
 danny
 
 
 

From: Bruce M Simpson <bms@incunabulum.net>
To: freebsd-gnats-submit@FreeBSD.org
Cc:  
Subject: Re: bin/99873: [patch] mountd(8) reload fails
Date: Mon, 25 Sep 2006 19:10:50 +0100

 This patch looks good, why don't you commit it?
State-Changed-From-To: feedback->closed 
State-Changed-By: rodrigc 
State-Changed-When: Mon Sep 25 19:36:39 UTC 2006 
State-Changed-Why:  
Committed in: 
HEAD: mountd.c, 1.88 
RELENG_6: mountd.c, 1.81.2.4 

Reminded by:	bms 

http://www.freebsd.org/cgi/query-pr.cgi?pr=99873 
>Unformatted:
