Thread (12 messages) 12 messages, 4 authors, 2023-03-01
STALE1188d
Revisions (7)
  1. v3 current
  2. v4 [diff vs current]
  3. rfc [diff vs current]
  4. v2 [diff vs current]
  5. v3 [diff vs current]
  6. v1 [diff vs current]
  7. v1 [diff vs current]

[PATCH bpf-next v3 3/4] net/smc: add BPF injection on smc negotiation

From: "D. Wythe" <alibuda@linux.alibaba.com>
Date: 2023-02-28 09:25:11
Also in: bpf, linux-rdma, linux-s390
Subsystem: networking [general], shared memory communications (smc) sockets, the rest · Maintainers: "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, D. Wythe, Dust Li, Sidraya Jayagond, Wenjia Zhang, Linus Torvalds

From: "D. Wythe" <alibuda@linux.alibaba.com>

This patch try add BPF injection on smc negotiation, so that
the application can decided whether to use smc or not through
eBPF progs.

In particular, some applications may need global dynamic information
to make decision. Therefore, we also inject a information collect
point into smc_release.

Note that, in order to make negotiation can be decided by application,
sockets must have SMC_LIMIT_HS set.

Signed-off-by: D. Wythe <alibuda@linux.alibaba.com>
---
 net/smc/af_smc.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c
index a4cccdf..7ebe5e8 100644
--- a/net/smc/af_smc.c
+++ b/net/smc/af_smc.c
@@ -166,6 +166,9 @@ static bool smc_hs_congested(const struct sock *sk)
 	if (workqueue_congested(WORK_CPU_UNBOUND, smc_hs_wq))
 		return true;
 
+	if (!smc_sock_should_select_smc(smc))
+		return true;
+
 	return false;
 }
 
@@ -320,6 +323,9 @@ static int smc_release(struct socket *sock)
 	sock_hold(sk); /* sock_put below */
 	smc = smc_sk(sk);
 
+	/* trigger info gathering if needed.*/
+	smc_sock_perform_collecting_info(sk, SMC_SOCK_CLOSED_TIMING);
+
 	old_state = sk->sk_state;
 
 	/* cleanup for a dangling non-blocking connect */
@@ -1627,7 +1633,14 @@ static int smc_connect(struct socket *sock, struct sockaddr *addr,
 	}
 
 	smc_copy_sock_settings_to_clc(smc);
-	tcp_sk(smc->clcsock->sk)->syn_smc = 1;
+	/* accept out connection as SMC connection */
+	if (smc_sock_should_select_smc(smc) == SK_PASS) {
+		tcp_sk(smc->clcsock->sk)->syn_smc = 1;
+	} else {
+		tcp_sk(smc->clcsock->sk)->syn_smc = 0;
+		smc_switch_to_fallback(smc, /* just a chooice */ 0);
+	}
+
 	if (smc->connect_nonblock) {
 		rc = -EALREADY;
 		goto out;
-- 
1.8.3.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help