net/smc: add SMC rendezvous protocol
RFC 1/1 net/smc: add SMC rendezvous protocol
The SMC protocol [1] uses a rendezvous protocol to negotiate SMC capability between peers. The current Linux implementation does not use this rendezvous protocol and, thus, is not compliant to RFC7609 and incompatible with other SMC implementations like in zOS. This patch adds support for the SMC rendezvous protocol.
Details:
The SMC rendezvous protocol relies on the use of a new TCP experimental option. With this option, SMC capabilities are exchanged between the peers during the TCP three way handshake.
The goal of this patch is to leave common TCP code unmodified. Thus, it uses netfilter hooks to intercept TCP SYN and SYN/ACK packets. For outgoing packets originating from SMC sockets, the experimental option is added. For inbound packets destined for SMC sockets, the experimental option is checked.
Another goal was to minimize the performance impact on non-SMC traffic (when SMC is enabled). The netfilter hooks used for SMC client connections are active only during TCP connection establishment. The netfilter hooks used for SMC servers are active as long as there are listening SMC sockets.
When the hooks are active, the following additional operations are performed on incoming and outgoing packets:
(1) call SMC netfilter hook (all IPv4 packets)
(2) check if TCP SYN or SYN/ACK packet (all IPv4 packets)
(3) check if packet goes to/comes from SMC socket (SYN & SYN/ACK packets only)
(4) check/add SMC experimental option (SMC sockets' SYN & SYN/ACK packets only)
References:
[1] SMC-R Informational RFC: http://www.rfc-editor.org/info/rfc7609
--- net/smc/Makefile | 2 +- net/smc/af_smc.c | 66 ++++++- net/smc/smc.h | 10 +- net/smc/smc_rv.c | 542 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ net/smc/smc_rv.h | 31 ++++ 5 files changed, 644 insertions(+), 7 deletions(-) create mode 100644 net/smc/smc_rv.c create mode 100644 net/smc/smc_rv.h
net/smc/Makefile +1 -1
@@ -1,4 +1,4 @@ obj-$(CONFIG_SMC) += smc.o 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-y += smc_cdc.o smc_tx.o smc_rx.o smc_close.o smc_rv.o
net/smc/af_smc.c +61 -5
182 lines not on this page · raw message
net/smc/smc.h +9 -1
@@ -167,6 +167,13 @@ struct smc_connection {struct work_struct close_work;/* peer sent some closing */ }; +struct smc_listen_pending { +u64 time;/* time when entry was created*/ +bool used;/* true if entry is in use */ +__be32 addr;/* address of a listen socket */ +__be16 port;/* port of a listen socket */ +}; +struct smc_sock {/* smc sock container */ struct sock sk;struct socket *clcsock;/* internal tcp socket */
@@ -175,6 +182,8 @@ struct smc_sock { /* smc sock container */struct smc_sock *listen_smc;/* listen parent */ struct work_struct tcp_listen_work;/* handle tcp socket accepts */ struct work_struct smc_listen_work;/* prepare new accept socket */ +struct smc_listen_pending *listen_pends;/* listen pending SYNs */ +spinlock_t listen_pends_lock;/* protects listen_pends */ struct list_head accept_q;/* sockets to be accepted */ spinlock_t accept_q_lock;/* protects accept_q */ struct delayed_work sock_put_work;/* final socket freeing */
@@ -271,5 +280,4 @@ int smc_conn_create(struct smc_sock *smc, __be32 peer_in_addr, struct smc_clc_msg_local *lcl, int srv_first_contact);struct sock *smc_accept_dequeue (struct sock *parent,struct socket *new_sock);void smc_close_non_accepted (struct sock *sk); -#endif /* __SMC_H */
net/smc/smc_rv.c new file +542 -0
542 lines not on this page · raw message
net/smc/smc_rv.h new file +31 -0
@@ -0,0 +1,31 @@ +/* +* Shared Memory Communications over RDMA (SMC-R) and RoCE +* +* Definitions for SMC Rendezvous - SMC capability checking +* +* Copyright IBM Corp. 2017 +* +* Author(s): Hans Wippel <[email protected]> +* Ursula Braun <[email protected]> +*/ + +#ifndef _SMC_RV_H +#define _SMC_RV_H + +#include <linux/netfilter.h> + +#define SMC_LISTEN_PEND_VALID_TIME (600 * HZ) + +struct smc_nf_hook { +struct mutex nf_hook_mutex;/* serialize nf register ops */ +int refcount; +struct nf_hook_ops *hook; +}; + +extern struct smc_nf_hook smc_nfho_clnt; +extern struct smc_nf_hook smc_nfho_serv; + +int smc_rv_nf_register_hook (struct net *net,struct smc_nf_hook *nfho); +void smc_rv_nf_unregister_hook (struct net *net,struct smc_nf_hook *nfho); +void smc_rv_init (void )__init ; +#endif
Signature · 1 line
2.13.5