Commit 07603b23 authored by Ursula Braun's avatar Ursula Braun Committed by David S. Miller

net/smc: propagate file from SMC to TCP socket

fcntl(fd, F_SETOWN, getpid()) selects the recipient of SIGURG signals
that are delivered when out-of-band data arrives on socket fd.
If an SMC socket program makes use of such an fcntl() call, it fails
in case of fallback to TCP-mode. In case of fallback the traffic is
processed with the internal TCP socket. Propagating field "file" from the
SMC socket to the internal TCP socket fixes the issue.
Reviewed-by: default avatarKarsten Graul <kgraul@linux.ibm.com>
Signed-off-by: default avatarUrsula Braun <ubraun@linux.ibm.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e183d4e4
...@@ -2084,12 +2084,6 @@ static inline bool skwq_has_sleeper(struct socket_wq *wq) ...@@ -2084,12 +2084,6 @@ static inline bool skwq_has_sleeper(struct socket_wq *wq)
* @p: poll_table * @p: poll_table
* *
* See the comments in the wq_has_sleeper function. * See the comments in the wq_has_sleeper function.
*
* Do not derive sock from filp->private_data here. An SMC socket establishes
* an internal TCP socket that is used in the fallback case. All socket
* operations on the SMC socket are then forwarded to the TCP socket. In case of
* poll, the filp->private_data pointer references the SMC socket because the
* TCP socket has no file assigned.
*/ */
static inline void sock_poll_wait(struct file *filp, struct socket *sock, static inline void sock_poll_wait(struct file *filp, struct socket *sock,
poll_table *p) poll_table *p)
......
...@@ -445,10 +445,19 @@ static void smc_link_save_peer_info(struct smc_link *link, ...@@ -445,10 +445,19 @@ static void smc_link_save_peer_info(struct smc_link *link,
link->peer_mtu = clc->qp_mtu; link->peer_mtu = clc->qp_mtu;
} }
static void smc_switch_to_fallback(struct smc_sock *smc)
{
smc->use_fallback = true;
if (smc->sk.sk_socket && smc->sk.sk_socket->file) {
smc->clcsock->file = smc->sk.sk_socket->file;
smc->clcsock->file->private_data = smc->clcsock;
}
}
/* fall back during connect */ /* fall back during connect */
static int smc_connect_fallback(struct smc_sock *smc, int reason_code) static int smc_connect_fallback(struct smc_sock *smc, int reason_code)
{ {
smc->use_fallback = true; smc_switch_to_fallback(smc);
smc->fallback_rsn = reason_code; smc->fallback_rsn = reason_code;
smc_copy_sock_settings_to_clc(smc); smc_copy_sock_settings_to_clc(smc);
if (smc->sk.sk_state == SMC_INIT) if (smc->sk.sk_state == SMC_INIT)
...@@ -774,10 +783,14 @@ static void smc_connect_work(struct work_struct *work) ...@@ -774,10 +783,14 @@ static void smc_connect_work(struct work_struct *work)
smc->sk.sk_err = -rc; smc->sk.sk_err = -rc;
out: out:
if (smc->sk.sk_err) if (!sock_flag(&smc->sk, SOCK_DEAD)) {
smc->sk.sk_state_change(&smc->sk); if (smc->sk.sk_err) {
else smc->sk.sk_state_change(&smc->sk);
smc->sk.sk_write_space(&smc->sk); } else { /* allow polling before and after fallback decision */
smc->clcsock->sk->sk_write_space(smc->clcsock->sk);
smc->sk.sk_write_space(&smc->sk);
}
}
kfree(smc->connect_info); kfree(smc->connect_info);
smc->connect_info = NULL; smc->connect_info = NULL;
release_sock(&smc->sk); release_sock(&smc->sk);
...@@ -934,8 +947,13 @@ struct sock *smc_accept_dequeue(struct sock *parent, ...@@ -934,8 +947,13 @@ struct sock *smc_accept_dequeue(struct sock *parent,
sock_put(new_sk); /* final */ sock_put(new_sk); /* final */
continue; continue;
} }
if (new_sock) if (new_sock) {
sock_graft(new_sk, new_sock); sock_graft(new_sk, new_sock);
if (isk->use_fallback) {
smc_sk(new_sk)->clcsock->file = new_sock->file;
isk->clcsock->file->private_data = isk->clcsock;
}
}
return new_sk; return new_sk;
} }
return NULL; return NULL;
...@@ -1086,7 +1104,7 @@ static void smc_listen_decline(struct smc_sock *new_smc, int reason_code, ...@@ -1086,7 +1104,7 @@ static void smc_listen_decline(struct smc_sock *new_smc, int reason_code,
return; return;
} }
smc_conn_free(&new_smc->conn); smc_conn_free(&new_smc->conn);
new_smc->use_fallback = true; smc_switch_to_fallback(new_smc);
new_smc->fallback_rsn = reason_code; new_smc->fallback_rsn = reason_code;
if (reason_code && reason_code != SMC_CLC_DECL_PEERDECL) { if (reason_code && reason_code != SMC_CLC_DECL_PEERDECL) {
if (smc_clc_send_decline(new_smc, reason_code) < 0) { if (smc_clc_send_decline(new_smc, reason_code) < 0) {
...@@ -1246,7 +1264,7 @@ static void smc_listen_work(struct work_struct *work) ...@@ -1246,7 +1264,7 @@ static void smc_listen_work(struct work_struct *work)
/* check if peer is smc capable */ /* check if peer is smc capable */
if (!tcp_sk(newclcsock->sk)->syn_smc) { if (!tcp_sk(newclcsock->sk)->syn_smc) {
new_smc->use_fallback = true; smc_switch_to_fallback(new_smc);
new_smc->fallback_rsn = SMC_CLC_DECL_PEERNOSMC; new_smc->fallback_rsn = SMC_CLC_DECL_PEERNOSMC;
smc_listen_out_connected(new_smc); smc_listen_out_connected(new_smc);
return; return;
...@@ -1503,7 +1521,7 @@ static int smc_sendmsg(struct socket *sock, struct msghdr *msg, size_t len) ...@@ -1503,7 +1521,7 @@ static int smc_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)
if (msg->msg_flags & MSG_FASTOPEN) { if (msg->msg_flags & MSG_FASTOPEN) {
if (sk->sk_state == SMC_INIT) { if (sk->sk_state == SMC_INIT) {
smc->use_fallback = true; smc_switch_to_fallback(smc);
smc->fallback_rsn = SMC_CLC_DECL_OPTUNSUPP; smc->fallback_rsn = SMC_CLC_DECL_OPTUNSUPP;
} else { } else {
rc = -EINVAL; rc = -EINVAL;
...@@ -1705,7 +1723,7 @@ static int smc_setsockopt(struct socket *sock, int level, int optname, ...@@ -1705,7 +1723,7 @@ static int smc_setsockopt(struct socket *sock, int level, int optname,
case TCP_FASTOPEN_NO_COOKIE: case TCP_FASTOPEN_NO_COOKIE:
/* option not supported by SMC */ /* option not supported by SMC */
if (sk->sk_state == SMC_INIT) { if (sk->sk_state == SMC_INIT) {
smc->use_fallback = true; smc_switch_to_fallback(smc);
smc->fallback_rsn = SMC_CLC_DECL_OPTUNSUPP; smc->fallback_rsn = SMC_CLC_DECL_OPTUNSUPP;
} else { } else {
if (!smc->use_fallback) if (!smc->use_fallback)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment