summaryrefslogtreecommitdiffstats
path: root/support/nfs/rpcmisc.c
diff options
context:
space:
mode:
authorNeil Brown <neilb@suse.de>2007-03-22 16:06:22 +1100
committerNeil Brown <neilb@suse.de>2007-03-22 16:06:22 +1100
commitbd401e645200601ab9c25dab905425112f3cafc4 (patch)
treebc85cab6ddaebd5108b7480e946ec84a2e27c0d6 /support/nfs/rpcmisc.c
parent0ec44a497a508fb631d472ce8c33041c497e1ca5 (diff)
downloadnfs-utils-bd401e645200601ab9c25dab905425112f3cafc4.tar.gz
nfs-utils-bd401e645200601ab9c25dab905425112f3cafc4.tar.xz
nfs-utils-bd401e645200601ab9c25dab905425112f3cafc4.zip
Never set SO_REUSEADDR on a UDP socket.
The effect is quite different from TCP sockets. For TCP, it allows you to listen for new connections even if there are outstanding old connections with the same local address. For UDP, it allows other people to steal your packets by binding to the same address.
Diffstat (limited to 'support/nfs/rpcmisc.c')
-rw-r--r--support/nfs/rpcmisc.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/support/nfs/rpcmisc.c b/support/nfs/rpcmisc.c
index 5b0a88f..22ea62c 100644
--- a/support/nfs/rpcmisc.c
+++ b/support/nfs/rpcmisc.c
@@ -184,8 +184,11 @@ int makesock(int port, int proto)
sin.sin_port = htons(port);
val = 1;
- if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val)) < 0)
- xlog(L_ERROR, "setsockopt failed: %s\n", strerror(errno));
+ if (proto == IPPROTO_TCP)
+ if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR,
+ &val, sizeof(val)) < 0)
+ xlog(L_ERROR, "setsockopt failed: %s\n",
+ strerror(errno));
#if 0
/* I was told it didn't work with gigabit ethernet.