Re: [PATCH bpf-next v5 1/6] net: Remove the err argument from sock_from_file

2020-12-04 Thread patchwork-bot+netdevbpf
Hello:

This series was applied to bpf/bpf-next.git (refs/heads/master):

On Fri,  4 Dec 2020 12:36:04 +0100 you wrote:
> Currently, the sock_from_file prototype takes an "err" pointer that is
> either not set or set to -ENOTSOCK IFF the returned socket is NULL. This
> makes the error redundant and it is ignored by a few callers.
> 
> This patch simplifies the API by letting callers deduce the error based
> on whether the returned socket is NULL or not.
> 
> [...]

Here is the summary with links:
  - [bpf-next,v5,1/6] net: Remove the err argument from sock_from_file
https://git.kernel.org/bpf/bpf-next/c/dba4a9256bb4
  - [bpf-next,v5,2/6] bpf: Add a bpf_sock_from_file helper
https://git.kernel.org/bpf/bpf-next/c/4f19cab76136
  - [bpf-next,v5,3/6] bpf: Expose bpf_sk_storage_* to iterator programs
https://git.kernel.org/bpf/bpf-next/c/a50a85e40c59
  - [bpf-next,v5,4/6] selftests/bpf: Add an iterator selftest for 
bpf_sk_storage_delete
https://git.kernel.org/bpf/bpf-next/c/593f6d41abbb
  - [bpf-next,v5,5/6] selftests/bpf: Add an iterator selftest for 
bpf_sk_storage_get
https://git.kernel.org/bpf/bpf-next/c/bd9b327e58f9
  - [bpf-next,v5,6/6] selftests/bpf: Test bpf_sk_storage_get in tcp iterators
https://git.kernel.org/bpf/bpf-next/c/34da87213d3d

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html




[PATCH bpf-next v5 1/6] net: Remove the err argument from sock_from_file

2020-12-04 Thread Florent Revest
Currently, the sock_from_file prototype takes an "err" pointer that is
either not set or set to -ENOTSOCK IFF the returned socket is NULL. This
makes the error redundant and it is ignored by a few callers.

This patch simplifies the API by letting callers deduce the error based
on whether the returned socket is NULL or not.

Suggested-by: Al Viro 
Signed-off-by: Florent Revest 
Reviewed-by: KP Singh 
---
 fs/eventpoll.c   |  3 +--
 fs/io_uring.c| 16 
 include/linux/net.h  |  2 +-
 net/core/netclassid_cgroup.c |  3 +--
 net/core/netprio_cgroup.c|  3 +--
 net/core/sock.c  |  8 +---
 net/socket.c | 27 ---
 7 files changed, 29 insertions(+), 33 deletions(-)

diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index 73c346e503d7..19499b7bb82c 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -416,12 +416,11 @@ static inline void ep_set_busy_poll_napi_id(struct epitem 
*epi)
unsigned int napi_id;
struct socket *sock;
struct sock *sk;
-   int err;
 
if (!net_busy_loop_on())
return;
 
-   sock = sock_from_file(epi->ffd.file, );
+   sock = sock_from_file(epi->ffd.file);
if (!sock)
return;
 
diff --git a/fs/io_uring.c b/fs/io_uring.c
index 8018c7076b25..ace99b15cbd3 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -4341,9 +4341,9 @@ static int io_sendmsg(struct io_kiocb *req, bool 
force_nonblock,
unsigned flags;
int ret;
 
-   sock = sock_from_file(req->file, );
+   sock = sock_from_file(req->file);
if (unlikely(!sock))
-   return ret;
+   return -ENOTSOCK;
 
if (req->async_data) {
kmsg = req->async_data;
@@ -4390,9 +4390,9 @@ static int io_send(struct io_kiocb *req, bool 
force_nonblock,
unsigned flags;
int ret;
 
-   sock = sock_from_file(req->file, );
+   sock = sock_from_file(req->file);
if (unlikely(!sock))
-   return ret;
+   return -ENOTSOCK;
 
ret = import_single_range(WRITE, sr->buf, sr->len, , _iter);
if (unlikely(ret))
@@ -4569,9 +4569,9 @@ static int io_recvmsg(struct io_kiocb *req, bool 
force_nonblock,
unsigned flags;
int ret, cflags = 0;
 
-   sock = sock_from_file(req->file, );
+   sock = sock_from_file(req->file);
if (unlikely(!sock))
-   return ret;
+   return -ENOTSOCK;
 
if (req->async_data) {
kmsg = req->async_data;
@@ -4632,9 +4632,9 @@ static int io_recv(struct io_kiocb *req, bool 
force_nonblock,
unsigned flags;
int ret, cflags = 0;
 
-   sock = sock_from_file(req->file, );
+   sock = sock_from_file(req->file);
if (unlikely(!sock))
-   return ret;
+   return -ENOTSOCK;
 
if (req->flags & REQ_F_BUFFER_SELECT) {
kbuf = io_recv_buffer_select(req, !force_nonblock);
diff --git a/include/linux/net.h b/include/linux/net.h
index 0dcd51feef02..9e2324efc26a 100644
--- a/include/linux/net.h
+++ b/include/linux/net.h
@@ -240,7 +240,7 @@ int sock_sendmsg(struct socket *sock, struct msghdr *msg);
 int sock_recvmsg(struct socket *sock, struct msghdr *msg, int flags);
 struct file *sock_alloc_file(struct socket *sock, int flags, const char 
*dname);
 struct socket *sockfd_lookup(int fd, int *err);
-struct socket *sock_from_file(struct file *file, int *err);
+struct socket *sock_from_file(struct file *file);
 #define sockfd_put(sock) fput(sock->file)
 int net_ratelimit(void);
 
diff --git a/net/core/netclassid_cgroup.c b/net/core/netclassid_cgroup.c
index 41b24cd31562..b49c57d35a88 100644
--- a/net/core/netclassid_cgroup.c
+++ b/net/core/netclassid_cgroup.c
@@ -68,9 +68,8 @@ struct update_classid_context {
 
 static int update_classid_sock(const void *v, struct file *file, unsigned n)
 {
-   int err;
struct update_classid_context *ctx = (void *)v;
-   struct socket *sock = sock_from_file(file, );
+   struct socket *sock = sock_from_file(file);
 
if (sock) {
spin_lock(_sk_update_lock);
diff --git a/net/core/netprio_cgroup.c b/net/core/netprio_cgroup.c
index 9bd4cab7d510..99a431c56f23 100644
--- a/net/core/netprio_cgroup.c
+++ b/net/core/netprio_cgroup.c
@@ -220,8 +220,7 @@ static ssize_t write_priomap(struct kernfs_open_file *of,
 
 static int update_netprio(const void *v, struct file *file, unsigned n)
 {
-   int err;
-   struct socket *sock = sock_from_file(file, );
+   struct socket *sock = sock_from_file(file);
if (sock) {
spin_lock(_sk_update_lock);
sock_cgroup_set_prioidx(>sk->sk_cgrp_data,
diff --git a/net/core/sock.c b/net/core/sock.c
index d422a6808405..eb55cf79bb24 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -2827,14 +2827,8 @@ EXPORT_SYMBOL(sock_no_mmap);
 void