From 2427fa19988f53c6f1218bb5f93860083f5e088f Mon Sep 17 00:00:00 2001 From: Kris Kennaway Date: Mon, 11 Feb 2008 23:23:21 +0000 Subject: [PATCH] Switch the default NFS mount mode from UDP to TCP. UDP mounts are a historical relic, and are no longer appropriate for either LAN or WAN mounting. At modern (gigabit and 10 gigabit) LAN speeds packet loss from socket buffer fill events is common, and sequence numbers wrap quickly enough that data corruption is possible. TCP solves both of these problems without imposing significant overhead. MFC after: 1 month --- UPDATING | 6 ++++++ sbin/mount_nfs/mount_nfs.8 | 10 +++++----- sbin/mount_nfs/mount_nfs.c | 2 +- sys/nfsclient/nfs_diskless.c | 4 ++-- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/UPDATING b/UPDATING index 24e8cd19b87f..10ea7e37bc81 100644 --- a/UPDATING +++ b/UPDATING @@ -22,6 +22,12 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 8.x IS SLOW: to maximize performance. (To disable malloc debugging, run ln -s aj /etc/malloc.conf.) +20080211: + The default NFS mount mode has changed from UDP to TCP for + increased reliability. If you rely on (insecurely) NFS + mounting across a firewall you may need to update your + firewall rules. + 20080208: Belatedly note the addition of m_collapse for compacting mbuf chains. diff --git a/sbin/mount_nfs/mount_nfs.8 b/sbin/mount_nfs/mount_nfs.8 index 93ea3c2caa62..a8d410fa86eb 100644 --- a/sbin/mount_nfs/mount_nfs.8 +++ b/sbin/mount_nfs/mount_nfs.8 @@ -142,11 +142,11 @@ The default is a retry count of zero, which means to keep retrying forever. There is a 60 second delay between each attempt. .It Fl T -Use TCP transport instead of UDP. -This is recommended for servers that are not on the same LAN cable as -the client. -Not all NFS servers support this method, especially older ones; -caution should be observed in these cases. +Use TCP transport. +This is the default option, as it provides for increased reliability on both +LAN and WAN configurations compared to UDP. +Some old NFS servers do not support this method; UDP mounts may be required +for interoperability. .It Fl U Force the mount protocol to use UDP transport, even for TCP NFS mounts. (Necessary for some old diff --git a/sbin/mount_nfs/mount_nfs.c b/sbin/mount_nfs/mount_nfs.c index 44d45e85760e..48c0a1fb63d1 100644 --- a/sbin/mount_nfs/mount_nfs.c +++ b/sbin/mount_nfs/mount_nfs.c @@ -155,7 +155,7 @@ struct nfs_args nfsdefargs = { NFS_ARGSVERSION, NULL, sizeof (struct sockaddr_in), - SOCK_DGRAM, + SOCK_STREAM, 0, NULL, 0, diff --git a/sys/nfsclient/nfs_diskless.c b/sys/nfsclient/nfs_diskless.c index 4825d31ac0cb..a970b1d5c4c7 100644 --- a/sys/nfsclient/nfs_diskless.c +++ b/sys/nfsclient/nfs_diskless.c @@ -204,8 +204,8 @@ nfs_setup_diskless(void) /* set up root mount */ nd->root_args.rsize = 8192; /* XXX tunable? */ nd->root_args.wsize = 8192; - nd->root_args.sotype = SOCK_DGRAM; - nd->root_args.flags = (NFSMNT_WSIZE | NFSMNT_RSIZE | NFSMNT_RESVPORT); + nd->root_args.sotype = SOCK_STREAM; + nd->root_args.flags = (NFSMNT_NFSV3 | NFSMNT_WSIZE | NFSMNT_RSIZE | NFSMNT_RESVPORT); if (inaddr_to_sockaddr("boot.nfsroot.server", &nd->root_saddr)) { printf("nfs_diskless: no server\n"); return;