Commit 89721e30 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag 'net-accept-more-20240515' of git://git.kernel.dk/linux

Pull more io_uring updates from Jens Axboe:
 "This adds support for IORING_CQE_F_SOCK_NONEMPTY for io_uring accept
  requests.

  This is very similar to previous work that enabled the same hint for
  doing receives on sockets. By far the majority of the work here is
  refactoring to enable the networking side to pass back whether or not
  the socket had more pending requests after accepting the current one,
  the last patch just wires it up for io_uring.

  Not only does this enable applications to know whether there are more
  connections to accept right now, it also enables smarter logic for
  io_uring multishot accept on whether to retry immediately or wait for
  a poll trigger"

* tag 'net-accept-more-20240515' of git://git.kernel.dk/linux:
  io_uring/net: wire up IORING_CQE_F_SOCK_NONEMPTY for accept
  net: pass back whether socket was empty post accept
  net: have do_accept() take a struct proto_accept_arg argument
  net: change proto and proto_ops accept type
parents 4b377b48 ac287da2
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -407,7 +407,8 @@ static int alg_setsockopt(struct socket *sock, int level, int optname,
	return err;
}

int af_alg_accept(struct sock *sk, struct socket *newsock, bool kern)
int af_alg_accept(struct sock *sk, struct socket *newsock,
		  struct proto_accept_arg *arg)
{
	struct alg_sock *ask = alg_sk(sk);
	const struct af_alg_type *type;
@@ -422,7 +423,7 @@ int af_alg_accept(struct sock *sk, struct socket *newsock, bool kern)
	if (!type)
		goto unlock;

	sk2 = sk_alloc(sock_net(sk), PF_ALG, GFP_KERNEL, &alg_proto, kern);
	sk2 = sk_alloc(sock_net(sk), PF_ALG, GFP_KERNEL, &alg_proto, arg->kern);
	err = -ENOMEM;
	if (!sk2)
		goto unlock;
@@ -468,10 +469,10 @@ int af_alg_accept(struct sock *sk, struct socket *newsock, bool kern)
}
EXPORT_SYMBOL_GPL(af_alg_accept);

static int alg_accept(struct socket *sock, struct socket *newsock, int flags,
		      bool kern)
static int alg_accept(struct socket *sock, struct socket *newsock,
		      struct proto_accept_arg *arg)
{
	return af_alg_accept(sock->sk, newsock, kern);
	return af_alg_accept(sock->sk, newsock, arg);
}

static const struct proto_ops alg_proto_ops = {
+5 −5
Original line number Diff line number Diff line
@@ -223,8 +223,8 @@ static int hash_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
	return err ?: len;
}

static int hash_accept(struct socket *sock, struct socket *newsock, int flags,
		       bool kern)
static int hash_accept(struct socket *sock, struct socket *newsock,
		       struct proto_accept_arg *arg)
{
	struct sock *sk = sock->sk;
	struct alg_sock *ask = alg_sk(sk);
@@ -252,7 +252,7 @@ static int hash_accept(struct socket *sock, struct socket *newsock, int flags,
	if (err)
		goto out_free_state;

	err = af_alg_accept(ask->parent, newsock, kern);
	err = af_alg_accept(ask->parent, newsock, arg);
	if (err)
		goto out_free_state;

@@ -355,7 +355,7 @@ static int hash_recvmsg_nokey(struct socket *sock, struct msghdr *msg,
}

static int hash_accept_nokey(struct socket *sock, struct socket *newsock,
			     int flags, bool kern)
			     struct proto_accept_arg *arg)
{
	int err;

@@ -363,7 +363,7 @@ static int hash_accept_nokey(struct socket *sock, struct socket *newsock,
	if (err)
		return err;

	return hash_accept(sock, newsock, flags, kern);
	return hash_accept(sock, newsock, arg);
}

static struct proto_ops algif_hash_ops_nokey = {
+5 −1
Original line number Diff line number Diff line
@@ -517,6 +517,10 @@ static void __pvcalls_back_accept(struct work_struct *work)
{
	struct sockpass_mapping *mappass = container_of(
		work, struct sockpass_mapping, register_work);
	struct proto_accept_arg arg = {
		.flags = O_NONBLOCK,
		.kern = true,
	};
	struct sock_mapping *map;
	struct pvcalls_ioworker *iow;
	struct pvcalls_fedata *fedata;
@@ -548,7 +552,7 @@ static void __pvcalls_back_accept(struct work_struct *work)
	sock->type = mappass->sock->type;
	sock->ops = mappass->sock->ops;

	ret = inet_accept(mappass->sock, sock, O_NONBLOCK, true);
	ret = inet_accept(mappass->sock, sock, &arg);
	if (ret == -EAGAIN) {
		sock_release(sock);
		return;
+4 −1
Original line number Diff line number Diff line
@@ -1784,6 +1784,9 @@ static int o2net_accept_one(struct socket *sock, int *more)
	struct o2nm_node *node = NULL;
	struct o2nm_node *local_node = NULL;
	struct o2net_sock_container *sc = NULL;
	struct proto_accept_arg arg = {
		.flags = O_NONBLOCK,
	};
	struct o2net_node *nn;
	unsigned int nofs_flag;

@@ -1802,7 +1805,7 @@ static int o2net_accept_one(struct socket *sock, int *more)

	new_sock->type = sock->type;
	new_sock->ops = sock->ops;
	ret = sock->ops->accept(sock, new_sock, O_NONBLOCK, false);
	ret = sock->ops->accept(sock, new_sock, &arg);
	if (ret < 0)
		goto out;

+2 −1
Original line number Diff line number Diff line
@@ -166,7 +166,8 @@ int af_alg_unregister_type(const struct af_alg_type *type);

int af_alg_release(struct socket *sock);
void af_alg_release_parent(struct sock *sk);
int af_alg_accept(struct sock *sk, struct socket *newsock, bool kern);
int af_alg_accept(struct sock *sk, struct socket *newsock,
		  struct proto_accept_arg *arg);

void af_alg_free_sg(struct af_alg_sgl *sgl);

Loading