Introduce IPPROTO_SMC
Subsystems (6)
D. Wythe
maintainercover Introduce IPPROTO_SMC
From: "D. Wythe" <[email protected]>
this patch attempts to initiate a discussion on creating smc socket via AF_INET, similar to the following code snippet:
/* create v4 smc sock */
v4 = socket(AF_INET, SOCK_STREAM, IPPROTO_SMC);
/* create v6 smc sock */
v6 = socket(AF_INET6, SOCK_STREAM, IPPROTO_SMC);
As we all know, the way we currently create an SMC socket as follows.
/* create v4 smc sock */
v4 = socket(AF_SMC, SOCK_STREAM, SMCPROTO_SMC);
/* create v6 smc sock */
v6 = socket(AF_SMC, SOCK_STREAM, SMCPROTO_SMC6);
Note: This is not to suggest removing the SMC path, but rather to propose adding a new path (inet path).
There are several reasons why we believe it is much better than AF_SMC:
Semantics:
SMC extends the TCP protocol and switches it's data path to RDMA path if RDMA link is ready. Otherwise, SMC should always try its best to degrade to TCP. From this perspective, SMC is a protocol derived from TCP and can also fallback to TCP, It should be considered as part of the same protocol family as TCP (AF_INET and AF_INET6).
Compatibility & Scalability:
Due to the presence of fallback, we needs to handle it very carefully to keep the consistent with the TCP sockets. SMC has done a lot of work to ensure that, but still, there are quite a few issues left, such as:
1. The "ss" command cannot display the process name and ID associated with the fallback socket.
2. The linger option is ineffective when user try’s to close the fallback socket.
3. Some eBPF attach points related to INET_SOCK are ineffective under fallback socket, such as BPF_CGROUP_INET_SOCK_RELEASE.
4. SO_PEEK_OFF is a un-supported sock option for fallback sockets, while it’s of course supported for tcp sockets.
Of course, we can fix each issue one by one, but it is not a fundamental solution. Any changes on the inet path may require re-synchronization, including bug fixes, security fixes, tracing, new features and more. For example, there is a commit which we think is very valueable:
commit 0dd061a6a115 ("bpf: Add update_socket_protocol hook")
This commit allows users to modify dynamically the protocol before socket created through eBPF programs, which provides a more flexible approach than smc_run (LP_PRELOAD). It does not require the process restart and allows for controlling replacement at the connection level, whereas smc_run operates at the process level.
However, to benefit from it under the SMC path requires additional code submission while nothing changes requires to do under inet path.
I'm not saying that these issues cannot be fixed under smc path, however, the solution for these issues often involves duplicating work that already done on inet path. Thats to say, if we can be under the inet path, we can easily reuse the existing infrastructure.
Performance:
In order to ensure consistency between fallback sockets and TCP sockets, SMC creates an additional TCP socket. This introduces additional overhead of approximately 15%-20% for the establishment and destruction of fallback sockets. In fact, for the users we have contacted who have shown interest in SMC, ensuring consistency in performance between fallback and TCP has always been their top priority. Since no one can guarantee the availability of RDMA links, support for SMC on both sides, or if the user's environment is 100% suitable for SMC. Fallback is the only way to address those issues, but the additional performance overhead is unacceptable, as fallback cannot provide the benefits of RDMA and only brings burden right now.
A Simple Fallback benchmark within Short connection (wrk/nginx)
------------------------------------------------------------------
proto/conn | 128 | 512 | 1024 | 2048 | ------------------------------------------------------------------| TCP | 133947.56 | 132933.89 |129047.70 |132411.72 | ------------------------------------------------------------------| Fallback in Server | | IPPROTO_SMC | 131607.38 | 131579.17 |130023.96 |131814.16 | ------------------------------------------------------------------| Fallback in Server | | PF_SMC | 85510.27 | 89577.23 |89850.54 |89542.41 | ------------------------------------------------------------------| Fallback in Client | | IPPROTO_SMC | 134589.05 | 132379.63 |133110.02 |132381.47 | ------------------------------------------------------------------| Fallback in Client | |
PF_SMC | 109194.38 | 115995.48 |115498.11 |108671.24 |
------------------------------------------------------------------
In inet path, we can embed TCP sock into SMC sock, when fallback occurs, the socket behaves exactly like a TCP socket. In our POC, the performance of fallback socket under inet path is almost indistinguishable from of tcp socket, with less than 1% loss. Additionally, and more importantly, it has full feature compatibility with TCP socket.
Of course, it is also possible under smc path, but in that way, it would require a significant amount of work to ensure compatibility with tcp sockets, which most of them has already been done in inet path. And still, any changes in inet path may require re-synchronization.
I also noticed that there have been some discussions on this issue before.
And I saw some supportive opinions here, maybe it is time to continue discussing this matter now.
D. Wythe (20):
net: export partial symbols in inet/inet6 proto_ops net/smc: read&write sock state via unified macros net/smc: refactor smc_setsockopt
net/smc: refactor smc_accept_poll
net/smc: try test to fallback when ulp set net/smc: fast return on unconcernd TCP options net/smc: refactor sock_flag/sock_set_flag net/smc: optimize mutex_fback_rsn from mutex to spinlock net/smc: refator smc_switch_to_fallback
net/smc: make initialization code in smc_listen independent net/smc: make __smc_accept can return the new accepted sock net/smc: refatoring initialization of smc sock net/smc: embedded tcp sock into smc sock
net/smc: allow to access the state of inet smc sock net/smc: enable access of sock flags of inet smc sock net/smc: add inet proto defination for SMC net/smc: add dummy implementation for inet smc sock net/smc: add define and macro for smc_negotiation net/smc: support smc inet with merge socks net/smc: support diag for smc inet mode
include/linux/tcp.h | 1 + include/net/inet_common.h | 3 + include/net/netns/smc.h | 2 +- include/uapi/linux/in.h | 2 + net/ipv4/af_inet.c | 3 +- net/ipv6/af_inet6.c | 2 + net/smc/Makefile | 1 + net/smc/af_smc.c | 1501 +++++++++++++++++++++++++++++++++++------ net/smc/smc.h | 62 +- net/smc/smc_cdc.c | 2 +- net/smc/smc_cdc.h | 8 + net/smc/smc_clc.h | 1 + net/smc/smc_close.c | 120 ++-- net/smc/smc_core.c | 24 +- net/smc/smc_diag.c | 157 ++++- net/smc/smc_inet.c | 450 ++++++++++++ net/smc/smc_inet.h | 280 ++++++++ net/smc/smc_rx.c | 28 +- net/smc/smc_stats.c | 6 +- net/smc/smc_tx.c | 2 +- tools/include/uapi/linux/in.h | 2 + 21 files changed, 2326 insertions(+), 331 deletions(-) create mode 100644 net/smc/smc_inet.c create mode 100644 net/smc/smc_inet.h
Signature · 1 line
1.8.3.1
D. Wythe
maintainerRFC 1/20 net: export partial symbols in inet/inet6 proto_ops
From: "D. Wythe" <[email protected]>
The following symbols have been exported here
1. inet_compat_ioctl
2. inet6_sendmsg
3. inet6_recvmsg
Exporting these symbols mainly provides the ability for other modules to directly access these symbols. Currently, all symbols except those above symbols are exported. So, there mighe be no obvious risk in exporting these symbols.
--- include/net/inet_common.h | 3 +++ net/ipv4/af_inet.c | 3 ++- net/ipv6/af_inet6.c | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-)
include/net/inet_common.h +3 -0
@@ -57,6 +57,9 @@ int __inet_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len,int inet_getname (struct socket *sock,struct sockaddr *uaddr,int peer);int inet_ioctl (struct socket *sock,unsigned int cmd,unsigned long arg); +#ifdef CONFIG_COMPAT +int inet_compat_ioctl (struct socket *sock,unsigned int cmd,unsigned long arg); +#endif int inet_ctl_sock_create (struct sock **sk,unsigned short family,unsigned short type,unsigned char protocol,struct net *net);
net/ipv4/af_inet.c +2 -1
@@ -1031,7 +1031,7 @@ static int inet_compat_routing_ioctl(struct sock *sk, unsigned int cmd,return ip_rt_ioctl (sock_net (sk), cmd, &rt); } -static int inet_compat_ioctl (struct socket *sock,unsigned int cmd,unsigned long arg) +int inet_compat_ioctl (struct socket *sock,unsigned int cmd,unsigned long arg) {void __user *argp =compat_ptr (arg);struct sock *sk = sock->sk;
@@ -1046,6 +1046,7 @@ static int inet_compat_ioctl(struct socket *sock, unsigned int cmd, unsigned lon return sk->sk_prot->compat_ioctl(sk, cmd, arg); } } +EXPORT_SYMBOL_GPL (inet_compat_ioctl);#endif /* CONFIG_COMPAT */ const struct proto_ops inet_stream_ops = {
net/ipv6/af_inet6.c +2 -0
@@ -660,6 +660,7 @@ int inet6_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)return INDIRECT_CALL_2 (prot->sendmsg, tcp_sendmsg, udpv6_sendmsg, sk, msg, size); } +EXPORT_SYMBOL_GPL (inet6_sendmsg); INDIRECT_CALLABLE_DECLARE(int udpv6_recvmsg(struct sock *, struct msghdr *,size_t ,int ,int *));
@@ -682,6 +683,7 @@ int inet6_recvmsg(struct socket *sock, struct msghdr *msg, size_t size, msg->msg_namelen = addr_len;return err; } +EXPORT_SYMBOL_GPL (inet6_recvmsg);const struct proto_ops inet6_stream_ops = { .family =PF_INET6 ,
Signature · 1 line
1.8.3.1
D. Wythe
maintainerRFC 2/20 net/smc: read&write sock state via unified macros
In reply to D. WytheFrom: "D. Wythe" <[email protected]>
In order to merge SMC sock and TCP sock, the state field of sock will be shared by TCP protocol stack and SMC protocol statck. Unfortunately, the state defined by SMC coincides with state defined in TCP.
Easier way is to redefine the state of SMC sock, however, this will confuse some of smc tools because they are using the old state definition.
So we have to use a new field for SMC implementation to read and write status after merging sock, In consideration of compatibility and subsequent extensibility, we decied to make all read & write operations related to be replaced by a unified macro. In this way, we can just modify this macro to switch state access between different fields.
This patch only goes into code reorganization, replacing all read and write operations on socks state with unified macros. In theory, it should have no impact on anything, and all subsequent reading or writing operations on state should via it.
--- net/smc/af_smc.c | 195 ++++++++++++++++++++++++++-------------------------- net/smc/smc.h | 3 + net/smc/smc_close.c | 98 +++++++++++++------------- net/smc/smc_core.c | 24 +++---- net/smc/smc_diag.c | 2 +- net/smc/smc_rx.c | 16 ++--- net/smc/smc_tx.c | 2 +- 7 files changed, 171 insertions(+), 169 deletions(-)
net/smc/af_smc.c +97 -98
@@ -278,16 +278,16 @@ static int __smc_release(struct smc_sock *smc)smc_sock_set_flag (sk,SOCK_DEAD ); sk->sk_shutdown |=SHUTDOWN_MASK ; }else { -if (sk->sk_state !=SMC_CLOSED ) { -if (sk->sk_state !=SMC_LISTEN && - sk->sk_state !=SMC_INIT ) +if (smc_sk_state (sk) !=SMC_CLOSED ) { +if (smc_sk_state (sk) !=SMC_LISTEN && +smc_sk_state (sk) !=SMC_INIT )sock_put (sk);/* passive closing */ -if (sk->sk_state ==SMC_LISTEN ) { +if (smc_sk_state (sk) ==SMC_LISTEN ) {/* wake up clcsock accept */ rc =kernel_sock_shutdown (smc->clcsock,SHUT_RDWR ); } - sk->sk_state =SMC_CLOSED ; +smc_sk_set_state (sk,SMC_CLOSED ); sk->sk_state_change (sk); }smc_restore_fallback_changes (smc);
@@ -295,7 +295,7 @@ static int __smc_release(struct smc_sock *smc) sk->sk_prot->unhash (sk); -if (sk->sk_state ==SMC_CLOSED ) { +if (smc_sk_state (sk) ==SMC_CLOSED ) {if (smc->clcsock) {release_sock (sk);smc_clcsock_release (smc);
@@ -320,7 +320,7 @@ static int smc_release(struct socket *sock)sock_hold (sk);/* sock_put below */ smc =smc_sk (sk); - old_state = sk->sk_state; + old_state =smc_sk_state (sk);/* cleanup for a dangling non-blocking connect */ if (smc->connect_nonblock && old_state ==SMC_INIT )
@@ -329,7 +329,7 @@ static int smc_release(struct socket *sock)if (cancel_work_sync (&smc->connect_work))sock_put (&smc->sk);/* sock_hold in smc_connect for passive closing */ -if (sk->sk_state ==SMC_LISTEN ) +if (smc_sk_state (sk) ==SMC_LISTEN )/* smc_close_non_accepted() is called and acquires * sock lock for child sockets again */
@@ -337,7 +337,7 @@ static int smc_release(struct socket *sock)else lock_sock (sk); -if (old_state ==SMC_INIT && sk->sk_state ==SMC_ACTIVE && +if (old_state ==SMC_INIT &&smc_sk_state (sk) ==SMC_ACTIVE && !smc->use_fallback)smc_close_active_abort (smc);
@@ -356,7 +356,7 @@ static int smc_release(struct socket *sock)static void smc_destruct (struct sock *sk) { -if (sk->sk_state !=SMC_CLOSED ) +if (smc_sk_state (sk) !=SMC_CLOSED )return ;if (!sock_flag (sk,SOCK_DEAD ))return ;
@@ -375,7 +375,7 @@ static struct sock *smc_sock_alloc(struct net *net, struct socket *sock,return NULL ;sock_init_data (sock, sk);/* sets sk_refcnt to 1 */ - sk->sk_state =SMC_INIT ; +smc_sk_set_state (sk,SMC_INIT ); sk->sk_destruct = smc_destruct; sk->sk_protocol = protocol;WRITE_ONCE (sk->sk_sndbuf,2 *READ_ONCE (net->smc.sysctl_wmem));
@@ -423,7 +423,7 @@ static int smc_bind(struct socket *sock, struct sockaddr *uaddr,/* Check if socket is already active */ rc = -EINVAL ; -if (sk->sk_state !=SMC_INIT || smc->connect_nonblock) +if (smc_sk_state (sk) !=SMC_INIT || smc->connect_nonblock) goto out_rel; smc->clcsock->sk->sk_reuse = sk->sk_reuse;
@@ -946,14 +946,14 @@ static int smc_connect_fallback(struct smc_sock *smc, int reason_code) rc =smc_switch_to_fallback (smc, reason_code);if (rc) {/* fallback fails */ this_cpu_inc (net->smc.smc_stats->clnt_hshake_err_cnt); -if (smc->sk.sk_state ==SMC_INIT ) +if (smc_sk_state (&smc->sk) ==SMC_INIT )sock_put (&smc->sk);/* passive closing */ return rc; }smc_copy_sock_settings_to_clc (smc); smc->connect_nonblock =0 ; -if (smc->sk.sk_state ==SMC_INIT ) - smc->sk.sk_state =SMC_ACTIVE ; +if (smc_sk_state (&smc->sk) ==SMC_INIT ) +smc_sk_set_state (&smc->sk,SMC_ACTIVE );return 0 ; }
@@ -966,7 +966,7 @@ static int smc_connect_decline_fallback(struct smc_sock *smc, int reason_code,if (reason_code <0 ) {/* error, fallback is not possible */ this_cpu_inc (net->smc.smc_stats->clnt_hshake_err_cnt); -if (smc->sk.sk_state ==SMC_INIT ) +if (smc_sk_state (&smc->sk) ==SMC_INIT )sock_put (&smc->sk);/* passive closing */ return reason_code; }
@@ -974,7 +974,7 @@ static int smc_connect_decline_fallback(struct smc_sock *smc, int reason_code, rc =smc_clc_send_decline (smc, reason_code, version);if (rc <0 ) {this_cpu_inc (net->smc.smc_stats->clnt_hshake_err_cnt); -if (smc->sk.sk_state ==SMC_INIT ) +if (smc_sk_state (&smc->sk) ==SMC_INIT )sock_put (&smc->sk);/* passive closing */ return rc; }
@@ -1357,8 +1357,8 @@ static int smc_connect_rdma(struct smc_sock *smc,smc_copy_sock_settings_to_clc (smc); smc->connect_nonblock =0 ; -if (smc->sk.sk_state ==SMC_INIT ) - smc->sk.sk_state =SMC_ACTIVE ; +if (smc_sk_state (&smc->sk) ==SMC_INIT ) +smc_sk_set_state (&smc->sk,SMC_ACTIVE );return 0 ; connect_abort:
@@ -1452,8 +1452,8 @@ static int smc_connect_ism(struct smc_sock *smc,smc_copy_sock_settings_to_clc (smc); smc->connect_nonblock =0 ; -if (smc->sk.sk_state ==SMC_INIT ) - smc->sk.sk_state =SMC_ACTIVE ; +if (smc_sk_state (&smc->sk) ==SMC_INIT ) +smc_sk_set_state (&smc->sk,SMC_ACTIVE );return 0 ; connect_abort:
@@ -1607,7 +1607,7 @@ static void smc_connect_work(struct work_struct *work)release_sock (smc->clcsock->sk);lock_sock (&smc->sk);if (rc !=0 || smc->sk.sk_err) { - smc->sk.sk_state =SMC_CLOSED ; +smc_sk_set_state (&smc->sk,SMC_CLOSED );if (rc == -EPIPE || rc == -EAGAIN ) smc->sk.sk_err =EPIPE ;else if (rc == -ECONNREFUSED )
@@ -1655,10 +1655,10 @@ static int smc_connect(struct socket *sock, struct sockaddr *addr, rc = -EINVAL ; goto out;case SS_CONNECTED : - rc = sk->sk_state ==SMC_ACTIVE ? -EISCONN : -EINVAL ; + rc =smc_sk_state (sk) ==SMC_ACTIVE ? -EISCONN : -EINVAL ; goto out;case SS_CONNECTING : -if (sk->sk_state ==SMC_ACTIVE ) +if (smc_sk_state (sk) ==SMC_ACTIVE ) goto connected;break ;case SS_UNCONNECTED :
@@ -1666,7 +1666,7 @@ static int smc_connect(struct socket *sock, struct sockaddr *addr,break ; } -switch (sk->sk_state) { +switch (smc_sk_state (sk)) {default : goto out;case SMC_CLOSED :
@@ -1740,11 +1740,11 @@ static int smc_clcsock_accept(struct smc_sock *lsmc, struct smc_sock **new_smc)lock_sock (lsk);if (rc <0 && rc != -EAGAIN ) lsk->sk_err = -rc; -if (rc <0 || lsk->sk_state ==SMC_CLOSED ) { +if (rc <0 ||smc_sk_state (lsk) ==SMC_CLOSED ) { new_sk->sk_prot->unhash (new_sk);if (new_clcsock)sock_release (new_clcsock); - new_sk->sk_state =SMC_CLOSED ; +smc_sk_set_state (new_sk,SMC_CLOSED );smc_sock_set_flag (new_sk,SOCK_DEAD );sock_put (new_sk);/* final */ *new_smc =NULL ;
@@ -1812,7 +1812,7 @@ struct sock *smc_accept_dequeue(struct sock *parent, new_sk = (struct sock *)isk;smc_accept_unlink (new_sk); -if (new_sk->sk_state ==SMC_CLOSED ) { +if (smc_sk_state (new_sk) ==SMC_CLOSED ) { new_sk->sk_prot->unhash (new_sk);if (isk->clcsock) {sock_release (isk->clcsock);
@@ -1911,7 +1911,7 @@ static void smc_listen_out(struct smc_sock *new_smc)if (tcp_sk (new_smc->clcsock->sk)->syn_smc)atomic_dec (&lsmc->queued_smc_hs); -if (lsmc->sk.sk_state ==SMC_LISTEN ) { +if (smc_sk_state (&lsmc->sk) ==SMC_LISTEN ) {lock_sock_nested (&lsmc->sk,SINGLE_DEPTH_NESTING );smc_accept_enqueue (&lsmc->sk, newsmcsk);release_sock (&lsmc->sk);
@@ -1929,8 +1929,8 @@ static void smc_listen_out_connected(struct smc_sock *new_smc) {struct sock *newsmcsk = &new_smc->sk; -if (newsmcsk->sk_state ==SMC_INIT ) - newsmcsk->sk_state =SMC_ACTIVE ; +if (smc_sk_state (newsmcsk) ==SMC_INIT ) +smc_sk_set_state (newsmcsk,SMC_ACTIVE );smc_listen_out (new_smc); }
@@ -1942,9 +1942,9 @@ static void smc_listen_out_err(struct smc_sock *new_smc)struct net *net =sock_net (newsmcsk);this_cpu_inc (net->smc.smc_stats->srv_hshake_err_cnt); -if (newsmcsk->sk_state ==SMC_INIT ) +if (smc_sk_state (newsmcsk) ==SMC_INIT )sock_put (&new_smc->sk);/* passive closing */ - newsmcsk->sk_state =SMC_CLOSED ; +smc_sk_set_state (newsmcsk,SMC_CLOSED );smc_listen_out (new_smc); }
@@ -2432,7 +2432,7 @@ static void smc_listen_work(struct work_struct *work)u8 accept_version;int rc =0 ; -if (new_smc->listen_smc->sk.sk_state !=SMC_LISTEN ) +if (smc_sk_state (&new_smc->listen_smc->sk) !=SMC_LISTEN )return smc_listen_out_err (new_smc);if (new_smc->use_fallback) {
@@ -2564,7 +2564,7 @@ static void smc_tcp_listen_work(struct work_struct *work)int rc =0 ;lock_sock (lsk); -while (lsk->sk_state ==SMC_LISTEN ) { +while (smc_sk_state (lsk) ==SMC_LISTEN ) { rc =smc_clcsock_accept (lsmc, &new_smc);if (rc)/* clcsock accept queue empty or error */ goto out;
@@ -2599,7 +2599,7 @@ static void smc_clcsock_data_ready(struct sock *listen_clcsock)if (!lsmc) goto out; lsmc->clcsk_data_ready (listen_clcsock); -if (lsmc->sk.sk_state ==SMC_LISTEN ) { +if (smc_sk_state (&lsmc->sk) ==SMC_LISTEN ) {sock_hold (&lsmc->sk);/* sock_put in smc_tcp_listen_work() */ if (!queue_work (smc_tcp_ls_wq, &lsmc->tcp_listen_work))sock_put (&lsmc->sk);
@@ -2618,12 +2618,12 @@ static int smc_listen(struct socket *sock, int backlog)lock_sock (sk); rc = -EINVAL ; -if ((sk->sk_state !=SMC_INIT && sk->sk_state !=SMC_LISTEN ) || +if ((smc_sk_state (sk) !=SMC_INIT &&smc_sk_state (sk) !=SMC_LISTEN ) || smc->connect_nonblock || sock->state !=SS_UNCONNECTED ) goto out; rc =0 ; -if (sk->sk_state ==SMC_LISTEN ) { +if (smc_sk_state (sk) ==SMC_LISTEN ) { sk->sk_max_ack_backlog = backlog; goto out; }
@@ -2666,7 +2666,7 @@ static int smc_listen(struct socket *sock, int backlog) } sk->sk_max_ack_backlog = backlog; sk->sk_ack_backlog =0 ; - sk->sk_state =SMC_LISTEN ; +smc_sk_set_state (sk,SMC_LISTEN ); out:release_sock (sk);
@@ -2686,7 +2686,7 @@ static int smc_accept(struct socket *sock, struct socket *new_sock,sock_hold (sk);/* sock_put below */ lock_sock (sk); -if (lsmc->sk.sk_state !=SMC_LISTEN ) { +if (smc_sk_state (&lsmc->sk) !=SMC_LISTEN ) { rc = -EINVAL ;release_sock (sk); goto out;
@@ -2748,8 +2748,8 @@ static int smc_getname(struct socket *sock, struct sockaddr *addr, {struct smc_sock *smc; -if (peer && (sock->sk->sk_state !=SMC_ACTIVE ) && - (sock->sk->sk_state !=SMC_APPCLOSEWAIT1 )) +if (peer && (smc_sk_state (sock->sk) !=SMC_ACTIVE ) && + (smc_sk_state (sock->sk) !=SMC_APPCLOSEWAIT1 ))return -ENOTCONN ; smc =smc_sk (sock->sk);
@@ -2769,7 +2769,7 @@ static int smc_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)/* SMC does not support connect with fastopen */ if (msg->msg_flags &MSG_FASTOPEN ) {/* not connected yet, fallback */ -if (sk->sk_state ==SMC_INIT && !smc->connect_nonblock) { +if (smc_sk_state (sk) ==SMC_INIT && !smc->connect_nonblock) { rc =smc_switch_to_fallback (smc,SMC_CLC_DECL_OPTUNSUPP );if (rc) goto out;
@@ -2777,9 +2777,9 @@ static int smc_sendmsg(struct socket *sock, struct msghdr *msg, size_t len) rc = -EINVAL ; goto out; } - }else if ((sk->sk_state !=SMC_ACTIVE ) && - (sk->sk_state !=SMC_APPCLOSEWAIT1 ) && - (sk->sk_state !=SMC_INIT )) { + }else if ((smc_sk_state (sk) !=SMC_ACTIVE ) && + (smc_sk_state (sk) !=SMC_APPCLOSEWAIT1 ) && + (smc_sk_state (sk) !=SMC_INIT )) { rc = -EPIPE ; goto out; }
@@ -2804,17 +2804,17 @@ static int smc_recvmsg(struct socket *sock, struct msghdr *msg, size_t len, smc =smc_sk (sk);lock_sock (sk); -if (sk->sk_state ==SMC_CLOSED && (sk->sk_shutdown &RCV_SHUTDOWN )) { +if (smc_sk_state (sk) ==SMC_CLOSED && (sk->sk_shutdown &RCV_SHUTDOWN )) {/* socket was connected before, no more data to read */ rc =0 ; goto out; } -if ((sk->sk_state ==SMC_INIT ) || - (sk->sk_state ==SMC_LISTEN ) || - (sk->sk_state ==SMC_CLOSED )) +if ((smc_sk_state (sk) ==SMC_INIT ) || + (smc_sk_state (sk) ==SMC_LISTEN ) || + (smc_sk_state (sk) ==SMC_CLOSED )) goto out; -if (sk->sk_state ==SMC_PEERFINCLOSEWAIT ) { +if (smc_sk_state (sk) ==SMC_PEERFINCLOSEWAIT ) { rc =0 ; goto out; }
@@ -2861,14 +2861,14 @@ static __poll_t smc_poll(struct file *file, struct socket *sock, mask = smc->clcsock->ops->poll (file, smc->clcsock, wait); sk->sk_err = smc->clcsock->sk->sk_err; }else { -if (sk->sk_state !=SMC_CLOSED ) +if (smc_sk_state (sk) !=SMC_CLOSED )sock_poll_wait (file, sock, wait);if (sk->sk_err) mask |=EPOLLERR ;if ((sk->sk_shutdown ==SHUTDOWN_MASK ) || - (sk->sk_state ==SMC_CLOSED )) + (smc_sk_state (sk) ==SMC_CLOSED )) mask |=EPOLLHUP ; -if (sk->sk_state ==SMC_LISTEN ) { +if (smc_sk_state (sk) ==SMC_LISTEN ) {/* woken up by sk_data_ready in smc_listen_work() */ mask |=smc_accept_poll (sk); }else if (smc->use_fallback) {/* as result of connect_work()*/
@@ -2876,7 +2876,7 @@ static __poll_t smc_poll(struct file *file, struct socket *sock, wait); sk->sk_err = smc->clcsock->sk->sk_err; }else { -if ((sk->sk_state !=SMC_INIT && +if ((smc_sk_state (sk) !=SMC_INIT &&atomic_read (&smc->conn.sndbuf_space)) || sk->sk_shutdown &SEND_SHUTDOWN ) { mask |=EPOLLOUT |EPOLLWRNORM ;
@@ -2888,7 +2888,7 @@ static __poll_t smc_poll(struct file *file, struct socket *sock, mask |=EPOLLIN |EPOLLRDNORM ;if (sk->sk_shutdown &RCV_SHUTDOWN ) mask |=EPOLLIN |EPOLLRDNORM |EPOLLRDHUP ; -if (sk->sk_state ==SMC_APPCLOSEWAIT1 ) +if (smc_sk_state (sk) ==SMC_APPCLOSEWAIT1 ) mask |=EPOLLIN ;if (smc->conn.urg_state ==SMC_URG_VALID ) mask |=EPOLLPRI ;
@@ -2915,29 +2915,29 @@ static int smc_shutdown(struct socket *sock, int how)lock_sock (sk);if (sock->state ==SS_CONNECTING ) { -if (sk->sk_state ==SMC_ACTIVE ) +if (smc_sk_state (sk) ==SMC_ACTIVE ) sock->state =SS_CONNECTED ; -else if (sk->sk_state ==SMC_PEERCLOSEWAIT1 || - sk->sk_state ==SMC_PEERCLOSEWAIT2 || - sk->sk_state ==SMC_APPCLOSEWAIT1 || - sk->sk_state ==SMC_APPCLOSEWAIT2 || - sk->sk_state ==SMC_APPFINCLOSEWAIT ) +else if (smc_sk_state (sk) ==SMC_PEERCLOSEWAIT1 || +smc_sk_state (sk) ==SMC_PEERCLOSEWAIT2 || +smc_sk_state (sk) ==SMC_APPCLOSEWAIT1 || +smc_sk_state (sk) ==SMC_APPCLOSEWAIT2 || +smc_sk_state (sk) ==SMC_APPFINCLOSEWAIT ) sock->state =SS_DISCONNECTING ; } rc = -ENOTCONN ; -if ((sk->sk_state !=SMC_ACTIVE ) && - (sk->sk_state !=SMC_PEERCLOSEWAIT1 ) && - (sk->sk_state !=SMC_PEERCLOSEWAIT2 ) && - (sk->sk_state !=SMC_APPCLOSEWAIT1 ) && - (sk->sk_state !=SMC_APPCLOSEWAIT2 ) && - (sk->sk_state !=SMC_APPFINCLOSEWAIT )) +if ((smc_sk_state (sk) !=SMC_ACTIVE ) && + (smc_sk_state (sk) !=SMC_PEERCLOSEWAIT1 ) && + (smc_sk_state (sk) !=SMC_PEERCLOSEWAIT2 ) && + (smc_sk_state (sk) !=SMC_APPCLOSEWAIT1 ) && + (smc_sk_state (sk) !=SMC_APPCLOSEWAIT2 ) && + (smc_sk_state (sk) !=SMC_APPFINCLOSEWAIT )) goto out;if (smc->use_fallback) { rc =kernel_sock_shutdown (smc->clcsock, how); sk->sk_shutdown = smc->clcsock->sk->sk_shutdown;if (sk->sk_shutdown ==SHUTDOWN_MASK ) { - sk->sk_state =SMC_CLOSED ; +smc_sk_set_state (sk,SMC_CLOSED ); sk->sk_socket->state =SS_UNCONNECTED ;sock_put (sk); }
@@ -2945,10 +2945,10 @@ static int smc_shutdown(struct socket *sock, int how) }switch (how) {case SHUT_RDWR :/* shutdown in both directions */ - old_state = sk->sk_state; + old_state =smc_sk_state (sk); rc =smc_close_active (smc);if (old_state ==SMC_ACTIVE && - sk->sk_state ==SMC_PEERCLOSEWAIT1 ) +smc_sk_state (sk) ==SMC_PEERCLOSEWAIT1 ) do_shutdown = false;break ;case SHUT_WR :
@@ -2964,7 +2964,7 @@ static int smc_shutdown(struct socket *sock, int how)/* map sock_shutdown_cmd constants to sk_shutdown value range */ sk->sk_shutdown |= how +1 ; -if (sk->sk_state ==SMC_CLOSED ) +if (smc_sk_state (sk) ==SMC_CLOSED ) sock->state =SS_UNCONNECTED ;else sock->state =SS_DISCONNECTING ;
@@ -3085,16 +3085,15 @@ static int smc_setsockopt(struct socket *sock, int level, int optname,case TCP_FASTOPEN_KEY :case TCP_FASTOPEN_NO_COOKIE :/* option not supported by SMC */ -if (sk->sk_state ==SMC_INIT && !smc->connect_nonblock) { +if (smc_sk_state (sk) ==SMC_INIT && !smc->connect_nonblock) rc =smc_switch_to_fallback (smc,SMC_CLC_DECL_OPTUNSUPP ); - }else { +else rc = -EINVAL ; - }break ;case TCP_NODELAY : -if (sk->sk_state !=SMC_INIT && - sk->sk_state !=SMC_LISTEN && - sk->sk_state !=SMC_CLOSED ) { +if (smc_sk_state (sk) !=SMC_INIT && +smc_sk_state (sk) !=SMC_LISTEN && +smc_sk_state (sk) !=SMC_CLOSED ) {if (val) {SMC_STAT_INC (smc, ndly_cnt);smc_tx_pending (&smc->conn);
@@ -3103,9 +3102,9 @@ static int smc_setsockopt(struct socket *sock, int level, int optname, }break ;case TCP_CORK : -if (sk->sk_state !=SMC_INIT && - sk->sk_state !=SMC_LISTEN && - sk->sk_state !=SMC_CLOSED ) { +if (smc_sk_state (sk) !=SMC_INIT && +smc_sk_state (sk) !=SMC_LISTEN && +smc_sk_state (sk) !=SMC_CLOSED ) {if (!val) {SMC_STAT_INC (smc, cork_cnt);smc_tx_pending (&smc->conn);
@@ -3173,24 +3172,24 @@ static int smc_ioctl(struct socket *sock, unsigned int cmd, }switch (cmd) {case SIOCINQ :/* same as FIONREAD */ -if (smc->sk.sk_state ==SMC_LISTEN ) { +if (smc_sk_state (&smc->sk) ==SMC_LISTEN ) {release_sock (&smc->sk);return -EINVAL ; } -if (smc->sk.sk_state ==SMC_INIT || - smc->sk.sk_state ==SMC_CLOSED ) +if (smc_sk_state (&smc->sk) ==SMC_INIT || +smc_sk_state (&smc->sk) ==SMC_CLOSED ) answ =0 ;else answ =atomic_read (&smc->conn.bytes_to_rcv);break ;case SIOCOUTQ :/* output queue size (not send + not acked) */ -if (smc->sk.sk_state ==SMC_LISTEN ) { +if (smc_sk_state (&smc->sk) ==SMC_LISTEN ) {release_sock (&smc->sk);return -EINVAL ; } -if (smc->sk.sk_state ==SMC_INIT || - smc->sk.sk_state ==SMC_CLOSED ) +if (smc_sk_state (&smc->sk) ==SMC_INIT || +smc_sk_state (&smc->sk) ==SMC_CLOSED ) answ =0 ;else answ = smc->conn.sndbuf_desc->len -
@@ -3198,23 +3197,23 @@ static int smc_ioctl(struct socket *sock, unsigned int cmd,break ;case SIOCOUTQNSD :/* output queue size (not send only) */ -if (smc->sk.sk_state ==SMC_LISTEN ) { +if (smc_sk_state (&smc->sk) ==SMC_LISTEN ) {release_sock (&smc->sk);return -EINVAL ; } -if (smc->sk.sk_state ==SMC_INIT || - smc->sk.sk_state ==SMC_CLOSED ) +if (smc_sk_state (&smc->sk) ==SMC_INIT || +smc_sk_state (&smc->sk) ==SMC_CLOSED ) answ =0 ;else answ =smc_tx_prepared_sends (&smc->conn);break ;case SIOCATMARK : -if (smc->sk.sk_state ==SMC_LISTEN ) { +if (smc_sk_state (&smc->sk) ==SMC_LISTEN ) {release_sock (&smc->sk);return -EINVAL ; } -if (smc->sk.sk_state ==SMC_INIT || - smc->sk.sk_state ==SMC_CLOSED ) { +if (smc_sk_state (&smc->sk) ==SMC_INIT || +smc_sk_state (&smc->sk) ==SMC_CLOSED ) { answ =0 ; }else {smc_curs_copy (&cons, &conn->local_tx_ctrl.cons, conn);
@@ -3248,17 +3247,17 @@ static ssize_t smc_splice_read(struct socket *sock, loff_t *ppos, smc =smc_sk (sk);lock_sock (sk); -if (sk->sk_state ==SMC_CLOSED && (sk->sk_shutdown &RCV_SHUTDOWN )) { +if (smc_sk_state (sk) ==SMC_CLOSED && (sk->sk_shutdown &RCV_SHUTDOWN )) {/* socket was connected before, no more data to read */ rc =0 ; goto out; } -if (sk->sk_state ==SMC_INIT || - sk->sk_state ==SMC_LISTEN || - sk->sk_state ==SMC_CLOSED ) +if (smc_sk_state (sk) ==SMC_INIT || +smc_sk_state (sk) ==SMC_LISTEN || +smc_sk_state (sk) ==SMC_CLOSED ) goto out; -if (sk->sk_state ==SMC_PEERFINCLOSEWAIT ) { +if (smc_sk_state (sk) ==SMC_PEERFINCLOSEWAIT ) { rc =0 ; goto out; }
net/smc/smc.h +3 -0
@@ -38,6 +38,9 @@#define KERNEL_HAS_ATOMIC64 #endif +#define smc_sk_state (sk) ((sk)->sk_state) +#define smc_sk_set_state (sk, state) (smc_sk_state(sk) = (state)) +enum smc_state {/* possible states of an SMC socket */ SMC_ACTIVE =1 ,SMC_INIT =2 ,
net/smc/smc_close.c +49 -49
277 lines not on this page · raw message
net/smc/smc_core.c +12 -12
@@ -1010,8 +1010,8 @@ static int smc_switch_cursor(struct smc_sock *smc, struct smc_cdc_tx_pend *pend,/* recalculate, value is used by tx_rdma_writes() */ atomic_set (&smc->conn.peer_rmbe_space,smc_write_space (conn)); -if (smc->sk.sk_state !=SMC_INIT && - smc->sk.sk_state !=SMC_CLOSED ) { +if (smc_sk_state (&smc->sk) !=SMC_INIT && +smc_sk_state (&smc->sk) !=SMC_CLOSED ) { rc =smcr_cdc_msg_send_validation (conn, pend, wr_buf);if (!rc) {queue_delayed_work (conn->lgr->tx_wq, &conn->tx_work,0 );
@@ -1072,17 +1072,17 @@ struct smc_link *smc_switch_conns(struct smc_link_group *lgr,continue ; smc = container_of(conn, struct smc_sock, conn);/* conn->lnk not yet set in SMC_INIT state */ -if (smc->sk.sk_state ==SMC_INIT ) +if (smc_sk_state (&smc->sk) ==SMC_INIT )continue ; -if (smc->sk.sk_state ==SMC_CLOSED || - smc->sk.sk_state ==SMC_PEERCLOSEWAIT1 || - smc->sk.sk_state ==SMC_PEERCLOSEWAIT2 || - smc->sk.sk_state ==SMC_APPFINCLOSEWAIT || - smc->sk.sk_state ==SMC_APPCLOSEWAIT1 || - smc->sk.sk_state ==SMC_APPCLOSEWAIT2 || - smc->sk.sk_state ==SMC_PEERFINCLOSEWAIT || - smc->sk.sk_state ==SMC_PEERABORTWAIT || - smc->sk.sk_state ==SMC_PROCESSABORT ) { +if (smc_sk_state (&smc->sk) ==SMC_CLOSED || +smc_sk_state (&smc->sk) ==SMC_PEERCLOSEWAIT1 || +smc_sk_state (&smc->sk) ==SMC_PEERCLOSEWAIT2 || +smc_sk_state (&smc->sk) ==SMC_APPFINCLOSEWAIT || +smc_sk_state (&smc->sk) ==SMC_APPCLOSEWAIT1 || +smc_sk_state (&smc->sk) ==SMC_APPCLOSEWAIT2 || +smc_sk_state (&smc->sk) ==SMC_PEERFINCLOSEWAIT || +smc_sk_state (&smc->sk) ==SMC_PEERABORTWAIT || +smc_sk_state (&smc->sk) ==SMC_PROCESSABORT ) {spin_lock_bh (&conn->send_lock);smc_switch_link_and_count (conn, to_lnk);spin_unlock_bh (&conn->send_lock);
net/smc/smc_diag.c +1 -1
@@ -87,7 +87,7 @@ static int __smc_diag_dump(struct sock *sk, struct sk_buff *skb, r =nlmsg_data (nlh);smc_diag_msg_common_fill (r, sk); - r->diag_state = sk->sk_state; + r->diag_state =smc_sk_state (sk);if (smc->use_fallback) r->diag_mode =SMC_DIAG_MODE_FALLBACK_TCP ;else if (smc_conn_lgr_valid (&smc->conn) && smc->conn.lgr->is_smcd)
net/smc/smc_rx.c +8 -8
@@ -44,7 +44,7 @@ static void smc_rx_wake_up(struct sock *sk) EPOLLRDNORM | EPOLLRDBAND);sk_wake_async (sk,SOCK_WAKE_WAITD ,POLL_IN );if ((sk->sk_shutdown ==SHUTDOWN_MASK ) || - (sk->sk_state ==SMC_CLOSED )) + (smc_sk_state (sk) ==SMC_CLOSED ))sk_wake_async (sk,SOCK_WAKE_WAITD ,POLL_HUP );rcu_read_unlock (); }
@@ -119,9 +119,9 @@ static void smc_rx_pipe_buf_release(struct pipe_inode_info *pipe,struct smc_connection *conn;struct sock *sk = &smc->sk; -if (sk->sk_state ==SMC_CLOSED || - sk->sk_state ==SMC_PEERFINCLOSEWAIT || - sk->sk_state ==SMC_APPFINCLOSEWAIT ) +if (smc_sk_state (sk) ==SMC_CLOSED || +smc_sk_state (sk) ==SMC_PEERFINCLOSEWAIT || +smc_sk_state (sk) ==SMC_APPFINCLOSEWAIT ) goto out; conn = &smc->conn;lock_sock (sk);
@@ -316,7 +316,7 @@ static int smc_rx_recv_urg(struct smc_sock *smc, struct msghdr *msg, int len,return rc ? -EFAULT : len; } -if (sk->sk_state ==SMC_CLOSED || sk->sk_shutdown &RCV_SHUTDOWN ) +if (smc_sk_state (sk) ==SMC_CLOSED || sk->sk_shutdown &RCV_SHUTDOWN )return 0 ;return -EAGAIN ;
@@ -361,7 +361,7 @@ int smc_rx_recvmsg(struct smc_sock *smc, struct msghdr *msg,return -EINVAL ;/* future work for sk.sk_family == AF_SMC */ sk = &smc->sk; -if (sk->sk_state ==SMC_LISTEN ) +if (smc_sk_state (sk) ==SMC_LISTEN )return -ENOTCONN ;if (flags &MSG_OOB )return smc_rx_recv_urg (smc, msg, len, flags);
@@ -398,7 +398,7 @@ int smc_rx_recvmsg(struct smc_sock *smc, struct msghdr *msg,if (read_done) {if (sk->sk_err || - sk->sk_state ==SMC_CLOSED || +smc_sk_state (sk) ==SMC_CLOSED || !timeo ||signal_pending (current))break ;
@@ -407,7 +407,7 @@ int smc_rx_recvmsg(struct smc_sock *smc, struct msghdr *msg, read_done =sock_error (sk);break ; } -if (sk->sk_state ==SMC_CLOSED ) { +if (smc_sk_state (sk) ==SMC_CLOSED ) {if (!sock_flag (sk,SOCK_DONE )) {/* This occurs when user tries to read * from never connected socket.
net/smc/smc_tx.c +1 -1
@@ -198,7 +198,7 @@ int smc_tx_sendmsg(struct smc_sock *smc, struct msghdr *msg, size_t len) goto out_err; } -if (sk->sk_state ==SMC_INIT ) +if (smc_sk_state (sk) ==SMC_INIT )return -ENOTCONN ;if (len > conn->sndbuf_desc->len)
Signature · 1 line
1.8.3.1
D. Wythe
maintainerRFC 3/20 net/smc: refactor smc_setsockopt
In reply to D. WytheFrom: "D. Wythe" <[email protected]>
Refactoring the processing of socket options in SMC, extracting common processing functions and unsupported options.
--- net/smc/af_smc.c | 101 ++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 63 insertions(+), 38 deletions(-)
net/smc/af_smc.c +63 -38
@@ -3038,58 +3038,40 @@ static int __smc_setsockopt(struct socket *sock, int level, int optname,return rc; } -static int smc_setsockopt (struct socket *sock,int level,int optname, -sockptr_t optval,unsigned int optlen) +/* When an unsupported sockopt is found, +* SMC should try it best to fallback. If fallback is not possible, +* an error should be explicitly returned. +*/ +static inline bool smc_is_unsupport_tcp_sockopt (int optname) +{ +switch (optname) { +case TCP_FASTOPEN : +case TCP_FASTOPEN_CONNECT : +case TCP_FASTOPEN_KEY : +case TCP_FASTOPEN_NO_COOKIE : +return true; + } +return false; +} + +static int smc_setsockopt_common (struct socket *sock,int level,int optname, +sockptr_t optval,unsigned int optlen) {struct sock *sk = sock->sk;struct smc_sock *smc; -int val, rc; - -if (level ==SOL_TCP && optname ==TCP_ULP ) -return -EOPNOTSUPP ; -else if (level ==SOL_SMC ) -return __smc_setsockopt (sock, level, optname, optval, optlen); +int val, rc =0 ; smc =smc_sk (sk); -/* generic setsockopts reaching us here always apply to the -* CLC socket -*/ -mutex_lock (&smc->clcsock_release_lock); -if (!smc->clcsock) { -mutex_unlock (&smc->clcsock_release_lock); -return -EBADF ; - } -if (unlikely (!smc->clcsock->ops->setsockopt)) - rc = -EOPNOTSUPP ; -else - rc = smc->clcsock->ops->setsockopt (smc->clcsock, level, optname, - optval, optlen); -if (smc->clcsock->sk->sk_err) { - sk->sk_err = smc->clcsock->sk->sk_err; -sk_error_report (sk); - } -mutex_unlock (&smc->clcsock_release_lock); -if (optlen <sizeof (int ))return -EINVAL ;if (copy_from_sockptr (&val, optval,sizeof (int )))return -EFAULT ;lock_sock (sk); -if (rc || smc->use_fallback) +if (smc->use_fallback) goto out;switch (optname) { -case TCP_FASTOPEN : -case TCP_FASTOPEN_CONNECT : -case TCP_FASTOPEN_KEY : -case TCP_FASTOPEN_NO_COOKIE : -/* option not supported by SMC */ -if (smc_sk_state (sk) ==SMC_INIT && !smc->connect_nonblock) - rc =smc_switch_to_fallback (smc,SMC_CLC_DECL_OPTUNSUPP ); -else - rc = -EINVAL ; -break ;case TCP_NODELAY : if (smc_sk_state(sk) != SMC_INIT && smc_sk_state(sk) != SMC_LISTEN &&
@@ -3116,6 +3098,13 @@ static int smc_setsockopt(struct socket *sock, int level, int optname, smc->sockopt_defer_accept = val;break ;default : +if (smc_is_unsupport_tcp_sockopt (optname)) { +/* option not supported by SMC */ +if (smc_sk_state (sk) ==SMC_INIT && !smc->connect_nonblock) + rc =smc_switch_to_fallback (smc,SMC_CLC_DECL_OPTUNSUPP ); +else + rc = -EINVAL ; + }break ; } out:
@@ -3124,6 +3113,42 @@ static int smc_setsockopt(struct socket *sock, int level, int optname,return rc; } +static int smc_setsockopt (struct socket *sock,int level,int optname, +sockptr_t optval,unsigned int optlen) +{ +struct sock *sk = sock->sk; +struct smc_sock *smc; +int rc; + +if (level ==SOL_TCP && optname ==TCP_ULP ) +return -EOPNOTSUPP ; +else if (level ==SOL_SMC ) +return __smc_setsockopt (sock, level, optname, optval, optlen); + + smc =smc_sk (sk); + +/* generic setsockopts reaching us here always apply to the +* CLC socket +*/ +mutex_lock (&smc->clcsock_release_lock); +if (!smc->clcsock) { +mutex_unlock (&smc->clcsock_release_lock); +return -EBADF ; + } +if (unlikely (!smc->clcsock->ops->setsockopt)) + rc = -EOPNOTSUPP ; +else + rc = smc->clcsock->ops->setsockopt (smc->clcsock, level, optname, + optval, optlen); +if (smc->clcsock->sk->sk_err) { + sk->sk_err = smc->clcsock->sk->sk_err; +sk_error_report (sk); + } +mutex_unlock (&smc->clcsock_release_lock); + +return rc ?:smc_setsockopt_common (sock, level, optname, optval, optlen); +} +static int smc_getsockopt (struct socket *sock,int level,int optname,char __user *optval,int __user *optlen) {
Signature · 1 line
1.8.3.1
D. Wythe
maintainerRFC 4/20 net/smc: refactor smc_accept_poll
In reply to D. WytheFrom: "D. Wythe" <[email protected]>
Refactoring smc_accept_poll to extract a common function for determining whether the accept_queue is empty.
--- net/smc/af_smc.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)
net/smc/af_smc.c +8 -9
@@ -2832,17 +2832,16 @@ static int smc_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,return rc; } -static __poll_t smc_accept_poll (struct sock *parent) +static inline bool smc_accept_queue_empty (struct sock *sk) { -struct smc_sock *isk =smc_sk (parent); -__poll_t mask =0 ; - -spin_lock (&isk->accept_q_lock); -if (!list_empty (&isk->accept_q)) - mask =EPOLLIN |EPOLLRDNORM ; -spin_unlock (&isk->accept_q_lock); +return list_empty (&smc_sk (sk)->accept_q); +} -return mask; +static __poll_t smc_accept_poll (struct sock *parent) +{ +if (!smc_accept_queue_empty (parent)) +return EPOLLIN |EPOLLRDNORM ; +return 0 ; } static __poll_t smc_poll(struct file *file, struct socket *sock,
Signature · 1 line
1.8.3.1
D. Wythe
maintainerRFC 5/20 net/smc: try test to fallback when ulp set
In reply to D. WytheFrom: "D. Wythe" <[email protected]>
Currently, when the ULP option was seen, we will immediately return a failure. Here we try to fallback first as much as possible, rather than immediately returning.
--- net/smc/af_smc.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
net/smc/af_smc.c +2 -3
@@ -3048,6 +3048,7 @@ static inline bool smc_is_unsupport_tcp_sockopt(int optname)case TCP_FASTOPEN_CONNECT :case TCP_FASTOPEN_KEY :case TCP_FASTOPEN_NO_COOKIE : +case TCP_ULP :return true; }return false;
@@ -3119,9 +3120,7 @@ static int smc_setsockopt(struct socket *sock, int level, int optname,struct smc_sock *smc;int rc; -if (level ==SOL_TCP && optname ==TCP_ULP ) -return -EOPNOTSUPP ; -else if (level ==SOL_SMC ) +if (level ==SOL_SMC )return __smc_setsockopt (sock, level, optname, optval, optlen); smc =smc_sk (sk);
Signature · 1 line
1.8.3.1
D. Wythe
maintainerRFC 6/20 net/smc: fast return on unconcernd TCP options
In reply to D. WytheFrom: "D. Wythe" <[email protected]>
SMC does not require additional processing of every TCP options, hence that when options that do not require additional processing, we can immediately return.
Note that options which are explicitly not supported require a try to fallback, and shall not simplt returned.
--- net/smc/af_smc.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
net/smc/af_smc.c +26 -0
@@ -3054,6 +3054,28 @@ static inline bool smc_is_unsupport_tcp_sockopt(int optname)return false; } +/* Return true if smc might modify the semantics of +* the imcoming TCP options. Specifically, it includes +* unsupported TCP options. +*/ +static inline bool smc_need_override_tcp_sockopt (struct sock *sk,int optname) +{ +switch (optname) { +case TCP_NODELAY : +case TCP_CORK : +if (smc_sk_state (sk) ==SMC_INIT || +smc_sk_state (sk) ==SMC_LISTEN || +smc_sk_state (sk) ==SMC_CLOSED ) +return false; + fallthrough; +case TCP_DEFER_ACCEPT : +return true; +default : +break ; + } +return smc_is_unsupport_tcp_sockopt (optname); +} +static int smc_setsockopt_common (struct socket *sock,int level,int optname,sockptr_t optval,unsigned int optlen) {
@@ -3063,6 +3085,10 @@ static int smc_setsockopt_common(struct socket *sock, int level, int optname, smc =smc_sk (sk); +/* Fast path, just go away if no extra action needed */ +if (!smc_need_override_tcp_sockopt (sk, optname)) +return 0 ; +if (optlen <sizeof (int ))return -EINVAL ;if (copy_from_sockptr (&val, optval,sizeof (int )))
Signature · 1 line
1.8.3.1
D. Wythe
maintainerRFC 7/20 net/smc: refactor sock_flag/sock_set_flag
In reply to D. WytheFrom: "D. Wythe" <[email protected]>
Use a unified new macro to access the flag of the sock, so that we can easily modify the behavior of a specific flag instead of modifying the original function.
--- net/smc/af_smc.c | 4 ++-- net/smc/smc.h | 2 ++ net/smc/smc_cdc.c | 2 +- net/smc/smc_close.c | 8 ++++---- net/smc/smc_rx.c | 8 ++++---- 5 files changed, 13 insertions(+), 11 deletions(-)
net/smc/af_smc.c +2 -2
@@ -358,7 +358,7 @@ static void smc_destruct(struct sock *sk) {if (smc_sk_state (sk) !=SMC_CLOSED )return ; -if (!sock_flag (sk,SOCK_DEAD )) +if (!smc_sock_flag (sk,SOCK_DEAD ))return ; }
@@ -1623,7 +1623,7 @@ static void smc_connect_work(struct work_struct *work) smc->sk.sk_err = -rc; out: -if (!sock_flag (&smc->sk,SOCK_DEAD )) { +if (!smc_sock_flag (&smc->sk,SOCK_DEAD )) {if (smc->sk.sk_err) { smc->sk.sk_state_change (&smc->sk); }else {/* allow polling before and after fallback decision */
net/smc/smc.h +2 -0
@@ -388,4 +388,6 @@ static inline void smc_sock_set_flag(struct sock *sk, enum sock_flags flag) set_bit(flag, &sk->sk_flags); } +#define smc_sock_flag (sk, flag) sock_flag(sk, flag) +#endif /* __SMC_H */
net/smc/smc_cdc.c +1 -1
@@ -285,7 +285,7 @@ static void smc_cdc_handle_urg_data_arrival(struct smc_sock *smc,/* new data included urgent business */ smc_curs_copy (&conn->urg_curs, &conn->local_rx_ctrl.prod, conn); conn->urg_state =SMC_URG_VALID ; -if (!sock_flag (&smc->sk,SOCK_URGINLINE )) +if (!smc_sock_flag (&smc->sk,SOCK_URGINLINE ))/* we'll skip the urgent byte, so don't account for it */ (*diff_prod)--; base = (char *)conn->rmb_desc->cpu_addr + conn->rx_off;
net/smc/smc_close.c +4 -4
@@ -202,7 +202,7 @@ int smc_close_active(struct smc_sock *smc)int rc1 =0 ; timeout = current->flags &PF_EXITING ? -0 :sock_flag (sk,SOCK_LINGER ) ? +0 :smc_sock_flag (sk,SOCK_LINGER ) ? sk->sk_lingertime :SMC_MAX_STREAM_WAIT_TIMEOUT ; old_state =smc_sk_state (sk);
@@ -395,7 +395,7 @@ static void smc_close_passive_work(struct work_struct *work)case SMC_PEERCLOSEWAIT2 :if (!smc_cdc_rxed_any_close (conn))break ; -if (sock_flag (sk,SOCK_DEAD ) && +if (smc_sock_flag (sk,SOCK_DEAD ) &&smc_close_sent_any_close (conn)) {/* smc_release has already been called locally */ smc_sk_set_state (sk,SMC_CLOSED );
@@ -432,7 +432,7 @@ static void smc_close_passive_work(struct work_struct *work)if (old_state !=smc_sk_state (sk)) { sk->sk_state_change (sk);if ((smc_sk_state (sk) ==SMC_CLOSED ) && - (sock_flag (sk,SOCK_DEAD ) || !sk->sk_socket)) { + (smc_sock_flag (sk,SOCK_DEAD ) || !sk->sk_socket)) {smc_conn_free (conn);if (smc->clcsock) release_clcsock = true;
@@ -453,7 +453,7 @@ int smc_close_shutdown_write(struct smc_sock *smc)int rc =0 ; timeout = current->flags &PF_EXITING ? -0 :sock_flag (sk,SOCK_LINGER ) ? +0 :smc_sock_flag (sk,SOCK_LINGER ) ? sk->sk_lingertime :SMC_MAX_STREAM_WAIT_TIMEOUT ; old_state =smc_sk_state (sk);
net/smc/smc_rx.c +4 -4
@@ -70,7 +70,7 @@ static int smc_rx_update_consumer(struct smc_sock *smc,if (conn->urg_state ==SMC_URG_VALID || conn->urg_rx_skip_pend) { diff =smc_curs_comp (conn->rmb_desc->len, &cons, &conn->urg_curs); -if (sock_flag (sk,SOCK_URGINLINE )) { +if (smc_sock_flag (sk,SOCK_URGINLINE )) {if (diff ==0 ) { force = true; rc =1 ;
@@ -286,7 +286,7 @@ static int smc_rx_recv_urg(struct smc_sock *smc, struct msghdr *msg, int len,struct sock *sk = &smc->sk;int rc =0 ; -if (sock_flag (sk,SOCK_URGINLINE ) || +if (smc_sock_flag (sk,SOCK_URGINLINE ) || !(conn->urg_state ==SMC_URG_VALID ) || conn->urg_state ==SMC_URG_READ )return -EINVAL ;
@@ -408,7 +408,7 @@ int smc_rx_recvmsg(struct smc_sock *smc, struct msghdr *msg,break ; }if (smc_sk_state (sk) ==SMC_CLOSED ) { -if (!sock_flag (sk,SOCK_DONE )) { +if (!smc_sock_flag (sk,SOCK_DONE )) {/* This occurs when user tries to read * from never connected socket. */
@@ -449,7 +449,7 @@ int smc_rx_recvmsg(struct smc_sock *smc, struct msghdr *msg,if (splbytes)smc_curs_add (conn->rmb_desc->len, &cons, splbytes);if (conn->urg_state ==SMC_URG_VALID && -sock_flag (&smc->sk,SOCK_URGINLINE ) && +smc_sock_flag (&smc->sk,SOCK_URGINLINE ) && readable >1 ) readable--;/* always stop at urgent Byte */ /* not more than what user space asked for */
Signature · 1 line
1.8.3.1
D. Wythe
maintainerRFC 8/20 net/smc: optimize mutex_fback_rsn from mutex to spinlock
In reply to D. WytheFrom: "D. Wythe" <[email protected]>
The region protected by mutex_fback_rsn is simple enough and has no potential blocking points. This change makes us can invoke smc_stat_fallback() in any context, typically, in the context of IRQ.
--- include/net/netns/smc.h | 2 +- net/smc/af_smc.c | 4 ++-- net/smc/smc_stats.c | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-)
include/net/netns/smc.h +1 -1
@@ -10,7 +10,7 @@ struct netns_smc {/* per cpu counters for SMC */ struct smc_stats __percpu *smc_stats;/* protect fback_rsn */ -struct mutex mutex_fback_rsn; +spinlock_t mutex_fback_rsn;struct smc_stats_rsn *fback_rsn;bool limit_smc_hs;/* constraint on handshake */
net/smc/af_smc.c +2 -2
@@ -769,7 +769,7 @@ static void smc_stat_fallback(struct smc_sock *smc) {struct net *net =sock_net (&smc->sk); -mutex_lock (&net->smc.mutex_fback_rsn); +spin_lock_bh (&net->smc.mutex_fback_rsn);if (smc->listen_smc) {smc_stat_inc_fback_rsn_cnt (smc, net->smc.fback_rsn->srv); net->smc.fback_rsn->srv_fback_cnt++;
@@ -777,7 +777,7 @@ static void smc_stat_fallback(struct smc_sock *smc)smc_stat_inc_fback_rsn_cnt (smc, net->smc.fback_rsn->clnt); net->smc.fback_rsn->clnt_fback_cnt++; } -mutex_unlock (&net->smc.mutex_fback_rsn); +spin_unlock_bh (&net->smc.mutex_fback_rsn); }/* must be called under rcu read lock */
net/smc/smc_stats.c +3 -3
@@ -26,7 +26,7 @@ int smc_stats_init(struct net *net) net->smc.smc_stats = alloc_percpu(struct smc_stats);if (!net->smc.smc_stats) goto err_stats; -mutex_init (&net->smc.mutex_fback_rsn); +spin_lock_init (&net->smc.mutex_fback_rsn);return 0 ; err_stats:
@@ -387,7 +387,7 @@ int smc_nl_get_fback_stats(struct sk_buff *skb, struct netlink_callback *cb)int snum = cb_ctx->pos[0 ];bool is_srv = true; -mutex_lock (&net->smc.mutex_fback_rsn); +spin_lock_bh (&net->smc.mutex_fback_rsn);for (k =0 ; k <SMC_MAX_FBACK_RSN_CNT ; k++) {if (k < snum)continue ;
@@ -406,7 +406,7 @@ int smc_nl_get_fback_stats(struct sk_buff *skb, struct netlink_callback *cb)if (rc_clnt == -ENODATA && rc_srv == -ENODATA )break ; } -mutex_unlock (&net->smc.mutex_fback_rsn); +spin_unlock_bh (&net->smc.mutex_fback_rsn); cb_ctx->pos[1 ] = skip_serv; cb_ctx->pos[0 ] = k;return skb->len;
Signature · 1 line
1.8.3.1
D. Wythe
maintainerRFC 9/20 net/smc: refator smc_switch_to_fallback
In reply to D. WytheFrom: "D. Wythe" <[email protected]>
Move code ahead which has no need protected by clcsock_release_lock, On the one hand, this reduces the granularity of the critical area, and on the other hand, for the inet version of SMC, the code protected by the critical area is meaningless. This patch make it possible to invoke smc_switch_to_fallback() in any context (IRQ .etc) within inet sock version of SMC.
--- net/smc/af_smc.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
net/smc/af_smc.c +6 -4
@@ -909,16 +909,18 @@ static int smc_switch_to_fallback(struct smc_sock *smc, int reason_code) {int rc =0 ; +/* no need protected by clcsock_release_lock, move head */ + smc->use_fallback = true; + smc->fallback_rsn = reason_code; +smc_stat_fallback (smc); +trace_smc_switch_to_fallback (smc, reason_code); +mutex_lock (&smc->clcsock_release_lock);if (!smc->clcsock) { rc = -EBADF ; goto out; } - smc->use_fallback = true; - smc->fallback_rsn = reason_code; -smc_stat_fallback (smc); -trace_smc_switch_to_fallback (smc, reason_code);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;
Signature · 1 line
1.8.3.1
D. Wythe
maintainerRFC 10/20 net/smc: make initialization code in smc_listen independent
In reply to D. WytheFrom: "D. Wythe" <[email protected]>
This patch make the initialization code in smc_listen independent as smc_init_listen, we will use it in the inet version of SMC. This patch clearly has no side effects, logically speaking, it only refactored this smc_listen() function.
--- net/smc/af_smc.c | 49 +++++++++++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 20 deletions(-)
net/smc/af_smc.c +29 -20
@@ -2610,6 +2610,34 @@ static void smc_clcsock_data_ready(struct sock *listen_clcsock)read_unlock_bh (&listen_clcsock->sk_callback_lock); } +static inline void smc_init_listen (struct smc_sock *smc) +{ +struct sock *clcsk; + + clcsk =smc_sock_is_inet_sock (&smc->sk) ? &smc->sk : smc->clcsock->sk; + +/* save original sk_data_ready function and establish +* smc-specific sk_data_ready function +*/ +write_lock_bh (&clcsk->sk_callback_lock); + clcsk->sk_user_data = + (void *)((uintptr_t )smc |SK_USER_DATA_NOCOPY ); +smc_clcsock_replace_cb (&clcsk->sk_data_ready, + smc_clcsock_data_ready, &smc->clcsk_data_ready); +write_unlock_bh (&clcsk->sk_callback_lock); + +/* save original ops */ + smc->ori_af_ops =inet_csk (clcsk)->icsk_af_ops; + + smc->af_ops = *smc->ori_af_ops; + smc->af_ops.syn_recv_sock = smc_tcp_syn_recv_sock; + +inet_csk (clcsk)->icsk_af_ops = &smc->af_ops; + +if (smc->limit_smc_hs) +tcp_sk (clcsk)->smc_hs_congested = smc_hs_congested; +} +static int smc_listen (struct socket *sock,int backlog) {struct sock *sk = sock->sk;
@@ -2636,26 +2664,7 @@ static int smc_listen(struct socket *sock, int backlog)if (!smc->use_fallback)tcp_sk (smc->clcsock->sk)->syn_smc =1 ; -/* save original sk_data_ready function and establish -* smc-specific sk_data_ready function -*/ -write_lock_bh (&smc->clcsock->sk->sk_callback_lock); - smc->clcsock->sk->sk_user_data = - (void *)((uintptr_t )smc |SK_USER_DATA_NOCOPY ); -smc_clcsock_replace_cb (&smc->clcsock->sk->sk_data_ready, - smc_clcsock_data_ready, &smc->clcsk_data_ready); -write_unlock_bh (&smc->clcsock->sk->sk_callback_lock); - -/* save original ops */ - smc->ori_af_ops =inet_csk (smc->clcsock->sk)->icsk_af_ops; - - smc->af_ops = *smc->ori_af_ops; - smc->af_ops.syn_recv_sock = smc_tcp_syn_recv_sock; - -inet_csk (smc->clcsock->sk)->icsk_af_ops = &smc->af_ops; - -if (smc->limit_smc_hs) -tcp_sk (smc->clcsock->sk)->smc_hs_congested = smc_hs_congested; +smc_init_listen (smc); rc =kernel_listen (smc->clcsock, backlog);if (rc) {
Signature · 1 line
1.8.3.1
D. Wythe
maintainerRFC 11/20 net/smc: make __smc_accept can return the new accepted sock
In reply to D. WytheFrom: "D. Wythe" <[email protected]>
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.
--- net/smc/af_smc.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-)
net/smc/af_smc.c +18 -6
@@ -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,
Signature · 1 line
1.8.3.1
D. Wythe
maintainerRFC 12/20 net/smc: refatoring initialization of smc sock
In reply to D. WytheFrom: "D. Wythe" <[email protected]>
This patch try extract the common part of smc sock initialization, use smc_sock_init() for active open sock initialization, smc_sock_init_passive() for passive open sock initialization. This is a preparation to implement the inet version of SMC.
--- net/smc/af_smc.c | 58 +++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 41 insertions(+), 17 deletions(-)
net/smc/af_smc.c +41 -17
@@ -362,10 +362,48 @@ static void smc_destruct(struct sock *sk)return ; } +static inline void smc_sock_init_common (struct sock *sk) +{ +struct smc_sock *smc =smc_sk (sk); + +smc_sk_set_state (sk,SMC_INIT ); +INIT_DELAYED_WORK (&smc->conn.tx_work, smc_tx_work); +spin_lock_init (&smc->conn.send_lock); +mutex_init (&smc->clcsock_release_lock); +} + +static void smc_sock_init_passive (struct sock *par,struct sock *sk) +{ +struct smc_sock *parent =smc_sk (par); +struct sock *clcsk; + +smc_sock_init_common (sk); +smc_sk (sk)->listen_smc = parent; + + clcsk =smc_sock_is_inet_sock (sk) ? sk :smc_sk (sk)->clcsock->sk; +if (tcp_sk (clcsk)->syn_smc) +atomic_inc (&parent->queued_smc_hs); +} + +static void smc_sock_init (struct sock *sk,struct net *net) +{ +struct smc_sock *smc =smc_sk (sk); + +smc_sock_init_common (sk); +WRITE_ONCE (sk->sk_sndbuf,2 *READ_ONCE (net->smc.sysctl_wmem)); +WRITE_ONCE (sk->sk_rcvbuf,2 *READ_ONCE (net->smc.sysctl_rmem)); +INIT_WORK (&smc->tcp_listen_work, smc_tcp_listen_work); +INIT_WORK (&smc->connect_work, smc_connect_work); +INIT_LIST_HEAD (&smc->accept_q); +spin_lock_init (&smc->accept_q_lock); +smc_init_saved_callbacks (smc); + + sk->sk_destruct = smc_destruct; +} +static struct sock *smc_sock_alloc (struct net *net,struct socket *sock,int protocol) { -struct smc_sock *smc;struct proto *prot;struct sock *sk;
@@ -375,21 +413,9 @@ static struct sock *smc_sock_alloc(struct net *net, struct socket *sock,return NULL ;sock_init_data (sock, sk);/* sets sk_refcnt to 1 */ -smc_sk_set_state (sk,SMC_INIT ); - sk->sk_destruct = smc_destruct; sk->sk_protocol = protocol; -WRITE_ONCE (sk->sk_sndbuf,2 *READ_ONCE (net->smc.sysctl_wmem)); -WRITE_ONCE (sk->sk_rcvbuf,2 *READ_ONCE (net->smc.sysctl_rmem)); - smc =smc_sk (sk); -INIT_WORK (&smc->tcp_listen_work, smc_tcp_listen_work); -INIT_WORK (&smc->connect_work, smc_connect_work); -INIT_DELAYED_WORK (&smc->conn.tx_work, smc_tx_work); -INIT_LIST_HEAD (&smc->accept_q); -spin_lock_init (&smc->accept_q_lock); -spin_lock_init (&smc->conn.send_lock); +smc_sock_init (sk, net); sk->sk_prot->hash (sk); -mutex_init (&smc->clcsock_release_lock); -smc_init_saved_callbacks (smc);return sk; }
@@ -2573,10 +2599,8 @@ static void smc_tcp_listen_work(struct work_struct *work)if (!new_smc)continue ; -if (tcp_sk (new_smc->clcsock->sk)->syn_smc) -atomic_inc (&lsmc->queued_smc_hs); +smc_sock_init_passive (lsk, &new_smc->sk); - new_smc->listen_smc = lsmc; new_smc->use_fallback = lsmc->use_fallback; new_smc->fallback_rsn = lsmc->fallback_rsn;sock_hold (lsk);/* sock_put in smc_listen_work */
Signature · 1 line
1.8.3.1
D. Wythe
maintainerRFC 13/20 net/smc: embedded tcp sock into smc sock
In reply to D. WytheFrom: "D. Wythe" <[email protected]>
For inet version of SMC, one of the key goals is to make a fallbacked smc sock can be recognazied as a tcp sock by net tools.
So, it is necessary to embedded the tcp sock into smc sock and make the tcp sock as the first member of smc sock.
--- net/smc/smc.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
net/smc/smc.h +10 -1
@@ -248,7 +248,11 @@ struct smc_connection { };struct smc_sock {/* smc sock container */ -struct sock sk; +union { +struct tcp6_sock tp6sk; +struct tcp_sock tpsk; +struct sock sk; + };struct socket *clcsock;/* internal tcp socket */ void (*clcsk_state_change)(struct sock *sk);/* original stat_change fct. */
@@ -388,6 +392,11 @@ static inline void smc_sock_set_flag(struct sock *sk, enum sock_flags flag)set_bit (flag, &sk->sk_flags); } +static __always_inline bool smc_sock_is_inet_sock(const struct sock *sk) +{ +return inet_test_bit (IS_ICSK , sk); +} +#define smc_sock_flag (sk, flag) sock_flag(sk, flag)#endif /* __SMC_H */
Signature · 1 line
1.8.3.1
D. Wythe
maintainerRFC 14/20 net/smc: allow to access the state of inet smc sock
In reply to D. WytheFrom: "D. Wythe" <[email protected]>
As we know, in inet version of smc, smc_sock and tcp_sock coexist, this will result in the sk_state field has been accessed and modified by both protocols, which can cause obvious exceptions. Therefore, this patch modify the state macro for reading and setting the smc state, using the icsk field to determine which is the very field needed to be accessed or changed.
--- net/smc/smc.h | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-)
net/smc/smc.h +15 -3
@@ -38,9 +38,6 @@#define KERNEL_HAS_ATOMIC64 #endif -#define smc_sk_state (sk) ((sk)->sk_state) -#define smc_sk_set_state (sk, state) (smc_sk_state(sk) = (state)) -enum smc_state {/* possible states of an SMC socket */ SMC_ACTIVE =1 ,SMC_INIT =2 ,
@@ -254,6 +251,7 @@ struct smc_sock { /* smc sock container */struct sock sk; };struct socket *clcsock;/* internal tcp socket */ +unsigned char smc_state;/* smc state used in smc via inet_sk */ void (*clcsk_state_change)(struct sock *sk);/* original stat_change fct. */ void (*clcsk_data_ready)(struct sock *sk);
@@ -397,6 +395,20 @@ static __always_inline bool smc_sock_is_inet_sock(const struct sock *sk)return inet_test_bit (IS_ICSK , sk); } +#define smc_sk_state (sk) ({ \ + struct sock *__sk = (sk); \ + smc_sock_is_inet_sock(__sk) ? \ + smc_sk(__sk)->smc_state : (__sk)->sk_state; \ +}) + +static __always_inline void smc_sk_set_state(struct sock *sk, unsigned char state) +{ +if (smc_sock_is_inet_sock (sk)) +smc_sk (sk)->smc_state = state; +else + sk->sk_state = state; +} +#define smc_sock_flag (sk, flag) sock_flag(sk, flag)#endif /* __SMC_H */
Signature · 1 line
1.8.3.1
D. Wythe
maintainerRFC 15/20 net/smc: enable access of sock flags of inet smc sock
In reply to D. WytheFrom: "D. Wythe" <[email protected]>
Since smc_sock and tcp_sock coexist in inet version of smc, the sock flags field are shared between tcp and smc. Like the sk_state, we also need a extra sock flags filed for smc in inet version, and using the icsk field to determine which is the very field needed to be accessed or changed.
--- net/smc/smc.h | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-)
net/smc/smc.h +29 -5
@@ -252,6 +252,7 @@ struct smc_sock { /* smc sock container */ };struct socket *clcsock;/* internal tcp socket */ unsigned char smc_state;/* smc state used in smc via inet_sk */ +unsigned long smc_sk_flags;/* smc sock flags used for inet sock */ void (*clcsk_state_change)(struct sock *sk);/* original stat_change fct. */ void (*clcsk_data_ready)(struct sock *sk);
@@ -385,10 +386,6 @@ void smc_fill_gid_list(struct smc_link_group *lgr,int smc_nl_enable_hs_limitation (struct sk_buff *skb,struct genl_info *info);int smc_nl_disable_hs_limitation (struct sk_buff *skb,struct genl_info *info); -static inline void smc_sock_set_flag (struct sock *sk,enum sock_flags flag) -{ -set_bit (flag, &sk->sk_flags); -} static __always_inline bool smc_sock_is_inet_sock(const struct sock *sk) {
@@ -409,6 +406,33 @@ static __always_inline void smc_sk_set_state(struct sock *sk, unsigned char stat sk->sk_state = state; } -#define smc_sock_flag (sk, flag) sock_flag(sk, flag) +static __always_inline bool smc_sock_flag(const struct sock *sk, enum sock_flags flag) +{ +if (smc_sock_is_inet_sock (sk)) { +switch (flag) { +case SOCK_DEAD : +case SOCK_DONE : +return test_bit (flag, &smc_sk (sk)->smc_sk_flags); +default : +break ; + } + } +return sock_flag (sk, flag); +} + +static __always_inline void smc_sock_set_flag(struct sock *sk, enum sock_flags flag) +{ +if (smc_sock_is_inet_sock (sk)) { +switch (flag) { +case SOCK_DEAD : +case SOCK_DONE : +__set_bit (flag, &smc_sk (sk)->smc_sk_flags); +return ; +default : +break ; + } + } +set_bit (flag, &sk->sk_flags); +}#endif /* __SMC_H */
Signature · 1 line
1.8.3.1
D. Wythe
maintainerRFC 16/20 net/smc: add inet proto defination for SMC
In reply to D. WytheFrom: "D. Wythe" <[email protected]>
To implement SMC based on INET sock, we need to be able to identify its real sock type, So we need to apply for a unique IPPROTO_XXX definition.
But unlike IPPROTO_TCP or other similar definitions, which values need to be filled into IP message and transmitted in the network. In fact, we just need make sure it is unique in the code. That is, IPPROTO_SMC dose not exist in network, and it is only used to distinguish actual inet sock type in code, and it's still IPPROTO_TCP that is transmitted in the network.
In theory, we just need to define IPPROTO_SMC as value greater than 255 and unique in the code. In this patch, we pick 263, following IPPROTO_MPTCP.
--- include/uapi/linux/in.h | 2 ++ tools/include/uapi/linux/in.h | 2 ++ 2 files changed, 4 insertions(+)
include/uapi/linux/in.h +2 -0
@@ -83,6 +83,8 @@ enum {#define IPPROTO_RAW IPPROTO_RAW IPPROTO_MPTCP = 262, /* Multipath TCP connection */#define IPPROTO_MPTCP IPPROTO_MPTCP + IPPROTO_SMC = 263, /* Shared Memory Communications */ +#define IPPROTO_SMC IPPROTO_SMCIPPROTO_MAX };#endif
tools/include/uapi/linux/in.h +2 -0
@@ -83,6 +83,8 @@ enum {#define IPPROTO_RAW IPPROTO_RAW IPPROTO_MPTCP = 262, /* Multipath TCP connection */#define IPPROTO_MPTCP IPPROTO_MPTCP + IPPROTO_SMC = 263, /* Shared Memory Communications */ +#define IPPROTO_SMC IPPROTO_SMCIPPROTO_MAX };#endif
Signature · 1 line
1.8.3.1
D. Wythe
maintainerRFC 17/20 net/smc: add dummy implementation for inet smc sock
In reply to D. WytheFrom: "D. Wythe" <[email protected]>
This patch implements a dummy version of inet smc sock, and register it into the inet protocols, which allows us to create a inet smc sock.
Note that, the ops is forked from tcp ops. The vast majority of fields are consistent with TCP, and those cannot be consistent, mainly including,
1. obj_size
2. tw_prot and rsk_prot
3. function than need to be override, explicitly set to NULL.
--- net/smc/Makefile | 1 + net/smc/af_smc.c | 46 +++++++- net/smc/smc_inet.c | 315 +++++++++++++++++++++++++++++++++++++++++++++++++++++ net/smc/smc_inet.h | 86 +++++++++++++++ 4 files changed, 447 insertions(+), 1 deletion(-) create mode 100644 net/smc/smc_inet.c create mode 100644 net/smc/smc_inet.h
net/smc/Makefile +1 -0
@@ -5,4 +5,5 @@ obj-$(CONFIG_SMC_DIAG) += smc_diag.o smc-y := af_smc.o smc_pnet.o smc_ib.o smc_clc.o smc_core.o smc_wr.o smc_llc.o smc-y += smc_cdc.o smc_tx.o smc_rx.o smc_close.o smc_ism.o smc_netlink.o smc_stats.o smc-y += smc_tracepoint.o +smc-y += smc_inet.o smc-$(CONFIG_SYSCTL) += smc_sysctl.o
net/smc/af_smc.c +45 -1
83 lines not on this page · raw message
net/smc/smc_inet.c new file +315 -0
315 lines not on this page · raw message
net/smc/smc_inet.h new file +86 -0
86 lines not on this page · raw message
Signature · 1 line
1.8.3.1
D. Wythe
maintainerRFC 18/20 net/smc: add define and macro for smc_negotiation
In reply to D. WytheFrom: "D. Wythe" <[email protected]>
smc_negotiation is a new way to describe the state of the SMC protocol, note that it will only be used by inet sock. It mainly describes the following states of SMC sock:
TBD: Before TCP handshake is completed. PREPARE: TCP is established, and smc is establishing. SMC: smc handshake is established. NO_SMC: sock should act as TCP.
Before this patch, it is determined that these conditions must be applied simultaneously to syn_smc/use_fallback/sk_state, synchronization of fields needs to be handled with care, while syn_smc field cannot be modified at any time. Based on these considerations, inet sock uses smc_negotiation to control the protocol state.
--- net/smc/smc.h | 1 + net/smc/smc_inet.h | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 97 insertions(+)
net/smc/smc.h +1 -0
@@ -252,6 +252,7 @@ struct smc_sock { /* smc sock container */ };struct socket *clcsock;/* internal tcp socket */ unsigned char smc_state;/* smc state used in smc via inet_sk */ +unsigned int isck_smc_negotiation;unsigned long smc_sk_flags;/* smc sock flags used for inet sock */ void (*clcsk_state_change)(struct sock *sk);/* original stat_change fct. */
net/smc/smc_inet.h +96 -0
108 lines not on this page · raw message
Signature · 1 line
1.8.3.1
D. Wythe
maintainerRFC 19/20 net/smc: support smc inet with merge socks
In reply to D. WytheFrom: "D. Wythe" <[email protected]>
This patch mainly implements how AF_INET works under one single sock.
Unlike the AF_SMC sock, the inet smc can directly fallback to TCP under the IRQ context, no need to start a work in workqueue. The inet smc start the listen work only when the peer has syn_smc set. It accelerates the efficiency of establishing connections whom prove to be SMC unsupported.
The complex logic here is that we need to dynamically sort the reqsk in TCP, and try to move ahead the syn_smc with 0 as much as possible, which allows for faster fallback connections. However, due to the timing issue of accept, we cannot always guarantee this condition.
--- include/linux/tcp.h | 1 + net/smc/af_smc.c | 942 +++++++++++++++++++++++++++++++++++++++++++++++++++- net/smc/smc.h | 7 + net/smc/smc_cdc.h | 8 + net/smc/smc_clc.h | 1 + net/smc/smc_close.c | 16 +- net/smc/smc_inet.c | 215 +++++++++--- net/smc/smc_inet.h | 98 ++++++ net/smc/smc_rx.c | 6 +- 9 files changed, 1236 insertions(+), 58 deletions(-)
include/linux/tcp.h +1 -0
@@ -479,6 +479,7 @@ struct tcp_sock {#if IS_ENABLED (CONFIG_SMC )bool (*smc_hs_congested)(const struct sock *sk);bool syn_smc;/* SYN includes SMC */ +bool is_smc;/* is this sock also a smc sock */ #endif #if defined(CONFIG_TCP_MD5SIG ) || defined(CONFIG_TCP_AO )
net/smc/af_smc.c +930 -12
1,044 lines not on this page · raw message
net/smc/smc.h +7 -0
@@ -251,9 +251,14 @@ struct smc_sock { /* smc sock container */struct sock sk; };struct socket *clcsock;/* internal tcp socket */ +struct socket accompany_socket;unsigned char smc_state;/* smc state used in smc via inet_sk */ unsigned int isck_smc_negotiation;unsigned long smc_sk_flags;/* smc sock flags used for inet sock */ +unsigned int queued_cnt; +struct request_sock *tail_0; +struct request_sock *tail_1; +struct request_sock *reqsk;void (*clcsk_state_change)(struct sock *sk);/* original stat_change fct. */ void (*clcsk_data_ready)(struct sock *sk);
@@ -262,6 +267,7 @@ struct smc_sock { /* smc sock container *//* original write_space fct. */ void (*clcsk_error_report)(struct sock *sk);/* original error_report fct. */ +void (*original_sk_destruct)(struct sock *sk);struct smc_connection conn;/* smc connection */ struct smc_sock *listen_smc;/* listen parent */ struct work_struct connect_work;/* handle non-blocking connect*/
@@ -290,6 +296,7 @@ struct smc_sock { /* smc sock container *//* non-blocking connect in * flight */ + u8 ordered : 1;struct mutex clcsock_release_lock;/* protects clcsock of a listen * socket
net/smc/smc_cdc.h +8 -0
@@ -302,4 +302,12 @@ int smcr_cdc_msg_send_validation(struct smc_connection *conn,int smc_cdc_init (void )__init ;void smcd_cdc_rx_init (struct smc_connection *conn); +static inline bool smc_has_rcv_shutdown (struct sock *sk) +{ +if (smc_sock_is_inet_sock (sk)) +return smc_cdc_rxed_any_close_or_senddone (&smc_sk (sk)->conn); +else +return sk->sk_shutdown &RCV_SHUTDOWN ; +} +#endif /* SMC_CDC_H */
net/smc/smc_clc.h +1 -0
@@ -35,6 +35,7 @@#define SMC_CLC_DECL_TIMEOUT_AL 0x02020000/* timeout w4 QP add link */ #define SMC_CLC_DECL_CNFERR 0x03000000/* configuration error */ #define SMC_CLC_DECL_PEERNOSMC 0x03010000/* peer did not indicate SMC */ +#define SMC_CLC_DECL_ACTIVE 0x03010001/* local active fallback */ #define SMC_CLC_DECL_IPSEC 0x03020000/* IPsec usage */ #define SMC_CLC_DECL_NOSMCDEV 0x03030000/* no SMC device found (R or D) */ #define SMC_CLC_DECL_NOSMCDDEV 0x03030001/* no SMC-D device found */
net/smc/smc_close.c +13 -3
@@ -19,6 +19,7 @@#include "smc_tx.h" #include "smc_cdc.h" #include "smc_close.h" +#include "smc_inet.h" /* release the clcsock that is assigned to the smc_sock */ void smc_clcsock_release (struct smc_sock *smc)
@@ -27,6 +28,10 @@ void smc_clcsock_release(struct smc_sock *smc)if (smc->listen_smc &¤t_work () != &smc->smc_listen_work)cancel_work_sync (&smc->smc_listen_work); + +if (smc_sock_is_inet_sock (&smc->sk)) +return ; +mutex_lock (&smc->clcsock_release_lock);if (smc->clcsock) { tcp = smc->clcsock;
@@ -130,11 +135,16 @@ void smc_close_active_abort(struct smc_sock *smc)struct sock *sk = &smc->sk;bool release_clcsock = false; -if (smc_sk_state (sk) !=SMC_INIT && smc->clcsock && smc->clcsock->sk) { - sk->sk_err =ECONNABORTED ; -if (smc->clcsock && smc->clcsock->sk) +if (smc_sk_state (sk) !=SMC_INIT ) { +/* sock locked */ +if (smc_sock_is_inet_sock (sk)) { +smc_inet_sock_abort (sk); + }else if (smc->clcsock && smc->clcsock->sk) { + sk->sk_err =ECONNABORTED ;tcp_abort (smc->clcsock->sk,ECONNABORTED ); + } } +switch (smc_sk_state (sk)) {case SMC_ACTIVE :case SMC_APPCLOSEWAIT1 :
net/smc/smc_inet.c +175 -40
280 lines not on this page · raw message
net/smc/smc_inet.h +98 -0
120 lines not on this page · raw message
net/smc/smc_rx.c +3 -3
@@ -269,7 +269,7 @@ int smc_rx_wait(struct smc_sock *smc, long *timeo, rc =sk_wait_event (sk, timeo,READ_ONCE (sk->sk_err) || cflags->peer_conn_abort || -READ_ONCE (sk->sk_shutdown) &RCV_SHUTDOWN || +smc_has_rcv_shutdown (sk) || conn->killed ||fcrit (conn), &wait);
@@ -316,7 +316,7 @@ static int smc_rx_recv_urg(struct smc_sock *smc, struct msghdr *msg, int len,return rc ? -EFAULT : len; } -if (smc_sk_state (sk) ==SMC_CLOSED || sk->sk_shutdown &RCV_SHUTDOWN ) +if (smc_sk_state (sk) ==SMC_CLOSED ||smc_has_rcv_shutdown (sk))return 0 ;return -EAGAIN ;
@@ -387,7 +387,7 @@ int smc_rx_recvmsg(struct smc_sock *smc, struct msghdr *msg,if (smc_rx_recvmsg_data_available (smc)) goto copy; -if (sk->sk_shutdown &RCV_SHUTDOWN ) { +if (smc_has_rcv_shutdown (sk)) {/* smc_cdc_msg_recv_action() could have run after * above smc_rx_recvmsg_data_available() */
Signature · 1 line
1.8.3.1
kernel test robot
build botRe: [RFC net-next 19/20] net/smc: support smc inet with merge socks
kernel test robot noticed the following build warnings:
Hi Wythe,
[This is a private test report for your RFC patch.] kernel test robot noticed the following build warnings:
[auto build test WARNING on net-next/main]
url: https://github.com/intel-lab-lkp/linux/commits/D-Wythe/net-export-partial-symbols-in-inet-inet6-proto_ops/20240220-190529 base: net-next/main patch link: https://lore.kernel.org/r/1708412505-34470-20-git-send-email-alibuda%40linux.alibaba.com patch subject: [RFC net-next 19/20] net/smc: support smc inet with merge socks config: um-allyesconfig (https://download.01.org/0day-ci/archive/20240223/[email protected]/config) compiler: gcc-12 (Debian 12.2.0-14) 12.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240223/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
>> net/smc/af_smc.c:3911:14: warning: no previous prototype for '__smc_inet_csk_accept' [-Wmissing-prototypes]
3911 | struct sock *__smc_inet_csk_accept(struct sock *sk, int flags, int *err, bool kern, int next_state)
| ^~~~~~~~~~~~~~~~~~~~~
net/smc/af_smc.c: In function 'smc_inet_setsockopt':
net/smc/af_smc.c:4219:26: warning: variable 'smc' set but not used [-Wunused-but-set-variable]
4219 | struct smc_sock *smc;
| ^~~
net/smc/af_smc.c: In function 'smc_inet_release':
net/smc/af_smc.c:4434:13: warning: variable 'old_state' set but not used [-Wunused-but-set-variable]
4434 | int old_state, rc;
| ^~~~~~~~~--
net/smc/smc_inet.c:148:35: warning: initialized field overwritten [-Woverride-init]
148 | .per_cpu_fw_alloc = &tcp_memory_per_cpu_fw_alloc,
| ^
net/smc/smc_inet.c:148:35: note: (near initialization for 'smc_inet6_prot.per_cpu_fw_alloc')
>> net/smc/smc_inet.c:320:5: warning: no previous prototype for 'smc_sk_wait_tcp_data' [-Wmissing-prototypes]
320 | int smc_sk_wait_tcp_data(struct sock *sk, long *timeo, const struct sk_buff *skb)
| ^~~~~~~~~~~~~~~~~~~~
vim +/__smc_inet_csk_accept +3911 net/smc/af_smc.c
3910
> 3911 struct sock *__smc_inet_csk_accept(struct sock *sk, int flags, int *err, bool kern, int next_state)
3912 {
3913 struct sock *child;
3914 int cur;
3915
3916 child = inet_csk_accept(sk, flags | O_NONBLOCK, err, kern);
3917 if (child) {
3918 smc_sk(child)->listen_smc = smc_sk(sk);
3919
3920 /* depends on syn_smc if next_state not specify */
3921 if (next_state == SMC_NEGOTIATION_TBD)
3922 next_state = tcp_sk(child)->syn_smc ? SMC_NEGOTIATION_PREPARE_SMC :
3923 SMC_NEGOTIATION_NO_SMC;
3924
3925 cur = smc_inet_sock_move_state(child, SMC_NEGOTIATION_TBD,
3926 next_state);
3927 switch (cur) {
3928 case SMC_NEGOTIATION_NO_SMC:
3929 smc_sk_set_state(child, SMC_ACTIVE);
3930 smc_switch_to_fallback(smc_sk(child), SMC_CLC_DECL_PEERNOSMC);
3931 break;
3932 case SMC_NEGOTIATION_PREPARE_SMC:
3933 /* init as passive open smc sock */
3934 smc_sock_init_passive(sk, child);
3935 break;
3936 default:
3937 break;
3938 }
3939 }
3940 return child;
3941 }
3942
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botRe: [RFC net-next 19/20] net/smc: support smc inet with merge socks
In reply to D. Wythekernel test robot noticed the following build warnings:
Hi Wythe,
[This is a private test report for your RFC patch.] kernel test robot noticed the following build warnings:
[auto build test WARNING on net-next/main]
url: https://github.com/intel-lab-lkp/linux/commits/D-Wythe/net-export-partial-symbols-in-inet-inet6-proto_ops/20240220-190529 base: net-next/main patch link: https://lore.kernel.org/r/1708412505-34470-20-git-send-email-alibuda%40linux.alibaba.com patch subject: [RFC net-next 19/20] net/smc: support smc inet with merge socks config: s390-defconfig (https://download.01.org/0day-ci/archive/20240223/[email protected]/config) compiler: clang version 19.0.0git (https://github.com/llvm/llvm-project edd4aee4dd9b5b98b2576a6f783e4086173d902a) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240223/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
In file included from net/smc/af_smc.c:27:
In file included from include/linux/if_vlan.h:10:
In file included from include/linux/netdevice.h:38:
In file included from include/net/net_namespace.h:43:
In file included from include/linux/skbuff.h:28:
In file included from include/linux/dma-mapping.h:11:
In file included from include/linux/scatterlist.h:9:
In file included from arch/s390/include/asm/io.h:78:
include/asm-generic/io.h:547:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
547 | val = __raw_readb(PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:560:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
560 | val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
| ~~~~~~~~~~ ^
include/uapi/linux/byteorder/big_endian.h:37:59: note: expanded from macro '__le16_to_cpu'
37 | #define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
| ^
include/uapi/linux/swab.h:102:54: note: expanded from macro '__swab16'
102 | #define __swab16(x) (__u16)__builtin_bswap16((__u16)(x))
| ^
In file included from net/smc/af_smc.c:27:
In file included from include/linux/if_vlan.h:10:
In file included from include/linux/netdevice.h:38:
In file included from include/net/net_namespace.h:43:
In file included from include/linux/skbuff.h:28:
In file included from include/linux/dma-mapping.h:11:
In file included from include/linux/scatterlist.h:9:
In file included from arch/s390/include/asm/io.h:78:
include/asm-generic/io.h:573:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
573 | val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
| ~~~~~~~~~~ ^
include/uapi/linux/byteorder/big_endian.h:35:59: note: expanded from macro '__le32_to_cpu'
35 | #define __le32_to_cpu(x) __swab32((__force __u32)(__le32)(x))
| ^
include/uapi/linux/swab.h:115:54: note: expanded from macro '__swab32'
115 | #define __swab32(x) (__u32)__builtin_bswap32((__u32)(x))
| ^
In file included from net/smc/af_smc.c:27:
In file included from include/linux/if_vlan.h:10:
In file included from include/linux/netdevice.h:38:
In file included from include/net/net_namespace.h:43:
In file included from include/linux/skbuff.h:28:
In file included from include/linux/dma-mapping.h:11:
In file included from include/linux/scatterlist.h:9:
In file included from arch/s390/include/asm/io.h:78:
include/asm-generic/io.h:584:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
584 | __raw_writeb(value, PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:594:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
594 | __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:604:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
604 | __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:692:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
692 | readsb(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:700:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
700 | readsw(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:708:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
708 | readsl(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:717:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
717 | writesb(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:726:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
726 | writesw(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:735:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
735 | writesl(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
In file included from net/smc/af_smc.c:59:
>> net/smc/smc_inet.h:174:2: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough]
174 | default:
| ^
net/smc/smc_inet.h:174:2: note: insert 'break;' to avoid fall-through
174 | default:
| ^
| break;
>> net/smc/af_smc.c:3911:14: warning: no previous prototype for function '__smc_inet_csk_accept' [-Wmissing-prototypes]
3911 | struct sock *__smc_inet_csk_accept(struct sock *sk, int flags, int *err, bool kern, int next_state)
| ^
net/smc/af_smc.c:3911:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
3911 | struct sock *__smc_inet_csk_accept(struct sock *sk, int flags, int *err, bool kern, int next_state)
| ^
| static
>> net/smc/af_smc.c:4219:19: warning: variable 'smc' set but not used [-Wunused-but-set-variable]
4219 | struct smc_sock *smc;
| ^
>> net/smc/af_smc.c:4434:6: warning: variable 'old_state' set but not used [-Wunused-but-set-variable]
4434 | int old_state, rc;
| ^ 16 warnings generated.
--
In file included from net/smc/smc_close.c:15:
In file included from include/net/sock.h:46:
In file included from include/linux/netdevice.h:38:
In file included from include/net/net_namespace.h:43:
In file included from include/linux/skbuff.h:28:
In file included from include/linux/dma-mapping.h:11:
In file included from include/linux/scatterlist.h:9:
In file included from arch/s390/include/asm/io.h:78:
include/asm-generic/io.h:547:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
547 | val = __raw_readb(PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:560:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
560 | val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
| ~~~~~~~~~~ ^
include/uapi/linux/byteorder/big_endian.h:37:59: note: expanded from macro '__le16_to_cpu'
37 | #define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
| ^
include/uapi/linux/swab.h:102:54: note: expanded from macro '__swab16'
102 | #define __swab16(x) (__u16)__builtin_bswap16((__u16)(x))
| ^
In file included from net/smc/smc_close.c:15:
In file included from include/net/sock.h:46:
In file included from include/linux/netdevice.h:38:
In file included from include/net/net_namespace.h:43:
In file included from include/linux/skbuff.h:28:
In file included from include/linux/dma-mapping.h:11:
In file included from include/linux/scatterlist.h:9:
In file included from arch/s390/include/asm/io.h:78:
include/asm-generic/io.h:573:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
573 | val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
| ~~~~~~~~~~ ^
include/uapi/linux/byteorder/big_endian.h:35:59: note: expanded from macro '__le32_to_cpu'
35 | #define __le32_to_cpu(x) __swab32((__force __u32)(__le32)(x))
| ^
include/uapi/linux/swab.h:115:54: note: expanded from macro '__swab32'
115 | #define __swab32(x) (__u32)__builtin_bswap32((__u32)(x))
| ^
In file included from net/smc/smc_close.c:15:
In file included from include/net/sock.h:46:
In file included from include/linux/netdevice.h:38:
In file included from include/net/net_namespace.h:43:
In file included from include/linux/skbuff.h:28:
In file included from include/linux/dma-mapping.h:11:
In file included from include/linux/scatterlist.h:9:
In file included from arch/s390/include/asm/io.h:78:
include/asm-generic/io.h:584:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
584 | __raw_writeb(value, PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:594:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
594 | __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:604:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
604 | __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:692:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
692 | readsb(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:700:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
700 | readsw(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:708:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
708 | readsl(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:717:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
717 | writesb(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:726:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
726 | writesw(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:735:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
735 | writesl(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
In file included from net/smc/smc_close.c:22:
>> net/smc/smc_inet.h:174:2: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough]
174 | default:
| ^
net/smc/smc_inet.h:174:2: note: insert 'break;' to avoid fall-through
174 | default:
| ^
| break; 13 warnings generated.
--
In file included from net/smc/smc_inet.c:17:
In file included from include/net/sock.h:46:
In file included from include/linux/netdevice.h:38:
In file included from include/net/net_namespace.h:43:
In file included from include/linux/skbuff.h:28:
In file included from include/linux/dma-mapping.h:11:
In file included from include/linux/scatterlist.h:9:
In file included from arch/s390/include/asm/io.h:78:
include/asm-generic/io.h:547:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
547 | val = __raw_readb(PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:560:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
560 | val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
| ~~~~~~~~~~ ^
include/uapi/linux/byteorder/big_endian.h:37:59: note: expanded from macro '__le16_to_cpu'
37 | #define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
| ^
include/uapi/linux/swab.h:102:54: note: expanded from macro '__swab16'
102 | #define __swab16(x) (__u16)__builtin_bswap16((__u16)(x))
| ^
In file included from net/smc/smc_inet.c:17:
In file included from include/net/sock.h:46:
In file included from include/linux/netdevice.h:38:
In file included from include/net/net_namespace.h:43:
In file included from include/linux/skbuff.h:28:
In file included from include/linux/dma-mapping.h:11:
In file included from include/linux/scatterlist.h:9:
In file included from arch/s390/include/asm/io.h:78:
include/asm-generic/io.h:573:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
573 | val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
| ~~~~~~~~~~ ^
include/uapi/linux/byteorder/big_endian.h:35:59: note: expanded from macro '__le32_to_cpu'
35 | #define __le32_to_cpu(x) __swab32((__force __u32)(__le32)(x))
| ^
include/uapi/linux/swab.h:115:54: note: expanded from macro '__swab32'
115 | #define __swab32(x) (__u32)__builtin_bswap32((__u32)(x))
| ^
In file included from net/smc/smc_inet.c:17:
In file included from include/net/sock.h:46:
In file included from include/linux/netdevice.h:38:
In file included from include/net/net_namespace.h:43:
In file included from include/linux/skbuff.h:28:
In file included from include/linux/dma-mapping.h:11:
In file included from include/linux/scatterlist.h:9:
In file included from arch/s390/include/asm/io.h:78:
include/asm-generic/io.h:584:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
584 | __raw_writeb(value, PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:594:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
594 | __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:604:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
604 | __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:692:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
692 | readsb(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:700:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
700 | readsw(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:708:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
708 | readsl(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:717:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
717 | writesb(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:726:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
726 | writesw(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:735:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
735 | writesl(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
In file included from net/smc/smc_inet.c:20:
>> net/smc/smc_inet.h:174:2: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough]
174 | default:
| ^
net/smc/smc_inet.h:174:2: note: insert 'break;' to avoid fall-through
174 | default:
| ^
| break;
>> net/smc/smc_inet.c:320:5: warning: no previous prototype for function 'smc_sk_wait_tcp_data' [-Wmissing-prototypes]
320 | int smc_sk_wait_tcp_data(struct sock *sk, long *timeo, const struct sk_buff *skb)
| ^
net/smc/smc_inet.c:320:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
320 | int smc_sk_wait_tcp_data(struct sock *sk, long *timeo, const struct sk_buff *skb)
| ^
| static 14 warnings generated.
vim +174 net/smc/smc_inet.h
158
159 static inline int smc_inet_sock_try_disable_smc(struct sock *sk, int flag)
160 {
161 struct smc_sock *smc = smc_sk(sk);
162 int success = 0;
163
164 write_lock_bh(&sk->sk_callback_lock);
165 switch (isck_smc_negotiation_load(smc)) {
166 case SMC_NEGOTIATION_TBD:
167 /* can not disable now */
168 if (flag != SMC_NEGOTIATION_ABORT_FLAG && tcp_sk(sk)->syn_smc)
169 break;
170 isck_smc_negotiation_set_flags(smc_sk(sk), flag);
171 fallthrough;
172 case SMC_NEGOTIATION_NO_SMC:
173 success = 1;
> 174 default:
175 break;
176 }
177 write_unlock_bh(&sk->sk_callback_lock);
178 return success;
179 }
180
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
D. Wythe
maintainerRFC 20/20 net/smc: support diag for smc inet mode
In reply to D. WytheFrom: "D. Wythe" <[email protected]>
--- net/smc/smc_diag.c | 155 ++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 137 insertions(+), 18 deletions(-)
net/smc/smc_diag.c +137 -18
@@ -22,9 +22,11 @@#include "smc.h" #include "smc_core.h" #include "smc_ism.h" +#include "smc_inet.h" struct smc_diag_dump_ctx {int pos[2 ]; +int inet_pos[2 ]; };static struct smc_diag_dump_ctx *smc_dump_context (struct netlink_callback *cb)
@@ -35,24 +37,42 @@ static struct smc_diag_dump_ctx *smc_dump_context(struct netlink_callback *cb)static void smc_diag_msg_common_fill (struct smc_diag_msg *r,struct sock *sk) {struct smc_sock *smc =smc_sk (sk); +struct sock *clcsk; +bool is_v4, is_v6; + +if (smc_sock_is_inet_sock (sk)) + clcsk = sk; +else if (smc->clcsock) + clcsk = smc->clcsock->sk; +else +return ;memset (r,0 ,sizeof (*r)); r->diag_family = sk->sk_family;sock_diag_save_cookie (sk, r->id.idiag_cookie); -if (!smc->clcsock) -return ; - r->id.idiag_sport =htons (smc->clcsock->sk->sk_num); - r->id.idiag_dport = smc->clcsock->sk->sk_dport; - r->id.idiag_if = smc->clcsock->sk->sk_bound_dev_if; -if (sk->sk_protocol ==SMCPROTO_SMC ) { - r->id.idiag_src[0 ] = smc->clcsock->sk->sk_rcv_saddr; - r->id.idiag_dst[0 ] = smc->clcsock->sk->sk_daddr; + + r->id.idiag_sport =htons (clcsk->sk_num); + r->id.idiag_dport = clcsk->sk_dport; + r->id.idiag_if = clcsk->sk_bound_dev_if; + + is_v4 =smc_sock_is_inet_sock (sk) ? clcsk->sk_family ==AF_INET : + sk->sk_protocol ==SMCPROTO_SMC ;#if IS_ENABLED (CONFIG_IPV6 ) - } else if (sk->sk_protocol == SMCPROTO_SMC6) { -memcpy (&r->id.idiag_src, &smc->clcsock->sk->sk_v6_rcv_saddr, -sizeof (smc->clcsock->sk->sk_v6_rcv_saddr)); -memcpy (&r->id.idiag_dst, &smc->clcsock->sk->sk_v6_daddr, -sizeof (smc->clcsock->sk->sk_v6_daddr)); + is_v6 =smc_sock_is_inet_sock (sk) ? clcsk->sk_family ==AF_INET6 : + sk->sk_protocol ==SMCPROTO_SMC6 ; +#else + is_v6 = false; +#endif + +if (is_v4) { + r->id.idiag_src[0 ] = clcsk->sk_rcv_saddr; + r->id.idiag_dst[0 ] = clcsk->sk_daddr; +#if IS_ENABLED (CONFIG_IPV6 ) + } else if (is_v6) { +memcpy (&r->id.idiag_src, &clcsk->sk_v6_rcv_saddr, +sizeof (clcsk->sk_v6_rcv_saddr)); +memcpy (&r->id.idiag_dst, &clcsk->sk_v6_daddr, +sizeof (clcsk->sk_v6_daddr));#endif } }
@@ -72,7 +92,7 @@ static int smc_diag_msg_attrs_fill(struct sock *sk, struct sk_buff *skb,static int __smc_diag_dump (struct sock *sk,struct sk_buff *skb,struct netlink_callback *cb,const struct smc_diag_req *req, -struct nlattr *bc) +struct nlattr *bc,bool is_listen) {struct smc_sock *smc =smc_sk (sk);struct smc_diag_fallback fallback;
@@ -88,6 +108,12 @@ static int __smc_diag_dump(struct sock *sk, struct sk_buff *skb, r =nlmsg_data (nlh);smc_diag_msg_common_fill (r, sk); r->diag_state =smc_sk_state (sk); + +if (is_listen) + r->diag_state =SMC_LISTEN ; +else + r->diag_state =smc_sk_state (sk); +if (smc->use_fallback) r->diag_mode =SMC_DIAG_MODE_FALLBACK_TCP ;else if (smc_conn_lgr_valid (&smc->conn) && smc->conn.lgr->is_smcd)
@@ -193,6 +219,82 @@ static int __smc_diag_dump(struct sock *sk, struct sk_buff *skb,return -EMSGSIZE ; } +static int smc_diag_dump_inet_proto (struct inet_hashinfo *hashinfo,struct sk_buff *skb, +struct netlink_callback *cb,int p_type) +{ +struct smc_diag_dump_ctx *cb_ctx =smc_dump_context (cb); +struct net *net =sock_net (skb->sk); +int snum = cb_ctx->inet_pos[p_type]; +struct nlattr *bc =NULL ; +int rc =0 , num =0 , i; +struct proto *target_proto; +struct sock *sk; + +#if IS_ENABLED (CONFIG_IPV6 ) + target_proto = (p_type ==SMCPROTO_SMC6 ) ? &smc_inet6_prot : &smc_inet_prot; +#else + target_proto = &smc_inet_prot; +#endif + +for (i =0 ; i < hashinfo->lhash2_mask; i++) { +struct inet_listen_hashbucket *ilb; +struct hlist_nulls_node *node; + + ilb = &hashinfo->lhash2[i]; +spin_lock (&ilb->lock); +sk_nulls_for_each (sk, node, &ilb->nulls_head) { +if (!net_eq (sock_net (sk), net)) +continue ; +if (sk->sk_prot != target_proto) +continue ; +if (num < snum) + goto next_ls; + rc =__smc_diag_dump (sk, skb, cb,nlmsg_data (cb->nlh), bc,1 ); +if (rc <0 ) { +spin_unlock (&ilb->lock); + goto out; + } +next_ls: + num++; + } +spin_unlock (&ilb->lock); + } + +for (i =0 ; i <= hashinfo->ehash_mask; i++) { +struct inet_ehash_bucket *head = &hashinfo->ehash[i]; +spinlock_t *lock =inet_ehash_lockp (hashinfo, i); +struct hlist_nulls_node *node; + +if (hlist_nulls_empty (&head->chain)) +continue ; + +spin_lock_bh (lock); +sk_nulls_for_each (sk, node, &head->chain) { +if (!net_eq (sock_net (sk), net)) +continue ; +if (sk->sk_state ==TCP_TIME_WAIT ) +continue ; +if (sk->sk_state ==TCP_NEW_SYN_RECV ) +continue ; +if (sk->sk_prot != target_proto) +continue ; +if (num < snum) + goto next; + rc =__smc_diag_dump (sk, skb, cb,nlmsg_data (cb->nlh), bc,0 ); +if (rc <0 ) { +spin_unlock_bh (lock); + goto out; + } +next: + num++; + } +spin_unlock_bh (lock); + } +out: + cb_ctx->inet_pos[p_type] = num; +return rc; +} +static int smc_diag_dump_proto (struct proto *prot,struct sk_buff *skb,struct netlink_callback *cb,int p_type) {
@@ -214,7 +316,7 @@ static int smc_diag_dump_proto(struct proto *prot, struct sk_buff *skb,continue ;if (num < snum) goto next; - rc =__smc_diag_dump (sk, skb, cb,nlmsg_data (cb->nlh), bc); + rc =__smc_diag_dump (sk, skb, cb,nlmsg_data (cb->nlh), bc,0 );if (rc <0 ) goto out; next:
@@ -232,8 +334,26 @@ static int smc_diag_dump(struct sk_buff *skb, struct netlink_callback *cb)int rc =0 ; rc =smc_diag_dump_proto (&smc_proto, skb, cb,SMCPROTO_SMC ); -if (!rc) -smc_diag_dump_proto (&smc_proto6, skb, cb,SMCPROTO_SMC6 ); +if (rc) + goto out; + +#if IS_ENABLED (CONFIG_IPV6 ) + rc =smc_diag_dump_proto (&smc_proto6, skb, cb,SMCPROTO_SMC6 ); +if (rc) + goto out; +#endif + + rc =smc_diag_dump_inet_proto (smc_inet_prot.h.hashinfo, skb, cb,SMCPROTO_SMC ); +if (rc) + goto out; + +#if IS_ENABLED (CONFIG_IPV6 ) + rc =smc_diag_dump_inet_proto (smc_inet6_prot.h.hashinfo, skb, cb,SMCPROTO_SMC6 ); +if (rc) + goto out; +#endif +return 0 ; +out:return skb->len; }
@@ -273,6 +393,5 @@ static void __exit smc_diag_exit(void)module_init (smc_diag_init);module_exit (smc_diag_exit);MODULE_LICENSE ("GPL" ); -MODULE_DESCRIPTION ("SMC socket monitoring via SOCK_DIAG" );MODULE_ALIAS_NET_PF_PROTO_TYPE (PF_NETLINK ,NETLINK_SOCK_DIAG ,43 /* AF_SMC */ );MODULE_ALIAS_GENL_FAMILY (SMCR_GENL_FAMILY_NAME );
Signature · 1 line
1.8.3.1