Commit 4388ce05 authored by NeilBrown's avatar NeilBrown Committed by Trond Myklebust

SUNRPC: support abstract unix socket addresses

An "abtract" address for an AF_UNIX socket start with a nul and can
contain any bytes for the given length, but traditionally doesn't
contain other nuls.  When reported, the leading nul is replaced by '@'.

sunrpc currently rejects connections to these addresses and reports them
as an empty string.  To provide support for future use of these
addresses, allow them for outgoing connections and report them more
usefully.
Signed-off-by: default avatarNeilBrown <neilb@suse.de>
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
parent 86e2e1f6
...@@ -565,8 +565,12 @@ struct rpc_clnt *rpc_create(struct rpc_create_args *args) ...@@ -565,8 +565,12 @@ struct rpc_clnt *rpc_create(struct rpc_create_args *args)
servername[0] = '\0'; servername[0] = '\0';
switch (args->address->sa_family) { switch (args->address->sa_family) {
case AF_LOCAL: case AF_LOCAL:
snprintf(servername, sizeof(servername), "%s", if (sun->sun_path[0])
sun->sun_path); snprintf(servername, sizeof(servername), "%s",
sun->sun_path);
else
snprintf(servername, sizeof(servername), "@%s",
sun->sun_path+1);
break; break;
case AF_INET: case AF_INET:
snprintf(servername, sizeof(servername), "%pI4", snprintf(servername, sizeof(servername), "%pI4",
......
...@@ -253,7 +253,12 @@ static void xs_format_common_peer_addresses(struct rpc_xprt *xprt) ...@@ -253,7 +253,12 @@ static void xs_format_common_peer_addresses(struct rpc_xprt *xprt)
switch (sap->sa_family) { switch (sap->sa_family) {
case AF_LOCAL: case AF_LOCAL:
sun = xs_addr_un(xprt); sun = xs_addr_un(xprt);
strscpy(buf, sun->sun_path, sizeof(buf)); if (sun->sun_path[0]) {
strscpy(buf, sun->sun_path, sizeof(buf));
} else {
buf[0] = '@';
strscpy(buf+1, sun->sun_path+1, sizeof(buf)-1);
}
xprt->address_strings[RPC_DISPLAY_ADDR] = xprt->address_strings[RPC_DISPLAY_ADDR] =
kstrdup(buf, GFP_KERNEL); kstrdup(buf, GFP_KERNEL);
break; break;
...@@ -2858,7 +2863,7 @@ static struct rpc_xprt *xs_setup_local(struct xprt_create *args) ...@@ -2858,7 +2863,7 @@ static struct rpc_xprt *xs_setup_local(struct xprt_create *args)
switch (sun->sun_family) { switch (sun->sun_family) {
case AF_LOCAL: case AF_LOCAL:
if (sun->sun_path[0] != '/') { if (sun->sun_path[0] != '/' && sun->sun_path[0] != '\0') {
dprintk("RPC: bad AF_LOCAL address: %s\n", dprintk("RPC: bad AF_LOCAL address: %s\n",
sun->sun_path); sun->sun_path);
ret = ERR_PTR(-EINVAL); ret = ERR_PTR(-EINVAL);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment