2019-11-20 00:14:58

by Luc Van Oostenryck

[permalink] [raw]
Subject: [PATCH] xsk: fix xsk_poll()'s return type

xsk_poll() is defined as returning 'unsigned int' but the
.poll method is declared as returning '__poll_t', a bitwise type.

Fix this by using the proper return type and using the EPOLL
constants instead of the POLL ones, as required for __poll_t.

CC: Björn Töpel <[email protected]>
CC: Magnus Karlsson <[email protected]>
CC: Jonathan Lemon <[email protected]>
CC: [email protected]
Signed-off-by: Luc Van Oostenryck <[email protected]>
---
net/xdp/xsk.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c
index 9044073fbf22..7b59f36eec0d 100644
--- a/net/xdp/xsk.c
+++ b/net/xdp/xsk.c
@@ -418,10 +418,10 @@ static int xsk_sendmsg(struct socket *sock, struct msghdr *m, size_t total_len)
return __xsk_sendmsg(sk);
}

-static unsigned int xsk_poll(struct file *file, struct socket *sock,
+static __poll_t xsk_poll(struct file *file, struct socket *sock,
struct poll_table_struct *wait)
{
- unsigned int mask = datagram_poll(file, sock, wait);
+ __poll_t mask = datagram_poll(file, sock, wait);
struct sock *sk = sock->sk;
struct xdp_sock *xs = xdp_sk(sk);
struct net_device *dev;
@@ -443,9 +443,9 @@ static unsigned int xsk_poll(struct file *file, struct socket *sock,
}

if (xs->rx && !xskq_empty_desc(xs->rx))
- mask |= POLLIN | POLLRDNORM;
+ mask |= EPOLLIN | EPOLLRDNORM;
if (xs->tx && !xskq_full_desc(xs->tx))
- mask |= POLLOUT | POLLWRNORM;
+ mask |= EPOLLOUT | EPOLLWRNORM;

return mask;
}
--
2.24.0



2019-11-20 06:17:11

by Björn Töpel

[permalink] [raw]
Subject: Re: [PATCH] xsk: fix xsk_poll()'s return type

On 2019-11-20 01:10, Luc Van Oostenryck wrote:
> xsk_poll() is defined as returning 'unsigned int' but the
> .poll method is declared as returning '__poll_t', a bitwise type.
>
> Fix this by using the proper return type and using the EPOLL
> constants instead of the POLL ones, as required for __poll_t.
>

Thanks for the cleanup!

Acked-by: Björn Töpel <[email protected]>

Daniel/Alexei: This should go through bpf-next.


Björn



> CC: Björn Töpel <[email protected]>
> CC: Magnus Karlsson <[email protected]>
> CC: Jonathan Lemon <[email protected]>
> CC: [email protected]
> Signed-off-by: Luc Van Oostenryck <[email protected]>
> ---
> net/xdp/xsk.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c
> index 9044073fbf22..7b59f36eec0d 100644
> --- a/net/xdp/xsk.c
> +++ b/net/xdp/xsk.c
> @@ -418,10 +418,10 @@ static int xsk_sendmsg(struct socket *sock, struct msghdr *m, size_t total_len)
> return __xsk_sendmsg(sk);
> }
>
> -static unsigned int xsk_poll(struct file *file, struct socket *sock,
> +static __poll_t xsk_poll(struct file *file, struct socket *sock,
> struct poll_table_struct *wait)
> {
> - unsigned int mask = datagram_poll(file, sock, wait);
> + __poll_t mask = datagram_poll(file, sock, wait);
> struct sock *sk = sock->sk;
> struct xdp_sock *xs = xdp_sk(sk);
> struct net_device *dev;
> @@ -443,9 +443,9 @@ static unsigned int xsk_poll(struct file *file, struct socket *sock,
> }
>
> if (xs->rx && !xskq_empty_desc(xs->rx))
> - mask |= POLLIN | POLLRDNORM;
> + mask |= EPOLLIN | EPOLLRDNORM;
> if (xs->tx && !xskq_full_desc(xs->tx))
> - mask |= POLLOUT | POLLWRNORM;
> + mask |= EPOLLOUT | EPOLLWRNORM;
>
> return mask;
> }
>

2019-11-21 08:51:11

by Daniel Borkmann

[permalink] [raw]
Subject: Re: [PATCH] xsk: fix xsk_poll()'s return type

On Wed, Nov 20, 2019 at 07:15:42AM +0100, Bj?rn T?pel wrote:
> On 2019-11-20 01:10, Luc Van Oostenryck wrote:
> > xsk_poll() is defined as returning 'unsigned int' but the
> > .poll method is declared as returning '__poll_t', a bitwise type.
> >
> > Fix this by using the proper return type and using the EPOLL
> > constants instead of the POLL ones, as required for __poll_t.
>
> Thanks for the cleanup!
>
> Acked-by: Bj?rn T?pel <[email protected]>
>
> Daniel/Alexei: This should go through bpf-next.

Done, applied, thanks!