2007-03-12 15:58:49

by Talpey, Thomas

[permalink] [raw]
Subject: nfs-utils patch for mount-reserved-port

Only create a mount-time reserved port socket for kernels
which require it (pre-2.1.32/nfs_mount_version 1).

Signed-off-by: Tom Talpey <[email protected]>

Index: nfs-utils-1.0.12/utils/mount/nfsmount.c
===================================================================
--- nfs-utils-1.0.12.orig/utils/mount/nfsmount.c
+++ nfs-utils-1.0.12/utils/mount/nfsmount.c
@@ -1120,20 +1120,22 @@ noauth_flavors:
#endif
}

- /* create nfs socket for kernel */
-
- if (nfs_pmap->pm_prot == IPPROTO_TCP)
- fsock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
- else
- fsock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
- if (fsock < 0) {
- perror(_("nfs socket"));
- goto fail;
- }
- if (bindresvport(fsock, 0) < 0) {
- perror(_("nfs bindresvport"));
- goto fail;
+ if (nfs_mount_version == 1) {
+ /* create nfs socket for kernel */
+ if (nfs_pmap->pm_prot == IPPROTO_TCP)
+ fsock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
+ else
+ fsock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
+ if (fsock < 0) {
+ perror(_("nfs socket"));
+ goto fail;
+ }
+ if (bindresvport(fsock, 0) < 0) {
+ perror(_("nfs bindresvport"));
+ goto fail;
+ }
}
+
#ifdef NFS_MOUNT_DEBUG
printf(_("using port %d for nfs deamon\n"), nfs_pmap->pm_port);
#endif
@@ -1143,7 +1145,7 @@ noauth_flavors:
* to avoid problems with multihomed hosts.
* --Swen
*/
- if (linux_version_code() <= 66314
+ if (linux_version_code() <= 66314 && fsock != -1
&& connect(fsock, (struct sockaddr *) nfs_saddr,
sizeof (*nfs_saddr)) < 0) {
perror(_("nfs connect"));



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs


2007-03-13 11:38:23

by Talpey, Thomas

[permalink] [raw]
Subject: Re: nfs-utils patch for mount-reserved-port

At 12:02 AM 3/13/2007, Neil Brown wrote:
>On Monday March 12, [email protected] wrote:
>> Nobody replied yet, but on a second look, removing the compatibility
>> for the fd leads directly to removing all sorts of other compatibility stuff
>> being pitched too. So I think this way is best.
>
>I agree.
>You patch had spaces instead of tabs, but that wasn't too hard to fix
>up.

Sorry 'bout that. I blame our corporate Exchange server. :-/ It had tabs
when I hit send.

>> Yes, the second linux version check for <= 66314 technically precludes
>> the fsock being still -1, but it reads better, and seems a little safer with
>> the extra fsock check against the uninitialized value.
>
>I changes 66314 to 0x1030a :-) and made a couple of other little
>additions.

That 66314 was already there of course, I just added the fsock test.

New version looks great. Looking forward to --enable-mount, if any
work needed for that just holler.

Tom.

>
>Thanks, You can find it here
>
>http://neil.brown.name/git?p=nfs-utils;a=commitdiff;h=e6e19816da66cde1cc4fd062c898ce66a9b4e336
>
>(the linux-nfs.org git-web interface seems to be malfunctioning...)
>
>
>>
>> I am assuming nobody wants to patch util-linux for this kind of thing?
>> (i.e. that nfs-utils will be shipped configured with --enable-mount in
>> the future?)
>
>I'm hoping to release 1.1.0 with --enable-mount as the default, but
>there are still some issues pending for which patches exist but need
>to be improved...
>
>I wouldn't bother with fixing it in util-linux at this point.
>
>NeilBrown


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

2007-03-12 16:05:56

by Talpey, Thomas

[permalink] [raw]
Subject: Re: nfs-utils patch for mount-reserved-port

Nobody replied yet, but on a second look, removing the compatibility
for the fd leads directly to removing all sorts of other compatibility stuff
being pitched too. So I think this way is best.

Yes, the second linux version check for <= 66314 technically precludes
the fsock being still -1, but it reads better, and seems a little safer with
the extra fsock check against the uninitialized value.

I am assuming nobody wants to patch util-linux for this kind of thing?
(i.e. that nfs-utils will be shipped configured with --enable-mount in
the future?)

Tom.

At 11:55 AM 3/12/2007, Talpey, Thomas wrote:
>Only create a mount-time reserved port socket for kernels
>which require it (pre-2.1.32/nfs_mount_version 1).
>
>Signed-off-by: Tom Talpey <[email protected]>
>
>Index: nfs-utils-1.0.12/utils/mount/nfsmount.c
>===================================================================
>--- nfs-utils-1.0.12.orig/utils/mount/nfsmount.c
>+++ nfs-utils-1.0.12/utils/mount/nfsmount.c
>@@ -1120,20 +1120,22 @@ noauth_flavors:
> #endif
> }
>
>- /* create nfs socket for kernel */
>-
>- if (nfs_pmap->pm_prot == IPPROTO_TCP)
>- fsock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
>- else
>- fsock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
>- if (fsock < 0) {
>- perror(_("nfs socket"));
>- goto fail;
>- }
>- if (bindresvport(fsock, 0) < 0) {
>- perror(_("nfs bindresvport"));
>- goto fail;
>+ if (nfs_mount_version == 1) {
>+ /* create nfs socket for kernel */
>+ if (nfs_pmap->pm_prot == IPPROTO_TCP)
>+ fsock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
>+ else
>+ fsock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
>+ if (fsock < 0) {
>+ perror(_("nfs socket"));
>+ goto fail;
>+ }
>+ if (bindresvport(fsock, 0) < 0) {
>+ perror(_("nfs bindresvport"));
>+ goto fail;
>+ }
> }
>+
> #ifdef NFS_MOUNT_DEBUG
> printf(_("using port %d for nfs deamon\n"), nfs_pmap->pm_port);
> #endif
>@@ -1143,7 +1145,7 @@ noauth_flavors:
> * to avoid problems with multihomed hosts.
> * --Swen
> */
>- if (linux_version_code() <= 66314
>+ if (linux_version_code() <= 66314 && fsock != -1
> && connect(fsock, (struct sockaddr *) nfs_saddr,
> sizeof (*nfs_saddr)) < 0) {
> perror(_("nfs connect"));
>
>
>
>-------------------------------------------------------------------------
>Take Surveys. Earn Cash. Influence the Future of IT
>Join SourceForge.net's Techsay panel and you'll get the chance to share your
>opinions on IT & business topics through brief surveys-and earn cash
>http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
>_______________________________________________
>NFS maillist - [email protected]
>https://lists.sourceforge.net/lists/listinfo/nfs


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

2007-03-12 17:17:02

by Olaf Kirch

[permalink] [raw]
Subject: Re: nfs-utils patch for mount-reserved-port

On Monday 12 March 2007 16:55, Talpey, Thomas wrote:
> Only create a mount-time reserved port socket for kernels
> which require it (pre-2.1.32/nfs_mount_version 1).

I like this approach. Whether or not to remove compatibility
for ancient versions is another debate - but anything that
reduces the number of privports mount consumes is certainly
a big advantage.

Olaf
--
Olaf Kirch | --- o --- Nous sommes du soleil we love when we play
[email protected] | / | \ sol.dhoop.naytheet.ah kin.ir.samse.qurax

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

2007-03-13 04:02:32

by NeilBrown

[permalink] [raw]
Subject: Re: nfs-utils patch for mount-reserved-port

On Monday March 12, [email protected] wrote:
> Nobody replied yet, but on a second look, removing the compatibility
> for the fd leads directly to removing all sorts of other compatibility stuff
> being pitched too. So I think this way is best.

I agree.
You patch had spaces instead of tabs, but that wasn't too hard to fix
up.

>
> Yes, the second linux version check for <= 66314 technically precludes
> the fsock being still -1, but it reads better, and seems a little safer with
> the extra fsock check against the uninitialized value.

I changes 66314 to 0x1030a :-) and made a couple of other little
additions.

Thanks, You can find it here
http://neil.brown.name/git?p=nfs-utils;a=commitdiff;h=e6e19816da66cde1cc4fd062c898ce66a9b4e336

(the linux-nfs.org git-web interface seems to be malfunctioning...)


>
> I am assuming nobody wants to patch util-linux for this kind of thing?
> (i.e. that nfs-utils will be shipped configured with --enable-mount in
> the future?)

I'm hoping to release 1.1.0 with --enable-mount as the default, but
there are still some issues pending for which patches exist but need
to be improved...

I wouldn't bother with fixing it in util-linux at this point.

NeilBrown

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs