All of lore.kernel.org
 help / color / mirror / Atom feed
From: "D. Wythe" <alibuda@linux.alibaba.com>
To: kgraul@linux.ibm.com, wenjia@linux.ibm.com, jaka@linux.ibm.com,
	ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org
Cc: kuba@kernel.org, davem@davemloft.net, netdev@vger.kernel.org,
	linux-s390@vger.kernel.org, linux-rdma@vger.kernel.org,
	bpf@vger.kernel.org
Subject: [PATCH bpf-next v3 3/4] net/smc: add BPF injection on smc negotiation
Date: Tue, 28 Feb 2023 17:24:53 +0800	[thread overview]
Message-ID: <1677576294-33411-4-git-send-email-alibuda@linux.alibaba.com> (raw)
In-Reply-To: <1677576294-33411-1-git-send-email-alibuda@linux.alibaba.com>

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


  parent reply	other threads:[~2023-02-28  9:25 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-28  9:24 [PATCH bpf-next v3 0/4] net/smc: Introduce BPF injection capability D. Wythe
2023-02-28  9:24 ` [PATCH bpf-next v3 1/4] net/smc: move smc_sock related structure definition D. Wythe
2023-02-28  9:24 ` [PATCH bpf-next v3 2/4] bpf: add SMC support in BPF struct_ops D. Wythe
2023-02-28  9:24 ` D. Wythe [this message]
2023-02-28 14:08   ` [PATCH bpf-next v3 3/4] net/smc: add BPF injection on smc negotiation kernel test robot
2023-02-28 15:54     ` D. Wythe
2023-02-28 16:08     ` D. Wythe
2023-02-28  9:24 ` [PATCH bpf-next v3 4/4] bpf/selftests: add selftest for SMC bpf capability D. Wythe
2023-02-28 23:00 ` [PATCH bpf-next v3 0/4] net/smc: Introduce BPF injection capability Jakub Kicinski
2023-03-01  2:40   ` D. Wythe
2023-03-01  2:41   ` Tony Lu
2023-03-01  3:24     ` Jakub Kicinski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1677576294-33411-4-git-send-email-alibuda@linux.alibaba.com \
    --to=alibuda@linux.alibaba.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=jaka@linux.ibm.com \
    --cc=kgraul@linux.ibm.com \
    --cc=kuba@kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=wenjia@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.