SUNRPC: Add hex-formatted address support to rpc_peeraddr2str()
authorChuck Lever <chuck.lever@oracle.com>
Mon, 6 Aug 2007 15:57:02 +0000 (11:57 -0400)
committerTrond Myklebust <Trond.Myklebust@netapp.com>
Tue, 9 Oct 2007 21:15:52 +0000 (17:15 -0400)
Add support for the NFS client's need to export volume information
with IP addresses formatted in hex instead of decimal.

This isn't used yet, but subsequent patches (not in this series) will
change the NFS client to use this functionality.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
include/linux/sunrpc/xprt.h
net/sunrpc/xprtsock.c

index d11cedd14f0f59a9e267b97beddbde1ae13aca74..4596c26f97aa32fb6a037654827b1038b99acebe 100644 (file)
@@ -53,6 +53,8 @@ enum rpc_display_format_t {
        RPC_DISPLAY_PORT,
        RPC_DISPLAY_PROTO,
        RPC_DISPLAY_ALL,
+       RPC_DISPLAY_HEX_ADDR,
+       RPC_DISPLAY_HEX_PORT,
        RPC_DISPLAY_MAX,
 };
 
index b3f40b8dbcba6bd48bc2716b1587bcee07184464..8a684d87311169b4a3536fdfdb4674a9b46ca7fd 100644 (file)
@@ -296,6 +296,20 @@ static void xs_format_peer_addresses(struct rpc_xprt *xprt)
                        xprt->prot == IPPROTO_UDP ? "udp" : "tcp");
        }
        xprt->address_strings[RPC_DISPLAY_ALL] = buf;
+
+       buf = kzalloc(10, GFP_KERNEL);
+       if (buf) {
+               snprintf(buf, 10, "%02x%02x%02x%02x",
+                               NIPQUAD(addr->sin_addr.s_addr));
+       }
+       xprt->address_strings[RPC_DISPLAY_HEX_ADDR] = buf;
+
+       buf = kzalloc(8, GFP_KERNEL);
+       if (buf) {
+               snprintf(buf, 8, "%4hx",
+                               ntohs(addr->sin_port));
+       }
+       xprt->address_strings[RPC_DISPLAY_HEX_PORT] = buf;
 }
 
 static void xs_free_peer_addresses(struct rpc_xprt *xprt)