aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChuck Lever <chuck.lever@oracle.com>2007-08-16 16:03:26 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2007-10-09 17:16:29 -0400
commit756805e7a76bcd2aae07fe31786fe453375e60b1 (patch)
treef741760cde49f5f9f433d6996300f44a916a743c
parent8945ee5e27156ef9708bc3a11da87ba689aa38b6 (diff)
SUNRPC: Add support for formatted universal addresses
"Universal addresses" are a string representation of an IP address and port. They are described fully in RFC 3530, section 2.2. Add support for generating them in the RPC client's socket transport module. Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
-rw-r--r--include/linux/sunrpc/xprt.h1
-rw-r--r--net/sunrpc/xprtsock.c18
2 files changed, 19 insertions, 0 deletions
diff --git a/include/linux/sunrpc/xprt.h b/include/linux/sunrpc/xprt.h
index 4596c26f97aa..902a9c0a2d9a 100644
--- a/include/linux/sunrpc/xprt.h
+++ b/include/linux/sunrpc/xprt.h
@@ -55,6 +55,7 @@ enum rpc_display_format_t {
55 RPC_DISPLAY_ALL, 55 RPC_DISPLAY_ALL,
56 RPC_DISPLAY_HEX_ADDR, 56 RPC_DISPLAY_HEX_ADDR,
57 RPC_DISPLAY_HEX_PORT, 57 RPC_DISPLAY_HEX_PORT,
58 RPC_DISPLAY_UNIVERSAL_ADDR,
58 RPC_DISPLAY_MAX, 59 RPC_DISPLAY_MAX,
59}; 60};
60 61
diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
index 01121a4f0851..7a154e4b70f5 100644
--- a/net/sunrpc/xprtsock.c
+++ b/net/sunrpc/xprtsock.c
@@ -328,6 +328,15 @@ static void xs_format_ipv4_peer_addresses(struct rpc_xprt *xprt)
328 ntohs(addr->sin_port)); 328 ntohs(addr->sin_port));
329 } 329 }
330 xprt->address_strings[RPC_DISPLAY_HEX_PORT] = buf; 330 xprt->address_strings[RPC_DISPLAY_HEX_PORT] = buf;
331
332 buf = kzalloc(30, GFP_KERNEL);
333 if (buf) {
334 snprintf(buf, 30, NIPQUAD_FMT".%u.%u",
335 NIPQUAD(addr->sin_addr.s_addr),
336 ntohs(addr->sin_port) >> 8,
337 ntohs(addr->sin_port) & 0xff);
338 }
339 xprt->address_strings[RPC_DISPLAY_UNIVERSAL_ADDR] = buf;
331} 340}
332 341
333static void xs_format_ipv6_peer_addresses(struct rpc_xprt *xprt) 342static void xs_format_ipv6_peer_addresses(struct rpc_xprt *xprt)
@@ -380,6 +389,15 @@ static void xs_format_ipv6_peer_addresses(struct rpc_xprt *xprt)
380 ntohs(addr->sin6_port)); 389 ntohs(addr->sin6_port));
381 } 390 }
382 xprt->address_strings[RPC_DISPLAY_HEX_PORT] = buf; 391 xprt->address_strings[RPC_DISPLAY_HEX_PORT] = buf;
392
393 buf = kzalloc(50, GFP_KERNEL);
394 if (buf) {
395 snprintf(buf, 50, NIP6_FMT".%u.%u",
396 NIP6(addr->sin6_addr),
397 ntohs(addr->sin6_port) >> 8,
398 ntohs(addr->sin6_port) & 0xff);
399 }
400 xprt->address_strings[RPC_DISPLAY_UNIVERSAL_ADDR] = buf;
383} 401}
384 402
385static void xs_free_peer_addresses(struct rpc_xprt *xprt) 403static void xs_free_peer_addresses(struct rpc_xprt *xprt)