net/smc: Introduce BPF injection capability
Subsystems (8)
D. Wythe
maintainerv3 cover net/smc: Introduce BPF injection capability
From: "D. Wythe" <[email protected]>
This patches attempt to introduce BPF injection capability for SMC, and add selftest to ensure code stability.
As we all know that the SMC protocol is not suitable for all scenarios, especially for short-lived. However, for most applications, they cannot guarantee that there are no such scenarios at all. Therefore, apps may need some specific strategies to decide shall we need to use SMC or not, for example, apps can limit the scope of the SMC to a specific IP address or port.
Based on the consideration of transparent replacement, we hope that apps can remain transparent even if they need to formulate some specific strategies for SMC using. That is, do not need to recompile their code.
On the other hand, we need to ensure the scalability of strategies implementation. Although it is simple to use socket options or sysctl, it will bring more complexity to subsequent expansion.
Fortunately, BPF can solve these concerns very well, users can write thire own strategies in eBPF to choose whether to use SMC or not. And it's quite easy for them to modify their strategies in the future.
This patches implement injection capability for SMC via struct_ops. In that way, we can add new injection scenarios in the future.
v3 -> v2:
1. fix checkpatch error and warning.
2. split patch for better review.
3. enhance selftest to cover more scenarios.
v2 -> v1:
1. fix compile error and warning.
D. Wythe (4):
net/smc: move smc_sock related structure definition
bpf: add SMC support in BPF struct_ops net/smc: add BPF injection on smc negotiation bpf/selftests: add selftest for SMC bpf capability
include/linux/btf_ids.h | 12 + include/net/smc.h | 248 ++++++++++++++++++ kernel/bpf/bpf_struct_ops_types.h | 4 + net/Makefile | 5 + net/smc/af_smc.c | 15 +- net/smc/bpf_smc_struct_ops.c | 148 +++++++++++ net/smc/smc.h | 224 ---------------- tools/testing/selftests/bpf/prog_tests/bpf_smc.c | 37 +++ tools/testing/selftests/bpf/progs/bpf_smc.c | 320 +++++++++++++++++++++++ 9 files changed, 788 insertions(+), 225 deletions(-) create mode 100644 net/smc/bpf_smc_struct_ops.c create mode 100644 tools/testing/selftests/bpf/prog_tests/bpf_smc.c create mode 100644 tools/testing/selftests/bpf/progs/bpf_smc.c
Signature · 1 line
1.8.3.1
D. Wythe
maintainerPATCH v3 1/4 net/smc: move smc_sock related structure definition
From: "D. Wythe" <[email protected]>
This patch only try to move the definition of smc_sock and its related structure, from et/smc/smc.h to include/net/smc/smc.h. In that way can ebpf generate the BTF ID corresponding to our structure.
Of course, we can also choose to hide the structure and only to expose an intermediate structure, but it requires an additional transformation. If we need to obtain some information frequently, this may cause some performance problems.
--- include/net/smc.h | 225 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ net/smc/smc.h | 224 ----------------------------------------------------- 2 files changed, 225 insertions(+), 224 deletions(-)
include/net/smc.h +225 -0
@@ -11,12 +11,17 @@#ifndef _SMC_H#define _SMC_H +#include <net/inet_connection_sock.h> #include <linux/device.h> #include <linux/spinlock.h> #include <linux/types.h> #include <linux/wait.h> #include "linux/ism.h" +#ifdef ATOMIC64_INIT +#define KERNEL_HAS_ATOMIC64 +#endif +struct sock ;#define SMC_MAX_PNETID_LEN 16/* Max. length of PNET id */
@@ -90,4 +95,224 @@ struct smcd_dev { u8 going_away : 1; }; +struct smc_wr_rx_hdr {/* common prefix part of LLC and CDC to demultiplex */ +union { +u8 type; +#if defined(__BIG_ENDIAN_BITFIELD) +struct { +u8 llc_version:4 , + llc_type:4 ; + }; +#elif defined(__LITTLE_ENDIAN_BITFIELD) +struct { +u8 llc_type:4 , + llc_version:4 ; + }; +#endif + }; +}__aligned(1) ; + +struct smc_cdc_conn_state_flags { +#if defined(__BIG_ENDIAN_BITFIELD) +u8 peer_done_writing :1 ;/* Sending done indicator */ +u8 peer_conn_closed :1 ;/* Peer connection closed indicator */ +u8 peer_conn_abort :1 ;/* Abnormal close indicator */ +u8 reserved :5 ; +#elif defined(__LITTLE_ENDIAN_BITFIELD) +u8 reserved :5 ; +u8 peer_conn_abort :1 ; +u8 peer_conn_closed :1 ; +u8 peer_done_writing :1 ; +#endif +}; + +struct smc_cdc_producer_flags { +#if defined(__BIG_ENDIAN_BITFIELD) +u8 write_blocked :1 ;/* Writing Blocked, no rx buf space */ +u8 urg_data_pending :1 ;/* Urgent Data Pending */ +u8 urg_data_present :1 ;/* Urgent Data Present */ +u8 cons_curs_upd_req :1 ;/* cursor update requested */ +u8 failover_validation :1 ;/* message replay due to failover */ +u8 reserved :3 ; +#elif defined(__LITTLE_ENDIAN_BITFIELD) +u8 reserved :3 ; +u8 failover_validation :1 ; +u8 cons_curs_upd_req :1 ; +u8 urg_data_present :1 ; +u8 urg_data_pending :1 ; +u8 write_blocked :1 ; +#endif +}; + +/* in host byte order */ +union smc_host_cursor {/* SMC cursor - an offset in an RMBE */ +struct { +u16 reserved; +u16 wrap;/* window wrap sequence number */ +u32 count;/* cursor (= offset) part */ + }; +#ifdef KERNEL_HAS_ATOMIC64 +atomic64_t acurs;/* for atomic processing */ +#else +u64 acurs;/* for atomic processing */ +#endif +}__aligned(8) ; + +/* in host byte order, except for flag bitfields in network byte order */ +struct smc_host_cdc_msg {/* Connection Data Control message */ +struct smc_wr_rx_hdr common;/* .type = 0xFE */ +u8 len;/* length = 44 */ +u16 seqno;/* connection seq # */ +u32 token;/* alert_token */ +union smc_host_cursor prod;/* producer cursor */ +union smc_host_cursor cons;/* consumer cursor, +* piggy backed "ack" +*/ +struct smc_cdc_producer_flags prod_flags;/* conn. tx/rx status */ +struct smc_cdc_conn_state_flags conn_state_flags;/* peer conn. status*/ +u8 reserved[18 ]; +}__aligned(8) ; + +enum smc_urg_state { +SMC_URG_VALID =1 ,/* data present */ +SMC_URG_NOTYET =2 ,/* data pending */ +SMC_URG_READ =3 ,/* data was already read */ +}; + +struct smc_connection { +struct rb_node alert_node; +struct smc_link_group *lgr;/* link group of connection */ +struct smc_link *lnk;/* assigned SMC-R link */ +u32 alert_token_local;/* unique conn. id */ +u8 peer_rmbe_idx;/* from tcp handshake */ +int peer_rmbe_size;/* size of peer rx buffer */ +atomic_t peer_rmbe_space;/* remaining free bytes in peer +* rmbe +*/ +int rtoken_idx;/* idx to peer RMB rkey/addr */ + +struct smc_buf_desc *sndbuf_desc;/* send buffer descriptor */ +struct smc_buf_desc *rmb_desc;/* RMBE descriptor */ +int rmbe_size_short;/* compressed notation */ +int rmbe_update_limit; +/* lower limit for consumer +* cursor update +*/ + +struct smc_host_cdc_msg local_tx_ctrl;/* host byte order staging +* buffer for CDC msg send +* .prod cf. TCP snd_nxt +* .cons cf. TCP sends ack +*/ +union smc_host_cursor local_tx_ctrl_fin; +/* prod crsr - confirmed by peer +*/ +union smc_host_cursor tx_curs_prep;/* tx - prepared data +* snd_max..wmem_alloc +*/ +union smc_host_cursor tx_curs_sent;/* tx - sent data +* snd_nxt ? +*/ +union smc_host_cursor tx_curs_fin;/* tx - confirmed by peer +* snd-wnd-begin ? +*/ +atomic_t sndbuf_space;/* remaining space in sndbuf */ +u16 tx_cdc_seq;/* sequence # for CDC send */ +u16 tx_cdc_seq_fin;/* sequence # - tx completed */ +spinlock_t send_lock;/* protect wr_sends */ +atomic_t cdc_pend_tx_wr;/* number of pending tx CDC wqe +* - inc when post wqe, +* - dec on polled tx cqe +*/ +wait_queue_head_t cdc_pend_tx_wq;/* wakeup on no cdc_pend_tx_wr*/ +atomic_t tx_pushing;/* nr_threads trying tx push */ +struct delayed_work tx_work;/* retry of smc_cdc_msg_send */ +u32 tx_off;/* base offset in peer rmb */ + +struct smc_host_cdc_msg local_rx_ctrl;/* filled during event_handl. +* .prod cf. TCP rcv_nxt +* .cons cf. TCP snd_una +*/ +union smc_host_cursor rx_curs_confirmed;/* confirmed to peer +* source of snd_una ? +*/ +union smc_host_cursor urg_curs;/* points at urgent byte */ +enum smc_urg_state urg_state; +bool urg_tx_pend;/* urgent data staged */ +bool urg_rx_skip_pend; +/* indicate urgent oob data +* read, but previous regular +* data still pending +*/ +char urg_rx_byte;/* urgent byte */ +bool tx_in_release_sock; +/* flush pending tx data in +* sock release_cb() +*/ +atomic_t bytes_to_rcv;/* arrived data, +* not yet received +*/ +atomic_t splice_pending;/* number of spliced bytes +* pending processing +*/ +#ifndef KERNEL_HAS_ATOMIC64 +spinlock_t acurs_lock;/* protect cursors */ +#endif +struct work_struct close_work;/* peer sent some closing */ +struct work_struct abort_work;/* abort the connection */ +struct tasklet_struct rx_tsklet;/* Receiver tasklet for SMC-D */ +u8 rx_off;/* receive offset: +* 0 for SMC-R, 32 for SMC-D +*/ +u64 peer_token;/* SMC-D token of peer */ +u8 killed :1 ;/* abnormal termination */ +u8 freed :1 ;/* normal termiation */ +u8 out_of_sync :1 ;/* out of sync with peer */ +}; + +struct smc_sock {/* smc sock container */ +struct sock sk; +struct socket *clcsock;/* internal tcp socket */ +void (*clcsk_state_change)(struct sock *sk); +/* original stat_change fct. */ +void (*clcsk_data_ready)(struct sock *sk); +/* original data_ready fct. */ +void (*clcsk_write_space)(struct sock *sk); +/* original write_space fct. */ +void (*clcsk_error_report)(struct sock *sk); +/* original error_report fct. */ +struct smc_connection conn;/* smc connection */ +struct smc_sock *listen_smc;/* listen parent */ +struct work_struct connect_work;/* handle non-blocking connect*/ +struct work_struct tcp_listen_work;/* handle tcp socket accepts */ +struct work_struct smc_listen_work;/* prepare new accept socket */ +struct list_head accept_q;/* sockets to be accepted */ +spinlock_t accept_q_lock;/* protects accept_q */ +bool limit_smc_hs;/* put constraint on handshake */ +bool use_fallback;/* fallback to tcp */ +int fallback_rsn;/* reason for fallback */ +u32 peer_diagnosis;/* decline reason from peer */ +atomic_t queued_smc_hs;/* queued smc handshakes */ +struct inet_connection_sock_af_ops af_ops; +const struct inet_connection_sock_af_ops *ori_af_ops; +/* original af ops */ +int sockopt_defer_accept; +/* sockopt TCP_DEFER_ACCEPT +* value +*/ +u8 wait_close_tx_prepared :1 ; +/* shutdown wr or close +* started, waiting for unsent +* data to be sent +*/ +u8 connect_nonblock :1 ; +/* non-blocking connect in +* flight +*/ +struct mutex clcsock_release_lock; +/* protects clcsock of a listen +* socket +*/ +}; +#endif /* _SMC_H */
net/smc/smc.h +0 -224
242 lines not on this page · raw message
Signature · 1 line
1.8.3.1
D. Wythe
maintainerPATCH v3 2/4 bpf: add SMC support in BPF struct_ops
In reply to D. WytheFrom: "D. Wythe" <[email protected]>
This PATCH attempts to introduce BPF injection capability for SMC. Considering that the SMC protocol is not suitable for all scenarios, especially for short-lived. However, for most applications, they cannot guarantee that there are no such scenarios at all. Therefore, apps may need some specific strategies to decide shall we need to use SMC or not, for example, apps can limit the scope of the SMC to a specific IP address or port.
Based on the consideration of transparent replacement, we hope that apps can remain transparent even if they need to formulate some specific strategies for SMC using. That is, do not need to recompile their code.
On the other hand, we need to ensure the scalability of strategies implementation. Although it is simple to use socket options or sysctl, it will bring more complexity to subsequent expansion.
Fortunately, BPF can solve these concerns very well, users can write thire own strategies in eBPF to choose whether to use SMC or not. And it's quite easy for them to modify their strategies in the future.
This PATCH implement injection capability for SMC via struct_ops. In that way, we can add new injection scenarios in the future.
--- include/linux/btf_ids.h | 12 ++++ include/net/smc.h | 23 ++++++ kernel/bpf/bpf_struct_ops_types.h | 4 ++ net/Makefile | 5 ++ net/smc/bpf_smc_struct_ops.c | 148 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 192 insertions(+) create mode 100644 net/smc/bpf_smc_struct_ops.c
include/linux/btf_ids.h +12 -0
@@ -264,6 +264,18 @@ enum { MAX_BTF_TRACING_TYPE, }; +#if IS_ENABLED (CONFIG_SMC ) +enum { +#define BTF_SMC_TYPE(name, type) name, +BTF_SMC_TYPE(BTF_SMC_TYPE_SOCK, smc_sock) +BTF_SMC_TYPE(BTF_SMC_TYPE_CONNECTION, smc_connection) +BTF_SMC_TYPE(BTF_SMC_TYPE_HOST_CURSOR, smc_host_cursor) +#undef BTF_SMC_TYPE +MAX_BTF_SMC_TYPE, +}; +extern u32 btf_smc_ids[]; +#endif +extern u32 btf_tracing_ids[];extern u32 bpf_cgroup_btf_id[];extern u32 bpf_local_storage_map_btf_id[];
include/net/smc.h +23 -0
@@ -16,6 +16,7 @@#include <linux/spinlock.h> #include <linux/types.h> #include <linux/wait.h> +#include <linux/bpf.h> #include "linux/ism.h" #ifdef ATOMIC64_INIT
@@ -315,4 +316,26 @@ struct smc_sock { /* smc sock container */ */ }; +#define SMC_SOCK_CLOSED_TIMING (0) + +/* BPF struct ops for smc protocol negotiator */ +struct smc_sock_negotiator_ops { +/* ret for negotiate */ +int (*negotiate)(struct smc_sock *sk); + +/* info gathering timing */ +void (*collect_info)(struct sock *sk,int timing); +}; + +/* Query if current sock should go with SMC protocol +* SK_PASS for yes, otherwise for no. +*/ +int smc_sock_should_select_smc (const struct smc_sock *smc); + +/* At some specific points in time, +* let negotiator can perform info gathering +* on target sock. +*/ +void smc_sock_perform_collecting_info (const struct sock *sk,int timing); +#endif /* _SMC_H */
kernel/bpf/bpf_struct_ops_types.h +4 -0
@@ -9,4 +9,8 @@#include <net/tcp.h> BPF_STRUCT_OPS_TYPE(tcp_congestion_ops)#endif +#if IS_ENABLED (CONFIG_SMC ) +#include <net/smc.h> +BPF_STRUCT_OPS_TYPE(smc_sock_negotiator_ops) +#endif #endif
net/Makefile +5 -0
@@ -52,6 +52,11 @@ obj-$(CONFIG_TIPC) += tipc/ obj-$(CONFIG_NETLABEL) += netlabel/ obj-$(CONFIG_IUCV) += iucv/ obj-$(CONFIG_SMC) += smc/ +ifneq ($(CONFIG_SMC),) +ifeq ($(CONFIG_BPF_SYSCALL),y) +obj-y += smc/bpf_smc_struct_ops.o +endif +endif obj-$(CONFIG_RFKILL) += rfkill/ obj-$(CONFIG_NET_9P) += 9p/ obj-$(CONFIG_CAIF) += caif/
net/smc/bpf_smc_struct_ops.c new file +148 -0
148 lines not on this page · raw message
Signature · 1 line
1.8.3.1
D. Wythe
maintainerPATCH v3 3/4 net/smc: add BPF injection on smc negotiation
In reply to D. WytheFrom: "D. Wythe" <[email protected]>
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.
--- net/smc/af_smc.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
net/smc/af_smc.c +14 -1
@@ -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;
Signature · 1 line
1.8.3.1
kernel test robot
build botRe: [PATCH bpf-next v3 3/4] net/smc: add BPF injection on smc negotiation
Thank you for the patch! Yet something to improve:
Hi Wythe,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on bpf-next/master]
url: https://github.com/intel-lab-lkp/linux/commits/D-Wythe/net-smc-move-smc_sock-related-structure-definition/20230228-173007 base: https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master patch link: https://lore.kernel.org/r/1677576294-33411-4-git-send-email-alibuda%40linux.alibaba.com patch subject: [PATCH bpf-next v3 3/4] net/smc: add BPF injection on smc negotiation config: x86_64-randconfig-a015-20230227 (https://download.01.org/0day-ci/archive/20230228/[email protected]/config) compiler: gcc-11 (Debian 11.3.0-8) 11.3.0 reproduce (this is a W=1 build): # https://github.com/intel-lab-lkp/linux/commit/aa482ab82f4bf9b99d490f8ba5d88e1491156ccf git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review D-Wythe/net-smc-move-smc_sock-related-structure-definition/20230228-173007 git checkout aa482ab82f4bf9b99d490f8ba5d88e1491156ccf # save the config file mkdir build_dir && cp config build_dir/.config make W=1 O=build_dir ARCH=x86_64 olddefconfig make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
ld: net/smc/af_smc.o: in function `smc_hs_congested':
>> net/smc/af_smc.c:169: undefined reference to `smc_sock_should_select_smc' ld: net/smc/af_smc.o: in function `smc_release': >> net/smc/af_smc.c:327: undefined reference to `smc_sock_perform_collecting_info'
ld: net/smc/af_smc.o: in function `smc_connect':
net/smc/af_smc.c:1637: undefined reference to `smc_sock_should_select_smc'
vim +169 net/smc/af_smc.c
156
157 static bool smc_hs_congested(const struct sock *sk)
158 {
159 const struct smc_sock *smc;
160
161 smc = smc_clcsock_user_data(sk);
162
163 if (!smc)
164 return true;
165
166 if (workqueue_congested(WORK_CPU_UNBOUND, smc_hs_wq))
167 return true;
168
> 169 if (!smc_sock_should_select_smc(smc))
170 return true;
171
172 return false;
173 }
174
175 static struct smc_hashinfo smc_v4_hashinfo = {
176 .lock = __RW_LOCK_UNLOCKED(smc_v4_hashinfo.lock),
177 };
178
179 static struct smc_hashinfo smc_v6_hashinfo = {
180 .lock = __RW_LOCK_UNLOCKED(smc_v6_hashinfo.lock),
181 };
182
183 int smc_hash_sk(struct sock *sk)
184 {
185 struct smc_hashinfo *h = sk->sk_prot->h.smc_hash;
186 struct hlist_head *head;
187
188 head = &h->ht;
189
190 write_lock_bh(&h->lock);
191 sk_add_node(sk, head);
192 write_unlock_bh(&h->lock);
193 sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1);
194
195 return 0;
196 }
197 EXPORT_SYMBOL_GPL(smc_hash_sk);
198
199 void smc_unhash_sk(struct sock *sk)
200 {
201 struct smc_hashinfo *h = sk->sk_prot->h.smc_hash;
202
203 write_lock_bh(&h->lock);
204 if (sk_del_node_init(sk))
205 sock_prot_inuse_add(sock_net(sk), sk->sk_prot, -1);
206 write_unlock_bh(&h->lock);
207 }
208 EXPORT_SYMBOL_GPL(smc_unhash_sk);
209
210 /* This will be called before user really release sock_lock. So do the
211 * work which we didn't do because of user hold the sock_lock in the
212 * BH context
213 */
214 static void smc_release_cb(struct sock *sk)
215 {
216 struct smc_sock *smc = smc_sk(sk);
217
218 if (smc->conn.tx_in_release_sock) {
219 smc_tx_pending(&smc->conn);
220 smc->conn.tx_in_release_sock = false;
221 }
222 }
223
224 struct proto smc_proto = {
225 .name = "SMC",
226 .owner = THIS_MODULE,
227 .keepalive = smc_set_keepalive,
228 .hash = smc_hash_sk,
229 .unhash = smc_unhash_sk,
230 .release_cb = smc_release_cb,
231 .obj_size = sizeof(struct smc_sock),
232 .h.smc_hash = &smc_v4_hashinfo,
233 .slab_flags = SLAB_TYPESAFE_BY_RCU,
234 };
235 EXPORT_SYMBOL_GPL(smc_proto);
236
237 struct proto smc_proto6 = {
238 .name = "SMC6",
239 .owner = THIS_MODULE,
240 .keepalive = smc_set_keepalive,
241 .hash = smc_hash_sk,
242 .unhash = smc_unhash_sk,
243 .release_cb = smc_release_cb,
244 .obj_size = sizeof(struct smc_sock),
245 .h.smc_hash = &smc_v6_hashinfo,
246 .slab_flags = SLAB_TYPESAFE_BY_RCU,
247 };
248 EXPORT_SYMBOL_GPL(smc_proto6);
249
250 static void smc_fback_restore_callbacks(struct smc_sock *smc)
251 {
252 struct sock *clcsk = smc->clcsock->sk;
253
254 write_lock_bh(&clcsk->sk_callback_lock);
255 clcsk->sk_user_data = NULL;
256
257 smc_clcsock_restore_cb(&clcsk->sk_state_change, &smc->clcsk_state_change);
258 smc_clcsock_restore_cb(&clcsk->sk_data_ready, &smc->clcsk_data_ready);
259 smc_clcsock_restore_cb(&clcsk->sk_write_space, &smc->clcsk_write_space);
260 smc_clcsock_restore_cb(&clcsk->sk_error_report, &smc->clcsk_error_report);
261
262 write_unlock_bh(&clcsk->sk_callback_lock);
263 }
264
265 static void smc_restore_fallback_changes(struct smc_sock *smc)
266 {
267 if (smc->clcsock->file) { /* non-accepted sockets have no file yet */
268 smc->clcsock->file->private_data = smc->sk.sk_socket;
269 smc->clcsock->file = NULL;
270 smc_fback_restore_callbacks(smc);
271 }
272 }
273
274 static int __smc_release(struct smc_sock *smc)
275 {
276 struct sock *sk = &smc->sk;
277 int rc = 0;
278
279 if (!smc->use_fallback) {
280 rc = smc_close_active(smc);
281 sock_set_flag(sk, SOCK_DEAD);
282 sk->sk_shutdown |= SHUTDOWN_MASK;
283 } else {
284 if (sk->sk_state != SMC_CLOSED) {
285 if (sk->sk_state != SMC_LISTEN &&
286 sk->sk_state != SMC_INIT)
287 sock_put(sk); /* passive closing */
288 if (sk->sk_state == SMC_LISTEN) {
289 /* wake up clcsock accept */
290 rc = kernel_sock_shutdown(smc->clcsock,
291 SHUT_RDWR);
292 }
293 sk->sk_state = SMC_CLOSED;
294 sk->sk_state_change(sk);
295 }
296 smc_restore_fallback_changes(smc);
297 }
298
299 sk->sk_prot->unhash(sk);
300
301 if (sk->sk_state == SMC_CLOSED) {
302 if (smc->clcsock) {
303 release_sock(sk);
304 smc_clcsock_release(smc);
305 lock_sock(sk);
306 }
307 if (!smc->use_fallback)
308 smc_conn_free(&smc->conn);
309 }
310
311 return rc;
312 }
313
314 static int smc_release(struct socket *sock)
315 {
316 struct sock *sk = sock->sk;
317 struct smc_sock *smc;
318 int old_state, rc = 0;
319
320 if (!sk)
321 goto out;
322
323 sock_hold(sk); /* sock_put below */
324 smc = smc_sk(sk);
325
326 /* trigger info gathering if needed.*/
> 327 smc_sock_perform_collecting_info(sk, SMC_SOCK_CLOSED_TIMING); 328
329 old_state = sk->sk_state;
330
331 /* cleanup for a dangling non-blocking connect */
332 if (smc->connect_nonblock && old_state == SMC_INIT)
333 tcp_abort(smc->clcsock->sk, ECONNABORTED);
334
335 if (cancel_work_sync(&smc->connect_work))
336 sock_put(&smc->sk); /* sock_hold in smc_connect for passive closing */
337
338 if (sk->sk_state == SMC_LISTEN)
339 /* smc_close_non_accepted() is called and acquires
340 * sock lock for child sockets again
341 */
342 lock_sock_nested(sk, SINGLE_DEPTH_NESTING);
343 else
344 lock_sock(sk);
345
346 if (old_state == SMC_INIT && sk->sk_state == SMC_ACTIVE &&
347 !smc->use_fallback)
348 smc_close_active_abort(smc);
349
350 rc = __smc_release(smc);
351
352 /* detach socket */
353 sock_orphan(sk);
354 sock->sk = NULL;
355 release_sock(sk);
356
357 sock_put(sk); /* sock_hold above */
358 sock_put(sk); /* final sock_put */
359 out:
360 return rc;
361 }
362
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests
D. Wythe
maintainerRe: [PATCH bpf-next v3 3/4] net/smc: add BPF injection on smc negotiation
Hi robot,
It's seems impossible. I have compiled and tested this patch locally for many times. Maybe you compiled this patch separately. However, this patch depends on the previous one.
Thanks
D. Wythe
Quoted 246 lines · kernel test robot
Hi Wythe,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on bpf-next/master]
url: https://github.com/intel-lab-lkp/linux/commits/D-Wythe/net-smc-move-smc_sock-related-structure-definition/20230228-173007 base: https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master patch link: https://lore.kernel.org/r/1677576294-33411-4-git-send-email-alibuda%40linux.alibaba.com patch subject: [PATCH bpf-next v3 3/4] net/smc: add BPF injection on smc negotiation config: x86_64-randconfig-a015-20230227 (https://download.01.org/0day-ci/archive/20230228/[email protected]/config) compiler: gcc-11 (Debian 11.3.0-8) 11.3.0 reproduce (this is a W=1 build): # https://github.com/intel-lab-lkp/linux/commit/aa482ab82f4bf9b99d490f8ba5d88e1491156ccf git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review D-Wythe/net-smc-move-smc_sock-related-structure-definition/20230228-173007 git checkout aa482ab82f4bf9b99d490f8ba5d88e1491156ccf # save the config file mkdir build_dir && cp config build_dir/.config make W=1 O=build_dir ARCH=x86_64 olddefconfig make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bashIf you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/All errors (new ones prefixed by >>):
ld:
net/smc/af_smc.o: in function `smc_hs_congested':Quoted 1 line
Quoted 1 line
net/smc/af_smc.c:169: undefined reference to `smc_sock_should_select_smc'ld:
net/smc/af_smc.o: in function `smc_release':Quoted 1 line
Quoted 1 line
net/smc/af_smc.c:327: undefined reference to `smc_sock_perform_collecting_info'ld:
net/smc/af_smc.o: in function `smc_connect':
net/smc/af_smc.c:1637: undefined reference to `smc_sock_should_select_smc'vim +169
net/smc/af_smc.c156 157 static bool smc_hs_congested(const struct sock *sk) 158 { 159 const struct smc_sock *smc; 160 161 smc = smc_clcsock_user_data(sk); 162 163 if (!smc) 164 return true; 165 166 if (workqueue_congested(WORK_CPU_UNBOUND, smc_hs_wq)) 167 return true; 168Quoted 1 line
169 if (!smc_sock_should_select_smc(smc))
170 return true; 171 172 return false; 173 } 174 175 static struct smc_hashinfo smc_v4_hashinfo = { 176 .lock = __RW_LOCK_UNLOCKED(smc_v4_hashinfo.lock), 177 }; 178 179 static struct smc_hashinfo smc_v6_hashinfo = { 180 .lock = __RW_LOCK_UNLOCKED(smc_v6_hashinfo.lock), 181 }; 182 183 int smc_hash_sk(struct sock *sk) 184 { 185 struct smc_hashinfo *h = sk->sk_prot->h.smc_hash; 186 struct hlist_head *head; 187 188 head = &h->ht; 189 190 write_lock_bh(&h->lock); 191 sk_add_node(sk, head); 192 write_unlock_bh(&h->lock); 193 sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1); 194 195 return 0; 196 } 197 EXPORT_SYMBOL_GPL(smc_hash_sk); 198 199 void smc_unhash_sk(struct sock *sk) 200 { 201 struct smc_hashinfo *h = sk->sk_prot->h.smc_hash; 202 203 write_lock_bh(&h->lock); 204 if (sk_del_node_init(sk)) 205 sock_prot_inuse_add(sock_net(sk), sk->sk_prot, -1); 206 write_unlock_bh(&h->lock); 207 } 208 EXPORT_SYMBOL_GPL(smc_unhash_sk); 209 210 /* This will be called before user really release sock_lock. So do the 211 * work which we didn't do because of user hold the sock_lock in the 212 * BH context 213 */ 214 static void smc_release_cb(struct sock *sk) 215 { 216 struct smc_sock *smc = smc_sk(sk); 217 218 if (smc->conn.tx_in_release_sock) { 219 smc_tx_pending(&smc->conn); 220 smc->conn.tx_in_release_sock = false; 221 } 222 } 223 224 struct proto smc_proto = { 225 .name = "SMC", 226 .owner = THIS_MODULE, 227 .keepalive = smc_set_keepalive, 228 .hash = smc_hash_sk, 229 .unhash = smc_unhash_sk, 230 .release_cb = smc_release_cb, 231 .obj_size = sizeof(struct smc_sock), 232 .h.smc_hash = &smc_v4_hashinfo, 233 .slab_flags = SLAB_TYPESAFE_BY_RCU, 234 }; 235 EXPORT_SYMBOL_GPL(smc_proto); 236 237 struct proto smc_proto6 = { 238 .name = "SMC6", 239 .owner = THIS_MODULE, 240 .keepalive = smc_set_keepalive, 241 .hash = smc_hash_sk, 242 .unhash = smc_unhash_sk, 243 .release_cb = smc_release_cb, 244 .obj_size = sizeof(struct smc_sock), 245 .h.smc_hash = &smc_v6_hashinfo, 246 .slab_flags = SLAB_TYPESAFE_BY_RCU, 247 }; 248 EXPORT_SYMBOL_GPL(smc_proto6); 249 250 static void smc_fback_restore_callbacks(struct smc_sock *smc) 251 { 252 struct sock *clcsk = smc->clcsock->sk; 253 254 write_lock_bh(&clcsk->sk_callback_lock); 255 clcsk->sk_user_data = NULL; 256 257 smc_clcsock_restore_cb(&clcsk->sk_state_change, &smc->clcsk_state_change); 258 smc_clcsock_restore_cb(&clcsk->sk_data_ready, &smc->clcsk_data_ready); 259 smc_clcsock_restore_cb(&clcsk->sk_write_space, &smc->clcsk_write_space); 260 smc_clcsock_restore_cb(&clcsk->sk_error_report, &smc->clcsk_error_report); 261 262 write_unlock_bh(&clcsk->sk_callback_lock); 263 } 264 265 static void smc_restore_fallback_changes(struct smc_sock *smc) 266 { 267 if (smc->clcsock->file) { /* non-accepted sockets have no file yet */ 268 smc->clcsock->file->private_data = smc->sk.sk_socket; 269 smc->clcsock->file = NULL; 270 smc_fback_restore_callbacks(smc); 271 } 272 } 273 274 static int __smc_release(struct smc_sock *smc) 275 { 276 struct sock *sk = &smc->sk; 277 int rc = 0; 278 279 if (!smc->use_fallback) { 280 rc = smc_close_active(smc); 281 sock_set_flag(sk, SOCK_DEAD); 282 sk->sk_shutdown |= SHUTDOWN_MASK; 283 } else { 284 if (sk->sk_state != SMC_CLOSED) { 285 if (sk->sk_state != SMC_LISTEN && 286 sk->sk_state != SMC_INIT) 287 sock_put(sk); /* passive closing */ 288 if (sk->sk_state == SMC_LISTEN) { 289 /* wake up clcsock accept */ 290 rc = kernel_sock_shutdown(smc->clcsock, 291 SHUT_RDWR); 292 } 293 sk->sk_state = SMC_CLOSED; 294 sk->sk_state_change(sk); 295 } 296 smc_restore_fallback_changes(smc); 297 } 298 299 sk->sk_prot->unhash(sk); 300 301 if (sk->sk_state == SMC_CLOSED) { 302 if (smc->clcsock) { 303 release_sock(sk); 304 smc_clcsock_release(smc); 305 lock_sock(sk); 306 } 307 if (!smc->use_fallback) 308 smc_conn_free(&smc->conn); 309 } 310 311 return rc; 312 } 313 314 static int smc_release(struct socket *sock) 315 { 316 struct sock *sk = sock->sk; 317 struct smc_sock *smc; 318 int old_state, rc = 0; 319 320 if (!sk) 321 goto out; 322 323 sock_hold(sk); /* sock_put below */ 324 smc = smc_sk(sk); 325 326 /* trigger info gathering if needed.*/Quoted 1 line
327
smc_sock_perform_collecting_info(sk, SMC_SOCK_CLOSED_TIMING);328 329 old_state = sk->sk_state; 330 331 /* cleanup for a dangling non-blocking connect */ 332 if (smc->connect_nonblock && old_state == SMC_INIT) 333 tcp_abort(smc->clcsock->sk, ECONNABORTED); 334 335 if (cancel_work_sync(&smc->connect_work)) 336 sock_put(&smc->sk); /* sock_hold in smc_connect for passive closing */ 337 338 if (sk->sk_state == SMC_LISTEN) 339 /* smc_close_non_accepted() is called and acquires 340 * sock lock for child sockets again 341 */ 342 lock_sock_nested(sk, SINGLE_DEPTH_NESTING); 343 else 344 lock_sock(sk); 345 346 if (old_state == SMC_INIT && sk->sk_state == SMC_ACTIVE && 347 !smc->use_fallback) 348 smc_close_active_abort(smc); 349 350 rc = __smc_release(smc); 351 352 /* detach socket */ 353 sock_orphan(sk); 354 sock->sk = NULL; 355 release_sock(sk); 356 357 sock_put(sk); /* sock_hold above */ 358 sock_put(sk); /* final sock_put */ 359 out: 360 return rc; 361 } 362
D. Wythe
maintainerRe: [PATCH bpf-next v3 3/4] net/smc: add BPF injection on smc negotiation
In reply to kernel test robotYou are right. Thanks for you test!!
I will send new version to fix this.!
Quoted 246 lines · kernel test robot
Hi Wythe,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on bpf-next/master]
url: https://github.com/intel-lab-lkp/linux/commits/D-Wythe/net-smc-move-smc_sock-related-structure-definition/20230228-173007 base: https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master patch link: https://lore.kernel.org/r/1677576294-33411-4-git-send-email-alibuda%40linux.alibaba.com patch subject: [PATCH bpf-next v3 3/4] net/smc: add BPF injection on smc negotiation config: x86_64-randconfig-a015-20230227 (https://download.01.org/0day-ci/archive/20230228/[email protected]/config) compiler: gcc-11 (Debian 11.3.0-8) 11.3.0 reproduce (this is a W=1 build): # https://github.com/intel-lab-lkp/linux/commit/aa482ab82f4bf9b99d490f8ba5d88e1491156ccf git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review D-Wythe/net-smc-move-smc_sock-related-structure-definition/20230228-173007 git checkout aa482ab82f4bf9b99d490f8ba5d88e1491156ccf # save the config file mkdir build_dir && cp config build_dir/.config make W=1 O=build_dir ARCH=x86_64 olddefconfig make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bashIf you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/All errors (new ones prefixed by >>):
ld:
net/smc/af_smc.o: in function `smc_hs_congested':Quoted 1 line
Quoted 1 line
net/smc/af_smc.c:169: undefined reference to `smc_sock_should_select_smc'ld:
net/smc/af_smc.o: in function `smc_release':Quoted 1 line
Quoted 1 line
net/smc/af_smc.c:327: undefined reference to `smc_sock_perform_collecting_info'ld:
net/smc/af_smc.o: in function `smc_connect':
net/smc/af_smc.c:1637: undefined reference to `smc_sock_should_select_smc'vim +169
net/smc/af_smc.c156 157 static bool smc_hs_congested(const struct sock *sk) 158 { 159 const struct smc_sock *smc; 160 161 smc = smc_clcsock_user_data(sk); 162 163 if (!smc) 164 return true; 165 166 if (workqueue_congested(WORK_CPU_UNBOUND, smc_hs_wq)) 167 return true; 168Quoted 1 line
169 if (!smc_sock_should_select_smc(smc))
170 return true; 171 172 return false; 173 } 174 175 static struct smc_hashinfo smc_v4_hashinfo = { 176 .lock = __RW_LOCK_UNLOCKED(smc_v4_hashinfo.lock), 177 }; 178 179 static struct smc_hashinfo smc_v6_hashinfo = { 180 .lock = __RW_LOCK_UNLOCKED(smc_v6_hashinfo.lock), 181 }; 182 183 int smc_hash_sk(struct sock *sk) 184 { 185 struct smc_hashinfo *h = sk->sk_prot->h.smc_hash; 186 struct hlist_head *head; 187 188 head = &h->ht; 189 190 write_lock_bh(&h->lock); 191 sk_add_node(sk, head); 192 write_unlock_bh(&h->lock); 193 sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1); 194 195 return 0; 196 } 197 EXPORT_SYMBOL_GPL(smc_hash_sk); 198 199 void smc_unhash_sk(struct sock *sk) 200 { 201 struct smc_hashinfo *h = sk->sk_prot->h.smc_hash; 202 203 write_lock_bh(&h->lock); 204 if (sk_del_node_init(sk)) 205 sock_prot_inuse_add(sock_net(sk), sk->sk_prot, -1); 206 write_unlock_bh(&h->lock); 207 } 208 EXPORT_SYMBOL_GPL(smc_unhash_sk); 209 210 /* This will be called before user really release sock_lock. So do the 211 * work which we didn't do because of user hold the sock_lock in the 212 * BH context 213 */ 214 static void smc_release_cb(struct sock *sk) 215 { 216 struct smc_sock *smc = smc_sk(sk); 217 218 if (smc->conn.tx_in_release_sock) { 219 smc_tx_pending(&smc->conn); 220 smc->conn.tx_in_release_sock = false; 221 } 222 } 223 224 struct proto smc_proto = { 225 .name = "SMC", 226 .owner = THIS_MODULE, 227 .keepalive = smc_set_keepalive, 228 .hash = smc_hash_sk, 229 .unhash = smc_unhash_sk, 230 .release_cb = smc_release_cb, 231 .obj_size = sizeof(struct smc_sock), 232 .h.smc_hash = &smc_v4_hashinfo, 233 .slab_flags = SLAB_TYPESAFE_BY_RCU, 234 }; 235 EXPORT_SYMBOL_GPL(smc_proto); 236 237 struct proto smc_proto6 = { 238 .name = "SMC6", 239 .owner = THIS_MODULE, 240 .keepalive = smc_set_keepalive, 241 .hash = smc_hash_sk, 242 .unhash = smc_unhash_sk, 243 .release_cb = smc_release_cb, 244 .obj_size = sizeof(struct smc_sock), 245 .h.smc_hash = &smc_v6_hashinfo, 246 .slab_flags = SLAB_TYPESAFE_BY_RCU, 247 }; 248 EXPORT_SYMBOL_GPL(smc_proto6); 249 250 static void smc_fback_restore_callbacks(struct smc_sock *smc) 251 { 252 struct sock *clcsk = smc->clcsock->sk; 253 254 write_lock_bh(&clcsk->sk_callback_lock); 255 clcsk->sk_user_data = NULL; 256 257 smc_clcsock_restore_cb(&clcsk->sk_state_change, &smc->clcsk_state_change); 258 smc_clcsock_restore_cb(&clcsk->sk_data_ready, &smc->clcsk_data_ready); 259 smc_clcsock_restore_cb(&clcsk->sk_write_space, &smc->clcsk_write_space); 260 smc_clcsock_restore_cb(&clcsk->sk_error_report, &smc->clcsk_error_report); 261 262 write_unlock_bh(&clcsk->sk_callback_lock); 263 } 264 265 static void smc_restore_fallback_changes(struct smc_sock *smc) 266 { 267 if (smc->clcsock->file) { /* non-accepted sockets have no file yet */ 268 smc->clcsock->file->private_data = smc->sk.sk_socket; 269 smc->clcsock->file = NULL; 270 smc_fback_restore_callbacks(smc); 271 } 272 } 273 274 static int __smc_release(struct smc_sock *smc) 275 { 276 struct sock *sk = &smc->sk; 277 int rc = 0; 278 279 if (!smc->use_fallback) { 280 rc = smc_close_active(smc); 281 sock_set_flag(sk, SOCK_DEAD); 282 sk->sk_shutdown |= SHUTDOWN_MASK; 283 } else { 284 if (sk->sk_state != SMC_CLOSED) { 285 if (sk->sk_state != SMC_LISTEN && 286 sk->sk_state != SMC_INIT) 287 sock_put(sk); /* passive closing */ 288 if (sk->sk_state == SMC_LISTEN) { 289 /* wake up clcsock accept */ 290 rc = kernel_sock_shutdown(smc->clcsock, 291 SHUT_RDWR); 292 } 293 sk->sk_state = SMC_CLOSED; 294 sk->sk_state_change(sk); 295 } 296 smc_restore_fallback_changes(smc); 297 } 298 299 sk->sk_prot->unhash(sk); 300 301 if (sk->sk_state == SMC_CLOSED) { 302 if (smc->clcsock) { 303 release_sock(sk); 304 smc_clcsock_release(smc); 305 lock_sock(sk); 306 } 307 if (!smc->use_fallback) 308 smc_conn_free(&smc->conn); 309 } 310 311 return rc; 312 } 313 314 static int smc_release(struct socket *sock) 315 { 316 struct sock *sk = sock->sk; 317 struct smc_sock *smc; 318 int old_state, rc = 0; 319 320 if (!sk) 321 goto out; 322 323 sock_hold(sk); /* sock_put below */ 324 smc = smc_sk(sk); 325 326 /* trigger info gathering if needed.*/Quoted 1 line
327
smc_sock_perform_collecting_info(sk, SMC_SOCK_CLOSED_TIMING);328 329 old_state = sk->sk_state; 330 331 /* cleanup for a dangling non-blocking connect */ 332 if (smc->connect_nonblock && old_state == SMC_INIT) 333 tcp_abort(smc->clcsock->sk, ECONNABORTED); 334 335 if (cancel_work_sync(&smc->connect_work)) 336 sock_put(&smc->sk); /* sock_hold in smc_connect for passive closing */ 337 338 if (sk->sk_state == SMC_LISTEN) 339 /* smc_close_non_accepted() is called and acquires 340 * sock lock for child sockets again 341 */ 342 lock_sock_nested(sk, SINGLE_DEPTH_NESTING); 343 else 344 lock_sock(sk); 345 346 if (old_state == SMC_INIT && sk->sk_state == SMC_ACTIVE && 347 !smc->use_fallback) 348 smc_close_active_abort(smc); 349 350 rc = __smc_release(smc); 351 352 /* detach socket */ 353 sock_orphan(sk); 354 sock->sk = NULL; 355 release_sock(sk); 356 357 sock_put(sk); /* sock_hold above */ 358 sock_put(sk); /* final sock_put */ 359 out: 360 return rc; 361 } 362
D. Wythe
maintainerPATCH v3 4/4 bpf/selftests: add selftest for SMC bpf capability
In reply to D. WytheFrom: "D. Wythe" <[email protected]>
This PATCH adds a tiny selftest for SMC bpf capability, making decisions on whether to use SMC by collecting certain information from kernel smc sock.
Follow the steps below to run this test.
make -C tools/testing/selftests/bpf
cd tools/testing/selftests/bpf
sudo ./test_progs -t bpf_smc
Results shows:
18 bpf_smc:OK
Summary: 1/0 PASSED, 0 SKIPPED, 0 FAILED
--- tools/testing/selftests/bpf/prog_tests/bpf_smc.c | 37 +++ tools/testing/selftests/bpf/progs/bpf_smc.c | 320 +++++++++++++++++++++++ 2 files changed, 357 insertions(+) create mode 100644 tools/testing/selftests/bpf/prog_tests/bpf_smc.c create mode 100644 tools/testing/selftests/bpf/progs/bpf_smc.c
tools/testing/selftests/bpf/prog_tests/bpf_smc.c new file +37 -0
@@ -0,0 +1,37 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include <linux/err.h> +#include <netinet/tcp.h> +#include <test_progs.h> +#include "bpf_smc.skel.h" + +void test_bpf_smc (void ) +{ +struct bpf_smc *smc_skel; +struct bpf_link *link; +int err; + + smc_skel =bpf_smc__open (); +if (!ASSERT_OK_PTR (smc_skel,"skel_open" )) +return ; + + err =bpf_map__set_type (smc_skel->maps.negotiator_map,BPF_MAP_TYPE_HASH ); +if (!ASSERT_OK (err,"bpf_map__set_type" )) + goto error; + + err =bpf_map__set_max_entries (smc_skel->maps.negotiator_map,1 ); +if (!ASSERT_OK (err,"bpf_map__set_type" )) + goto error; + + err =bpf_smc__load (smc_skel); +if (!ASSERT_OK (err,"skel_load" )) + goto error; + + link =bpf_map__attach_struct_ops (smc_skel->maps.ops); +if (!ASSERT_OK_PTR (link,"bpf_map__attach_struct_ops" )) + goto error; + +bpf_link__destroy (link); +error: +bpf_smc__destroy (smc_skel); +}
tools/testing/selftests/bpf/progs/bpf_smc.c new file +320 -0
320 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Jakub Kicinski
maintainerQuoted 4 lines · On Tue, 28 Feb 2023 17:24:50 +0800 D. Wythe wrote:
From: "D. Wythe" <[email protected]>
This patches attempt to introduce BPF injection capability for SMC, and add selftest to ensure code stability.
What happened to fixing the issues Al pointed out long, long time ago?
D. Wythe
maintainerQuoted 9 lines · Jakub Kicinski
Quoted 4 lines · On Tue, 28 Feb 2023 17:24:50 +0800 D. Wythe wrote:
From: "D. Wythe" <[email protected]>
This patches attempt to introduce BPF injection capability for SMC, and add selftest to ensure code stability.
What happened to fixing the issues Al pointed out long, long time ago?
Sorry about that, I don't know much details about this issues. But I have already fed back the problem to Tony Lu, he will give a reply soon, thank you.
D. Wythe
Tony Lu
reviewerQuoted 9 lines · Jakub Kicinski
Quoted 4 lines · On Tue, 28 Feb 2023 17:24:50 +0800 D. Wythe wrote:
From: "D. Wythe" <[email protected]>
This patches attempt to introduce BPF injection capability for SMC, and add selftest to ensure code stability.
What happened to fixing the issues Al pointed out long, long time ago?
Actually, this patch set is going to replace the patch of TCP ULP for SMC. If this patch set is accepted, I am going to revert that patch.
For the reasons, the TCP ULP for SMC doesn't use wildly. It's not possible to know which applications are suitable to be replaced with SMC. But it's easier to detect the behavior of applications and determine whether to replace applications with SMC. And this patch set is going to fallback to TCP by behavior with eBPF.
So this is the _fix_ for that patch.
Thank you,
Tony Lu
Jakub Kicinski
maintainerQuoted 10 lines · On Wed, 1 Mar 2023 10:41:57 +0800 Tony Lu wrote:
Actually, this patch set is going to replace the patch of TCP ULP for SMC. If this patch set is accepted, I am going to revert that patch.
For the reasons, the TCP ULP for SMC doesn't use wildly. It's not possible to know which applications are suitable to be replaced with SMC. But it's easier to detect the behavior of applications and determine whether to replace applications with SMC. And this patch set is going to fallback to TCP by behavior with eBPF.
So this is the _fix_ for that patch.
Good to hear, I was worried you'd still want to install the ULP at some point whether the decision is via BPF or user space.