From: Stanislav Kinsbursky <skinsbursky-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org>
To: Trond.Myklebust-HgOvQuBEEgTQT0dZR+AlfA@public.gmane.org,
davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org
Cc: linux-nfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
eric.dumazet-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
xemul-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org,
netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
bfields-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org,
viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn@public.gmane.org,
tim.c.chen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org,
devel-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org
Subject: [RFC PATCH 1/2] unix sockets: add ability for search for peer from passed root
Date: Fri, 10 Aug 2012 16:57:30 +0400 [thread overview]
Message-ID: <20120810125730.7115.96005.stgit@localhost.localdomain> (raw)
In-Reply-To: <20120810125701.7115.71612.stgit-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
This helper is used stream sockets yet.
All is simple: if non-NULL struct path was passed to unix_find_other(), then
vfs_path_lookup() is called instead of kern_path().
Signed-off-by: Stanislav Kinsbursky <skinsbursky-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org>
---
include/net/af_unix.h | 2 ++
net/unix/af_unix.c | 25 ++++++++++++++++++-------
2 files changed, 20 insertions(+), 7 deletions(-)
diff --git a/include/net/af_unix.h b/include/net/af_unix.h
index 2ee33da..559467e 100644
--- a/include/net/af_unix.h
+++ b/include/net/af_unix.h
@@ -67,6 +67,8 @@ struct unix_sock {
long unix_inq_len(struct sock *sk);
long unix_outq_len(struct sock *sk);
+int unix_stream_connect_root(struct path *root, struct socket *sock,
+ struct sockaddr *uaddr, int addr_len, int flags);
#ifdef CONFIG_SYSCTL
extern int unix_sysctl_register(struct net *net);
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index 641f2e4..a790ebc 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -759,7 +759,7 @@ out: mutex_unlock(&u->readlock);
return err;
}
-static struct sock *unix_find_other(struct net *net,
+static struct sock *unix_find_other(struct net *net, struct path *root,
struct sockaddr_un *sunname, int len,
int type, unsigned int hash, int *error)
{
@@ -769,7 +769,11 @@ static struct sock *unix_find_other(struct net *net,
if (sunname->sun_path[0]) {
struct inode *inode;
- err = kern_path(sunname->sun_path, LOOKUP_FOLLOW, &path);
+
+ if (root)
+ err = vfs_path_lookup(root->dentry, root->mnt, sunname->sun_path, LOOKUP_FOLLOW, &path);
+ else
+ err = kern_path(sunname->sun_path, LOOKUP_FOLLOW, &path);
if (err)
goto fail;
inode = path.dentry->d_inode;
@@ -979,7 +983,7 @@ static int unix_dgram_connect(struct socket *sock, struct sockaddr *addr,
goto out;
restart:
- other = unix_find_other(net, sunaddr, alen, sock->type, hash, &err);
+ other = unix_find_other(net, NULL, sunaddr, alen, sock->type, hash, &err);
if (!other)
goto out;
@@ -1053,8 +1057,8 @@ static long unix_wait_for_peer(struct sock *other, long timeo)
return timeo;
}
-static int unix_stream_connect(struct socket *sock, struct sockaddr *uaddr,
- int addr_len, int flags)
+int unix_stream_connect_root(struct path *root, struct socket *sock,
+ struct sockaddr *uaddr, int addr_len, int flags)
{
struct sockaddr_un *sunaddr = (struct sockaddr_un *)uaddr;
struct sock *sk = sock->sk;
@@ -1098,7 +1102,7 @@ static int unix_stream_connect(struct socket *sock, struct sockaddr *uaddr,
restart:
/* Find listening sock. */
- other = unix_find_other(net, sunaddr, addr_len, sk->sk_type, hash, &err);
+ other = unix_find_other(net, root, sunaddr, addr_len, sk->sk_type, hash, &err);
if (!other)
goto out;
@@ -1227,6 +1231,13 @@ out:
sock_put(other);
return err;
}
+EXPORT_SYMBOL_GPL(unix_stream_connect_root);
+
+static int unix_stream_connect(struct socket *sock, struct sockaddr *uaddr,
+ int addr_len, int flags)
+{
+ return unix_stream_connect_root(NULL, sock, uaddr, addr_len, flags);
+}
static int unix_socketpair(struct socket *socka, struct socket *sockb)
{
@@ -1508,7 +1519,7 @@ restart:
if (sunaddr == NULL)
goto out_free;
- other = unix_find_other(net, sunaddr, namelen, sk->sk_type,
+ other = unix_find_other(net, NULL, sunaddr, namelen, sk->sk_type,
hash, &err);
if (other == NULL)
goto out_free;
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2012-08-10 12:57 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-10 12:57 [RFC PATCH 0/2] net: connect to UNIX sockets from specified root Stanislav Kinsbursky
2012-08-10 12:57 ` [RFC PATCH 2/2] SUNRPC: connect local transports with unix_stream_connect_root() helper Stanislav Kinsbursky
[not found] ` <20120810125701.7115.71612.stgit-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2012-08-10 12:57 ` Stanislav Kinsbursky [this message]
2012-08-10 18:10 ` [RFC PATCH 1/2] unix sockets: add ability for search for peer from passed root J. Bruce Fields
[not found] ` <20120810181002.GB17404-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org>
2012-08-10 18:43 ` Stanislav Kinsbursky
2012-08-10 18:15 ` [RFC PATCH 0/2] net: connect to UNIX sockets from specified root H. Peter Anvin
2012-08-10 18:26 ` Alan Cox
[not found] ` <20120810192628.79a34d28-38n7/U1jhRXW96NNrWNlrekiAK3p4hvP@public.gmane.org>
2012-08-10 18:31 ` H. Peter Anvin
[not found] ` <5025537D.9060300-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org>
2012-08-10 18:40 ` Alan Cox
2012-08-10 18:42 ` H. Peter Anvin
2012-08-10 19:11 ` J. Bruce Fields
[not found] ` <20120810191149.GA17985-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org>
2012-08-10 19:28 ` Alan Cox
2012-08-10 23:09 ` H. Peter Anvin
[not found] ` <50259494.8060304-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org>
2012-08-11 6:23 ` Pavel Emelyanov
2012-08-11 11:15 ` Stanislav Kinsbursky
2012-08-13 16:47 ` J. Bruce Fields
2012-08-13 17:39 ` Stanislav Kinsbursky
2012-08-13 18:24 ` J. Bruce Fields
[not found] ` <20120813182431.GA4234-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org>
2012-08-14 8:46 ` Stanislav Kinsbursky
2012-08-10 18:50 ` Stanislav Kinsbursky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120810125730.7115.96005.stgit@localhost.localdomain \
--to=skinsbursky-bzqdu9zft3wakbo8gow8eq@public.gmane.org \
--cc=Trond.Myklebust-HgOvQuBEEgTQT0dZR+AlfA@public.gmane.org \
--cc=bfields-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org \
--cc=davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org \
--cc=devel-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org \
--cc=eric.dumazet-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-nfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=tim.c.chen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org \
--cc=viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn@public.gmane.org \
--cc=xemul-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).