aboutsummaryrefslogtreecommitdiffstats
path: root/net/sunrpc/xprtrdma
diff options
context:
space:
mode:
authorChuck Lever <chuck.lever@oracle.com>2009-08-09 15:09:36 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2009-08-09 15:09:36 -0400
commitc877b849d302d1275452af80b7221a2555dc02e1 (patch)
tree7baf4099cbb235e9ee4d420f61208d10ecdc8c4d /net/sunrpc/xprtrdma
parentba809130bc260fce04141aca01ef9e068d32af2a (diff)
SUNRPC: Use rpc_ntop() for constructing transport address strings
Clean up: In addition to using the new generic rpc_ntop() and rpc_get_port() functions, have the RPC client compute the presentation address buffer sizes dynamically using kstrdup(). Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'net/sunrpc/xprtrdma')
-rw-r--r--net/sunrpc/xprtrdma/transport.c45
1 files changed, 18 insertions, 27 deletions
diff --git a/net/sunrpc/xprtrdma/transport.c b/net/sunrpc/xprtrdma/transport.c
index 537c210a8b92..5f9b8676b6bd 100644
--- a/net/sunrpc/xprtrdma/transport.c
+++ b/net/sunrpc/xprtrdma/transport.c
@@ -168,39 +168,30 @@ static struct rpc_xprt_ops xprt_rdma_procs; /* forward reference */
168static void 168static void
169xprt_rdma_format_addresses(struct rpc_xprt *xprt) 169xprt_rdma_format_addresses(struct rpc_xprt *xprt)
170{ 170{
171 struct sockaddr_in *addr = (struct sockaddr_in *) 171 struct sockaddr *sap = (struct sockaddr *)
172 &rpcx_to_rdmad(xprt).addr; 172 &rpcx_to_rdmad(xprt).addr;
173 char *buf; 173 struct sockaddr_in *sin = (struct sockaddr_in *)sap;
174 char buf[64];
174 175
175 buf = kzalloc(20, GFP_KERNEL); 176 (void)rpc_ntop(sap, buf, sizeof(buf));
176 if (buf) 177 xprt->address_strings[RPC_DISPLAY_ADDR] = kstrdup(buf, GFP_KERNEL);
177 snprintf(buf, 20, "%pI4", &addr->sin_addr.s_addr);
178 xprt->address_strings[RPC_DISPLAY_ADDR] = buf;
179 178
180 buf = kzalloc(8, GFP_KERNEL); 179 (void)snprintf(buf, sizeof(buf), "%u", rpc_get_port(sap));
181 if (buf) 180 xprt->address_strings[RPC_DISPLAY_PORT] = kstrdup(buf, GFP_KERNEL);
182 snprintf(buf, 8, "%u", ntohs(addr->sin_port));
183 xprt->address_strings[RPC_DISPLAY_PORT] = buf;
184 181
185 xprt->address_strings[RPC_DISPLAY_PROTO] = "rdma"; 182 xprt->address_strings[RPC_DISPLAY_PROTO] = "rdma";
186 183
187 buf = kzalloc(48, GFP_KERNEL); 184 (void)snprintf(buf, sizeof(buf), "addr=%s port=%s proto=rdma",
188 if (buf) 185 xprt->address_strings[RPC_DISPLAY_ADDR],
189 snprintf(buf, 48, "addr=%pI4 port=%u proto=%s", 186 xprt->address_strings[RPC_DISPLAY_PORT]);
190 &addr->sin_addr.s_addr, 187 xprt->address_strings[RPC_DISPLAY_ALL] = kstrdup(buf, GFP_KERNEL);
191 ntohs(addr->sin_port), "rdma"); 188
192 xprt->address_strings[RPC_DISPLAY_ALL] = buf; 189 (void)snprintf(buf, sizeof(buf), "%02x%02x%02x%02x",
193 190 NIPQUAD(sin->sin_addr.s_addr));
194 buf = kzalloc(10, GFP_KERNEL); 191 xprt->address_strings[RPC_DISPLAY_HEX_ADDR] = kstrdup(buf, GFP_KERNEL);
195 if (buf) 192
196 snprintf(buf, 10, "%02x%02x%02x%02x", 193 (void)snprintf(buf, sizeof(buf), "%4hx", rpc_get_port(sap));
197 NIPQUAD(addr->sin_addr.s_addr)); 194 xprt->address_strings[RPC_DISPLAY_HEX_PORT] = kstrdup(buf, GFP_KERNEL);
198 xprt->address_strings[RPC_DISPLAY_HEX_ADDR] = buf;
199
200 buf = kzalloc(8, GFP_KERNEL);
201 if (buf)
202 snprintf(buf, 8, "%4hx", ntohs(addr->sin_port));
203 xprt->address_strings[RPC_DISPLAY_HEX_PORT] = buf;
204 195
205 /* netid */ 196 /* netid */
206 xprt->address_strings[RPC_DISPLAY_NETID] = "rdma"; 197 xprt->address_strings[RPC_DISPLAY_NETID] = "rdma";