2010-10-13 21:44:40

by Ben Myers

[permalink] [raw]
Subject: [PATCH] Add an error message for xs_bind

xs_bind4 doesn't log an error when it can't get a reserved source port due to
them all being in use. This situation can be hard to debug when it is
intermittent or you don't know what to look for in the debug output. Add an
error message describing how to resolve this problem when it happens.
---
net/sunrpc/xprtsock.c | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
index fe9306b..ea5f38e 100644
--- a/net/sunrpc/xprtsock.c
+++ b/net/sunrpc/xprtsock.c
@@ -1563,6 +1563,12 @@ static int xs_bind4(struct sock_xprt *transport, struct socket *sock)
if (port > last)
nloop++;
} while (err == -EADDRINUSE && nloop != 2);
+ if (err == -EADDRINUSE && nloop == 2 && transport->xprt.resvport) {
+ printk("RPC: %s %pI4: cannot bind reserved source port, "
+ "too many ports already in use. "
+ "consider increasing xprt_max_resvport.\n",
+ __func__, &myaddr.sin_addr);
+ }
dprintk("RPC: %s %pI4:%u: %s (%d)\n",
__func__, &myaddr.sin_addr,
port, err ? "failed" : "ok", err);
@@ -1596,6 +1602,12 @@ static int xs_bind6(struct sock_xprt *transport, struct socket *sock)
if (port > last)
nloop++;
} while (err == -EADDRINUSE && nloop != 2);
+ if (err == -EADDRINUSE && nloop == 2 && transport->xprt.resvport) {
+ printk("RPC: %s %pI6: cannot bind reserved source port, "
+ "too many ports already in use. "
+ "consider increasing xprt_max_resvport.\n",
+ __func__, &myaddr.sin6_addr);
+ }
dprintk("RPC: xs_bind6 %pI6:%u: %s (%d)\n",
&myaddr.sin6_addr, port, err ? "failed" : "ok", err);
return err;