diff mbox series

[mptcp-next,v6,01/13] mptcp: sysctl: use index for sysctl table

Message ID 3e40ffced396775b7e3056b6f0934c112d8e8513.1740320007.git.tanggeliang@kylinos.cn (mailing list archive)
State Superseded, archived
Delegated to: Matthieu Baerts
Headers show
Series BPF path manager, part 4 | expand

Checks

Context Check Description
matttbe/checkpatch success total: 0 errors, 0 warnings, 0 checks, 35 lines checked
matttbe/shellcheck success MPTCP selftests files have not been modified
matttbe/build success Build and static analysis OK
matttbe/KVM_Validation__normal success Success! ✅
matttbe/KVM_Validation__debug success Success! ✅
matttbe/KVM_Validation__btf-normal__only_bpftest_all_ success Success! ✅
matttbe/KVM_Validation__btf-debug__only_bpftest_all_ success Success! ✅

Commit Message

Geliang Tang Feb. 23, 2025, 2:19 p.m. UTC
From: Geliang Tang <tanggeliang@kylinos.cn>

The sysctl table needs to be updated when a new sysctl is added or an old
sysctl is deleted. It's inconvenient to use fixed index numbers, since the
index number that needs to be changed and all subsequent index numbers need
to be updated accordingly.

This patch adds an "i" variable to access each sysctl in the sysctl table
incrementally.

Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
---
 net/mptcp/ctrl.c | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)
diff mbox series

Patch

diff --git a/net/mptcp/ctrl.c b/net/mptcp/ctrl.c
index be6c0237e10b..030dbe46cc8a 100644
--- a/net/mptcp/ctrl.c
+++ b/net/mptcp/ctrl.c
@@ -259,6 +259,7 @@  static int mptcp_pernet_new_table(struct net *net, struct mptcp_pernet *pernet)
 {
 	struct ctl_table_header *hdr;
 	struct ctl_table *table;
+	int i = 0;
 
 	table = mptcp_sysctl_table;
 	if (!net_eq(net, &init_net)) {
@@ -267,17 +268,17 @@  static int mptcp_pernet_new_table(struct net *net, struct mptcp_pernet *pernet)
 			goto err_alloc;
 	}
 
-	table[0].data = &pernet->mptcp_enabled;
-	table[1].data = &pernet->add_addr_timeout;
-	table[2].data = &pernet->checksum_enabled;
-	table[3].data = &pernet->allow_join_initial_addr_port;
-	table[4].data = &pernet->stale_loss_cnt;
-	table[5].data = &pernet->pm_type;
-	table[6].data = &pernet->scheduler;
-	/* table[7] is for available_schedulers which is read-only info */
-	table[8].data = &pernet->close_timeout;
-	table[9].data = &pernet->blackhole_timeout;
-	table[10].data = &pernet->syn_retrans_before_tcp_fallback;
+	table[i++].data = &pernet->mptcp_enabled;
+	table[i++].data = &pernet->add_addr_timeout;
+	table[i++].data = &pernet->checksum_enabled;
+	table[i++].data = &pernet->allow_join_initial_addr_port;
+	table[i++].data = &pernet->stale_loss_cnt;
+	table[i++].data = &pernet->pm_type;
+	table[i++].data = &pernet->scheduler;
+	i++; /* table[i] is for available_schedulers which is read-only info */
+	table[i++].data = &pernet->close_timeout;
+	table[i++].data = &pernet->blackhole_timeout;
+	table[i++].data = &pernet->syn_retrans_before_tcp_fallback;
 
 	hdr = register_net_sysctl_sz(net, MPTCP_SYSCTL_PATH, table,
 				     ARRAY_SIZE(mptcp_sysctl_table));