Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net/smc: add sysctl interface for SMC

This patch add sysctl interface to support container environment
for SMC as we talk in the mail list.

Link: https://lore.kernel.org/netdev/20220224020253.GF5443@linux.alibaba.com
Co-developed-by: Tony Lu <tonylu@linux.alibaba.com>
Signed-off-by: Tony Lu <tonylu@linux.alibaba.com>
Signed-off-by: Dust Li <dust.li@linux.alibaba.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Dust Li and committed by
David S. Miller
462791bb 1e385c08

+116 -1
+3
include/net/netns/smc.h
··· 14 14 struct smc_stats_rsn *fback_rsn; 15 15 16 16 bool limit_smc_hs; /* constraint on handshake */ 17 + #ifdef CONFIG_SYSCTL 18 + struct ctl_table_header *smc_hdr; 19 + #endif 17 20 }; 18 21 #endif
+1 -1
net/smc/Makefile
··· 4 4 obj-$(CONFIG_SMC_DIAG) += smc_diag.o 5 5 smc-y := af_smc.o smc_pnet.o smc_ib.o smc_clc.o smc_core.o smc_wr.o smc_llc.o 6 6 smc-y += smc_cdc.o smc_tx.o smc_rx.o smc_close.o smc_ism.o smc_netlink.o smc_stats.o 7 - smc-y += smc_tracepoint.o 7 + smc-y += smc_tracepoint.o smc_sysctl.o
+10
net/smc/af_smc.c
··· 51 51 #include "smc_close.h" 52 52 #include "smc_stats.h" 53 53 #include "smc_tracepoint.h" 54 + #include "smc_sysctl.h" 54 55 55 56 static DEFINE_MUTEX(smc_server_lgr_pending); /* serialize link group 56 57 * creation on server ··· 3274 3273 goto out_sock; 3275 3274 } 3276 3275 3276 + rc = smc_sysctl_init(); 3277 + if (rc) { 3278 + pr_err("%s: sysctl_init fails with %d\n", __func__, rc); 3279 + goto out_ulp; 3280 + } 3281 + 3277 3282 static_branch_enable(&tcp_have_smc); 3278 3283 return 0; 3279 3284 3285 + out_ulp: 3286 + tcp_unregister_ulp(&smc_ulp_ops); 3280 3287 out_sock: 3281 3288 sock_unregister(PF_SMC); 3282 3289 out_proto6: ··· 3312 3303 static void __exit smc_exit(void) 3313 3304 { 3314 3305 static_branch_disable(&tcp_have_smc); 3306 + smc_sysctl_exit(); 3315 3307 tcp_unregister_ulp(&smc_ulp_ops); 3316 3308 sock_unregister(PF_SMC); 3317 3309 smc_core_exit();
+70
net/smc/smc_sysctl.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * Shared Memory Communications over RDMA (SMC-R) and RoCE 4 + * 5 + * smc_sysctl.c: sysctl interface to SMC subsystem. 6 + * 7 + * Copyright (c) 2022, Alibaba Inc. 8 + * 9 + * Author: Tony Lu <tonylu@linux.alibaba.com> 10 + * 11 + */ 12 + 13 + #include <linux/init.h> 14 + #include <linux/sysctl.h> 15 + #include <net/net_namespace.h> 16 + 17 + #include "smc_sysctl.h" 18 + 19 + static struct ctl_table smc_table[] = { 20 + { } 21 + }; 22 + 23 + static __net_init int smc_sysctl_init_net(struct net *net) 24 + { 25 + struct ctl_table *table; 26 + 27 + table = smc_table; 28 + if (!net_eq(net, &init_net)) { 29 + int i; 30 + 31 + table = kmemdup(table, sizeof(smc_table), GFP_KERNEL); 32 + if (!table) 33 + goto err_alloc; 34 + 35 + for (i = 0; i < ARRAY_SIZE(smc_table) - 1; i++) 36 + table[i].data += (void *)net - (void *)&init_net; 37 + } 38 + 39 + net->smc.smc_hdr = register_net_sysctl(net, "net/smc", table); 40 + if (!net->smc.smc_hdr) 41 + goto err_reg; 42 + 43 + return 0; 44 + 45 + err_reg: 46 + if (!net_eq(net, &init_net)) 47 + kfree(table); 48 + err_alloc: 49 + return -ENOMEM; 50 + } 51 + 52 + static __net_exit void smc_sysctl_exit_net(struct net *net) 53 + { 54 + unregister_net_sysctl_table(net->smc.smc_hdr); 55 + } 56 + 57 + static struct pernet_operations smc_sysctl_ops __net_initdata = { 58 + .init = smc_sysctl_init_net, 59 + .exit = smc_sysctl_exit_net, 60 + }; 61 + 62 + int __init smc_sysctl_init(void) 63 + { 64 + return register_pernet_subsys(&smc_sysctl_ops); 65 + } 66 + 67 + void smc_sysctl_exit(void) 68 + { 69 + unregister_pernet_subsys(&smc_sysctl_ops); 70 + }
+32
net/smc/smc_sysctl.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + /* 3 + * Shared Memory Communications over RDMA (SMC-R) and RoCE 4 + * 5 + * smc_sysctl.c: sysctl interface to SMC subsystem. 6 + * 7 + * Copyright (c) 2022, Alibaba Inc. 8 + * 9 + * Author: Tony Lu <tonylu@linux.alibaba.com> 10 + * 11 + */ 12 + 13 + #ifndef _SMC_SYSCTL_H 14 + #define _SMC_SYSCTL_H 15 + 16 + #ifdef CONFIG_SYSCTL 17 + 18 + int smc_sysctl_init(void); 19 + void smc_sysctl_exit(void); 20 + 21 + #else 22 + 23 + int smc_sysctl_init(void) 24 + { 25 + return 0; 26 + } 27 + 28 + void smc_sysctl_exit(void) { } 29 + 30 + #endif /* CONFIG_SYSCTL */ 31 + 32 + #endif /* _SMC_SYSCTL_H */