Skip to content

Commit 5cc7fce

Browse files
Al Virokuba-moo
authored andcommitted
don't open-code kernel_accept() in rds_tcp_accept_one()
rds_tcp_accept_one() starts with a pretty much verbatim copy of kernel_accept(). Might as well use the real thing... That code went into mainline in 2009, kernel_accept() had been added in Aug 2006, the copyright on rds/tcp_listen.c is "Copyright (c) 2006 Oracle", so it's entirely possible that it predates the introduction of kernel_accept(). Signed-off-by: Al Viro <[email protected]> Link: https://patch.msgid.link/20250713180134.GC1880847@ZenIV Signed-off-by: Jakub Kicinski <[email protected]>
1 parent c34632d commit 5cc7fce

File tree

1 file changed

+2
-22
lines changed

1 file changed

+2
-22
lines changed

net/rds/tcp_listen.c

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,6 @@ int rds_tcp_accept_one(struct socket *sock)
105105
int conn_state;
106106
struct rds_conn_path *cp;
107107
struct in6_addr *my_addr, *peer_addr;
108-
struct proto_accept_arg arg = {
109-
.flags = O_NONBLOCK,
110-
.kern = true,
111-
};
112108
#if !IS_ENABLED(CONFIG_IPV6)
113109
struct in6_addr saddr, daddr;
114110
#endif
@@ -117,25 +113,9 @@ int rds_tcp_accept_one(struct socket *sock)
117113
if (!sock) /* module unload or netns delete in progress */
118114
return -ENETUNREACH;
119115

120-
ret = sock_create_lite(sock->sk->sk_family,
121-
sock->sk->sk_type, sock->sk->sk_protocol,
122-
&new_sock);
116+
ret = kernel_accept(sock, &new_sock, O_NONBLOCK);
123117
if (ret)
124-
goto out;
125-
126-
ret = sock->ops->accept(sock, new_sock, &arg);
127-
if (ret < 0)
128-
goto out;
129-
130-
/* sock_create_lite() does not get a hold on the owner module so we
131-
* need to do it here. Note that sock_release() uses sock->ops to
132-
* determine if it needs to decrement the reference count. So set
133-
* sock->ops after calling accept() in case that fails. And there's
134-
* no need to do try_module_get() as the listener should have a hold
135-
* already.
136-
*/
137-
new_sock->ops = sock->ops;
138-
__module_get(new_sock->ops->owner);
118+
return ret;
139119

140120
rds_tcp_keepalive(new_sock);
141121
if (!rds_tcp_tune(new_sock)) {

0 commit comments

Comments
 (0)