From nobody@FreeBSD.org  Thu Jun 28 15:20:47 2007
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id 28F5D16A41F
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 28 Jun 2007 15:20:47 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [69.147.83.33])
	by mx1.freebsd.org (Postfix) with ESMTP id 016B413C44C
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 28 Jun 2007 15:20:47 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id l5SFKkFK035559
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 28 Jun 2007 15:20:46 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id l5SFKkh6035558;
	Thu, 28 Jun 2007 15:20:46 GMT
	(envelope-from nobody)
Message-Id: <200706281520.l5SFKkh6035558@www.freebsd.org>
Date: Thu, 28 Jun 2007 15:20:46 GMT
From: "Brian A. Seklecki" <bseklecki@collaborativefusion.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: NFS Abstraction: mountd(8) binding
X-Send-Pr-Version: www-3.0

>Number:         114097
>Category:       bin
>Synopsis:       [patch] [nfs] NFS Abstraction: mountd(8) binding
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    matteo
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jun 28 15:30:03 GMT 2007
>Closed-Date:    Sun Aug 31 19:44:40 UTC 2008
>Last-Modified:  Sun Aug 31 19:44:40 UTC 2008
>Originator:     Brian A. Seklecki
>Release:        6.x / i386
>Organization:
Collaborative Fusion, Inc.
>Environment:
FreeBSD rampage 6.2-RELEASE-p3 FreeBSD 6.2-RELEASE-p3 #0: Thu Mar 22 21:08:30 EDT 2007     root@rampage:/mnt2/usr/obj/export/RELENG_6_2/src/sys/SMP  i386

>Description:

Match rpcbind(8) / nfsd(8) behavior for explicit local source address
binding of UDP/TCP Sockets:

See original ticket:

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


>How-To-Repeat:
Create strict service VIP abstraction on an NFS server behind a Firewall.
>Fix:
A similar patch that sets sin.sin_addr.s_addr in a for individual sockets
for each instance of "-h <ip>" parsed by getopt() in argcv[]:

-----

My basic patch to fix in my lab environment:

--- /usr/src/usr.sbin/mountd/mountd.c   Tue Dec 19 04:14:02 2006
+++ mountd.c    Wed Jun 27 22:15:32 2007
@@ -242,6 +242,10 @@
 int debug = 0;
 #endif
 
+int nhosts = 0;
+char **hosts = NULL;
+
+
 /*
  * Mountd server for NFS mount protocol as described in:
  * NFS: Network File System Protocol Specification, RFC1094, Appendix A
@@ -290,7 +294,7 @@
                        errx(1, "NFS server is not available or
loadable");
        }
 
-       while ((c = getopt(argc, argv, "2dlnp:r")) != -1)
+       while ((c = getopt(argc, argv, "2dlnp:rh")) != -1)
                switch (c) {
                case '2':
                        force_v2 = 1;
@@ -314,6 +318,16 @@
                            svcport == 0 || svcport >= IPPORT_MAX)
                                usage();
                        break;
+                case 'h':
+                        ++nhosts;
+                        hosts = realloc(hosts, nhosts * sizeof(char
*));
+                        if (hosts == NULL)
+                                errx(1, "Out of memory");
+                        hosts[nhosts - 1] = strdup(optarg);
+                        if (hosts[nhosts - 1] == NULL)
+                                errx(1, "Out of memory");
+                        break;
+
                default:
                        usage();
                };
@@ -397,6 +411,12 @@
                sin6.sin6_len = sizeof(struct sockaddr_in6);
                sin6.sin6_family = AF_INET6;
                sin6.sin6_port = htons(svcport);
+               struct  in_addr src_t;
+               fprintf(stdout, "%d \n", nhosts);
+                inet_aton(hosts[nhosts - 1], &src_t);
+                //inet_aton("192.168.3.58", &src_t);
+                sin.sin_addr.s_addr = src_t.s_addr;
+ 
        }
        if (udpsock != -1 && udpconf != NULL) {
                if (svcport != 0) {
@@ -540,7 +560,7 @@
 usage()
 {
        fprintf(stderr,
-               "usage: mountd [-2] [-d] [-l] [-n] [-p <port>] [-r] "
+               "usage: mountd [-2] [-d] [-l] [-n] [-p <port>] [-r]"
+               "[-h <bindip>] [export_file]\n");
        exit(1);
 }


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->matteo 
Responsible-Changed-By: matteo 
Responsible-Changed-When: Fri Jun 29 06:43:54 UTC 2007 
Responsible-Changed-Why:  
I'll take care of this PR. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=114097 
State-Changed-From-To: open->feedback 
State-Changed-By: matteo 
State-Changed-When: Mon Sep 17 13:32:33 UTC 2007 
State-Changed-Why:  
A patch for -CURRENT is available at http://people.freebsd.org/~matteo/diff/mountd.c.diff 
Could you pleaste test it? Thanks in advance 

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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/114097: commit references a PR
Date: Sat, 20 Oct 2007 11:25:42 +0000 (UTC)

 matteo      2007-10-20 11:25:34 UTC
 
   FreeBSD src repository
 
   Modified files:
     usr.sbin/mountd      mountd.8 mountd.c 
   Log:
   Add the -h <bindip> option to mountd, similar to the one in nfsd(8)
   
   -h bindip
   Specify specific IP addresses to bind to for TCP and UDP requests.
   This option may be specified multiple times.  If no -h option is
   specified, mountd will bind to INADDR_ANY.  Note that when specifying
   IP addresses with -h, mountd will automatically add 127.0.0.1 and if
   IPv6 is enabled, ::1 to the list.
   
   PR:             bin/114097
   Reviewed by:    pjd (an eariler version of the patch)
   MFC after:      1 week
   
   Revision  Changes    Path
   1.31      +19 -1     src/usr.sbin/mountd/mountd.8
   1.95      +321 -159  src/usr.sbin/mountd/mountd.c
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: feedback->patched 
State-Changed-By: matteo 
State-Changed-When: Sab 3 Nov 2007 16:07:16 UTC 
State-Changed-Why:  
Fix was committed to HEAD 

http://www.freebsd.org/cgi/query-pr.cgi?pr=114097 
State-Changed-From-To: patched->closed 
State-Changed-By: matteo 
State-Changed-When: Dom 3 Feb 2008 10:46:33 UTC 
State-Changed-Why:  
MFC'ed to RELENG_7 


http://www.freebsd.org/cgi/query-pr.cgi?pr=114097 
State-Changed-From-To: closed->patched 
State-Changed-By: linimon 
State-Changed-When: Tue Mar 18 06:51:58 UTC 2008 
State-Changed-Why:  
Submitter has requested an MFC to RELENG_6.  Is anyone interested 
in looking after this? 

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

From: "Brian A. Seklecki" <bseklecki@collaborativefusion.com>
To: linimon@FreeBSD.org, bug-followup@freebsd.org
Cc: matteo@FreeBSD.org
Subject: Re: bin/114097: [patch] [nfs] NFS Abstraction: mountd(8) binding
Date: Mon, 28 Apr 2008 09:29:44 -0400

 The latest version from -HEAD compiles just fine in RELENG_6_3.  It
 would be great to see this functionality in 6.4-R ~BAS
 
 On Tue, 2008-03-18 at 06:52 +0000, linimon@FreeBSD.org wrote:
 > Synopsis: [patch] [nfs] NFS Abstraction: mountd(8) binding
 > 
 > State-Changed-From-To: closed->patched
 > State-Changed-By: linimon
 > State-Changed-When: Tue Mar 18 06:51:58 UTC 2008
 > State-Changed-Why: 
 > Submitter has requested an MFC to RELENG_6.  Is anyone interested
 > in looking after this?
 > 
 > http://www.freebsd.org/cgi/query-pr.cgi?pr=114097
 -- 
 Brian A. Seklecki <bseklecki@collaborativefusion.com>
 Collaborative Fusion, Inc.
 

From: "Brian A. Seklecki" <bseklecki@collaborativefusion.com>
To: bug-followup@freebsd.org, matteo@FreeBSD.org, linimon@FreeBSD.org
Cc:  
Subject: Re: bin/114097: [patch] [nfs] NFS Abstraction: mountd(8) binding
Date: Mon, 19 May 2008 10:38:19 -0400

 Shall I open a second ticket for the RFP/MFC, or can we safely slip this
 into RELENG_6 before RELENG_6_4 ?
 
 I'm willing to bribe a developer at this point.  Bottles of single-malt,
 maybe an Islay, to be offered.
 
 ~BAS
 
 On Mon, 2008-04-28 at 09:29 -0400, Brian A. Seklecki wrote:
 > The latest version from -HEAD compiles just fine in RELENG_6_3.  It
 > would be great to see this functionality in 6.4-R ~BAS
 > 
 > On Tue, 2008-03-18 at 06:52 +0000, linimon@FreeBSD.org wrote:
 > > Synopsis: [patch] [nfs] NFS Abstraction: mountd(8) binding
 > > 
 > > State-Changed-From-To: closed->patched
 > > State-Changed-By: linimon
 > > State-Changed-When: Tue Mar 18 06:51:58 UTC 2008
 > > State-Changed-Why: 
 > > Submitter has requested an MFC to RELENG_6.  Is anyone interested
 > > in looking after this?
 > > 
 > > http://www.freebsd.org/cgi/query-pr.cgi?pr=114097
 -- 
 Brian A. Seklecki <bseklecki@collaborativefusion.com>
 Collaborative Fusion, Inc.
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/114097: commit references a PR
Date: Tue, 26 Aug 2008 12:05:53 +0000 (UTC)

 matteo      2008-08-26 12:05:37 UTC
 
   FreeBSD src repository
 
   Modified files:        (Branch: RELENG_6)
     usr.sbin/mountd      mountd.8 mountd.c 
   Log:
   SVN rev 182192 on 2008-08-26 12:05:37Z by matteo
   
   MFC r172827 r173056
   
   Add the -h <bindip> option to mountd, similar to the one in nfsd(8)
   
   -h bindip
   Specify specific IP addresses to bind to for TCP and UDP requests.
   This option may be specified multiple times.  If no -h option is
   specified, mountd will bind to INADDR_ANY.  Note that when specifying
   IP addresses with -h, mountd will automatically add 127.0.0.1 and if
   IPv6 is enabled, ::1 to the list.
   
   PR:             bin/114097
   
   Revision  Changes    Path
   1.27.8.2  +19 -1     src/usr.sbin/mountd/mountd.8
   1.81.2.8  +321 -159  src/usr.sbin/mountd/mountd.c
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: patched->closed 
State-Changed-By: matteo 
State-Changed-When: Dom 31 Ago 2008 19:44:22 UTC 
State-Changed-Why:  
Committed to RELENG_6, 7 and HEAD 

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