Commit 92ef0fd5 authored by Jens Axboe's avatar Jens Axboe
Browse files

net: change proto and proto_ops accept type



Rather than pass in flags, error pointer, and whether this is a kernel
invocation or not, add a struct proto_accept_arg struct as the argument.
This then holds all of these arguments, and prepares accept for being
able to pass back more information.

No functional changes in this patch.

Acked-by: default avatarJakub Kicinski <kuba@kernel.org>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent fe6532b4
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