From: "D. Wythe" <alibuda@xxxxxxxxxxxxxxxxx> This patch is a refactoring for smc_accept(), the extracted __smc_accept() make it possible to obtain the accepted sock when an NULL clcsock passed in. In that way, the inet version of SMC can access the accepted sock without providing a faked clcsock. Signed-off-by: D. Wythe <alibuda@xxxxxxxxxxxxxxxxx> --- net/smc/af_smc.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c index 484e981..e0505d6 100644 --- a/net/smc/af_smc.c +++ b/net/smc/af_smc.c @@ -2684,17 +2684,16 @@ static int smc_listen(struct socket *sock, int backlog) return rc; } -static int smc_accept(struct socket *sock, struct socket *new_sock, - int flags, bool kern) +static struct sock *__smc_accept(struct sock *sk, struct socket *new_sock, + int flags, int *err, bool kern) { - struct sock *sk = sock->sk, *nsk; DECLARE_WAITQUEUE(wait, current); + struct sock *nsk = NULL; struct smc_sock *lsmc; long timeo; int rc = 0; lsmc = smc_sk(sk); - sock_hold(sk); /* sock_put below */ lock_sock(sk); if (smc_sk_state(&lsmc->sk) != SMC_LISTEN) { @@ -2750,8 +2749,21 @@ static int smc_accept(struct socket *sock, struct socket *new_sock, } out: - sock_put(sk); /* sock_hold above */ - return rc; + *err = rc; + return nsk; +} + +static int smc_accept(struct socket *sock, struct socket *new_sock, + int flags, bool kern) +{ + struct sock *sk = sock->sk; + int error; + + sock_hold(sk); + __smc_accept(sk, new_sock, flags, &error, kern); + sock_put(sk); + + return error; } static int smc_getname(struct socket *sock, struct sockaddr *addr, -- 1.8.3.1