netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Use sockfd_lookup_light in the rest of the net/socket.c
@ 2007-11-14 16:42 Pavel Emelyanov
  2007-11-14 23:47 ` Simon Horman
  2007-11-15  0:02 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Pavel Emelyanov @ 2007-11-14 16:42 UTC (permalink / raw)
  To: David Miller; +Cc: Linux Netdev List, devel

Some time ago a sockfd_lookup_light was introduced and
most of the socket.c file was patched to use it. However
two routines were left - sys_sendto and sys_recvfrom.

Patch them as well, since this helper does exactly what
these two need.

Signed-off-by: Pavel Emelyanov <xemul@openvz.org>

---

diff --git a/net/socket.c b/net/socket.c
index 74784df..f8ec651 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -1581,16 +1581,11 @@ asmlinkage long sys_sendto(int fd, void __user *buff, size_t len,
 	struct msghdr msg;
 	struct iovec iov;
 	int fput_needed;
-	struct file *sock_file;
 
-	sock_file = fget_light(fd, &fput_needed);
-	err = -EBADF;
-	if (!sock_file)
+	sock = sockfd_lookup_light(fd, &err, &fput_needed);
+	if (!sock)
 		goto out;
 
-	sock = sock_from_file(sock_file, &err);
-	if (!sock)
-		goto out_put;
 	iov.iov_base = buff;
 	iov.iov_len = len;
 	msg.msg_name = NULL;
@@ -1612,7 +1607,7 @@ asmlinkage long sys_sendto(int fd, void __user *buff, size_t len,
 	err = sock_sendmsg(sock, &msg, len);
 
 out_put:
-	fput_light(sock_file, fput_needed);
+	fput_light(sock->file, fput_needed);
 out:
 	return err;
 }
@@ -1641,17 +1636,11 @@ asmlinkage long sys_recvfrom(int fd, void __user *ubuf, size_t size,
 	struct msghdr msg;
 	char address[MAX_SOCK_ADDR];
 	int err, err2;
-	struct file *sock_file;
 	int fput_needed;
 
-	sock_file = fget_light(fd, &fput_needed);
-	err = -EBADF;
-	if (!sock_file)
-		goto out;
-
-	sock = sock_from_file(sock_file, &err);
+	sock = sockfd_lookup_light(fd, &err, &fput_needed);
 	if (!sock)
-		goto out_put;
+		goto out;
 
 	msg.msg_control = NULL;
 	msg.msg_controllen = 0;
@@ -1670,8 +1659,8 @@ asmlinkage long sys_recvfrom(int fd, void __user *ubuf, size_t size,
 		if (err2 < 0)
 			err = err2;
 	}
-out_put:
-	fput_light(sock_file, fput_needed);
+
+	fput_light(sock->file, fput_needed);
 out:
 	return err;
 }

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] Use sockfd_lookup_light in the rest of the net/socket.c
  2007-11-14 16:42 [PATCH] Use sockfd_lookup_light in the rest of the net/socket.c Pavel Emelyanov
@ 2007-11-14 23:47 ` Simon Horman
  2007-11-15  0:02 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Simon Horman @ 2007-11-14 23:47 UTC (permalink / raw)
  To: Pavel Emelyanov; +Cc: David Miller, Linux Netdev List, devel

On Wed, Nov 14, 2007 at 07:42:18PM +0300, Pavel Emelyanov wrote:
> Some time ago a sockfd_lookup_light was introduced and
> most of the socket.c file was patched to use it. However
> two routines were left - sys_sendto and sys_recvfrom.
> 
> Patch them as well, since this helper does exactly what
> these two need.
> 
> Signed-off-by: Pavel Emelyanov <xemul@openvz.org>

This looks correct to me.

Acked-by: Simon Horman <horms@verge.net.au>

-- 
Horms, California Edition


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Use sockfd_lookup_light in the rest of the net/socket.c
  2007-11-14 16:42 [PATCH] Use sockfd_lookup_light in the rest of the net/socket.c Pavel Emelyanov
  2007-11-14 23:47 ` Simon Horman
@ 2007-11-15  0:02 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2007-11-15  0:02 UTC (permalink / raw)
  To: xemul; +Cc: netdev, devel

From: Pavel Emelyanov <xemul@openvz.org>
Date: Wed, 14 Nov 2007 19:42:18 +0300

> Some time ago a sockfd_lookup_light was introduced and
> most of the socket.c file was patched to use it. However
> two routines were left - sys_sendto and sys_recvfrom.
> 
> Patch them as well, since this helper does exactly what
> these two need.
> 
> Signed-off-by: Pavel Emelyanov <xemul@openvz.org>

Applied to net-2.6.25, thanks!

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-11-15  0:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-14 16:42 [PATCH] Use sockfd_lookup_light in the rest of the net/socket.c Pavel Emelyanov
2007-11-14 23:47 ` Simon Horman
2007-11-15  0:02 ` David Miller

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).