Skip to contentSkip to conversation

feat: Introduce sysctls for the default features

PATCH In review Arnaldo Carvalho de Melo 1 participant 1 message Feb 22, 2006

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 4/4 feat: Introduce sysctls for the default features

[root@qemu ~]# for a in /proc/sys/net/dccp/default/* ; do echo $a ; cat $a ; done /proc/sys/net/dccp/default/ack_ratio
2
/proc/sys/net/dccp/default/rx_ccid
3
/proc/sys/net/dccp/default/send_ackvec
1
/proc/sys/net/dccp/default/send_ndp
1
/proc/sys/net/dccp/default/seq_window
100
/proc/sys/net/dccp/default/tx_ccid
3
[root@qemu ~]#

So if wanting to test ccid3 as the tx CCID one can just do:

[root@qemu ~]# echo 3 > /proc/sys/net/dccp/default/tx_ccid [root@qemu ~]# echo 2 > /proc/sys/net/dccp/default/rx_ccid [root@qemu ~]# cat /proc/sys/net/dccp/default/[tr]x_ccid 2
3
[root@qemu ~]#

Of course we also need the setsockopt for each app to tell its preferences, but for testing or defining something other than CCID2 as the default for apps that don't explicitely set their preference the sysctl interface is handy.

---

 include/linux/sysctl.h |   16 ++++++
 net/dccp/Makefile      |    2 +
 net/dccp/dccp.h        |   14 +++++
 net/dccp/options.c     |   22 +++++----
 net/dccp/proto.c       |    9 +++
 net/dccp/sysctl.c      |  124 ++++++++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 176 insertions(+), 11 deletions(-)
 create mode 100644 net/dccp/sysctl.c

df0bb8f0450110107ef4c4dc641b3e626e750565

include/linux/sysctl.h +16 -0
index 42ebee8..195e936 100644
@@ -209,6 +209,7 @@ enum
 	NET_SCTP,
 	NET_LLC,
 	NET_NETFILTER,
+	NET_DCCP ,
 };
 
 /* /proc/sys/kernel/random */
@@ -569,6 +570,21 @@ enum {
 	__NET_NEIGH_MAX
 };
 
+/* /proc/sys/net/dccp */
+enum {
+	NET_DCCP_DEFAULT=1,
+};
+
+/* /proc/sys/net/dccp/default */
+enum {
+	NET_DCCP_DEFAULT_SEQ_WINDOW  = 1,
+	NET_DCCP_DEFAULT_RX_CCID     = 2,
+	NET_DCCP_DEFAULT_TX_CCID     = 3,
+	NET_DCCP_DEFAULT_ACK_RATIO   = 4,
+	NET_DCCP_DEFAULT_SEND_ACKVEC = 5,
+	NET_DCCP_DEFAULT_SEND_NDP    = 6,
+};
+
 /* /proc/sys/net/ipx */
 enum {
 	NET_IPX_PPROP_BROADCASTING=1,
net/dccp/Makefile +2 -0
index 5736ace..7af0569 100644
@@ -11,6 +11,8 @@ dccp-$(CONFIG_IP_DCCP_ACKVEC) += ackvec.
 
 obj-$(CONFIG_INET_DCCP_DIAG) += dccp_diag.o
 
+dccp-$(CONFIG_SYSCTL) += sysctl.o
+
 dccp_diag-y := diag.o
 
 obj-y += ccids/
net/dccp/dccp.h +14 -0
index 1764adb..f059541 100644
@@ -433,4 +433,18 @@ static inline void timeval_sub_usecs(str
 	}
 }
 
+#ifdef CONFIG_SYSCTL
+extern int dccp_sysctl_init(void);
+extern void dccp_sysctl_exit(void);
+#else
+static inline int dccp_sysctl_init(void)
+{
+	return 0;
+}
+
+static inline void dccp_sysctl_exit(void)
+{
+}
+#endif
+
 #endif /* _DCCP_H */
net/dccp/options.c +12 -10
index 7d73b33..3ecd319 100644
@@ -23,19 +23,21 @@
 #include "dccp.h"
 #include "feat.h"
 
-/* stores the default values for new connection. may be changed with sysctl */
-static const struct dccp_options dccpo_default_values = {
-	.dccpo_sequence_window	  = DCCPF_INITIAL_SEQUENCE_WINDOW,
-	.dccpo_rx_ccid		  = DCCPF_INITIAL_CCID,
-	.dccpo_tx_ccid		  = DCCPF_INITIAL_CCID,
-	.dccpo_ack_ratio	  = DCCPF_INITIAL_ACK_RATIO,
-	.dccpo_send_ack_vector	  = DCCPF_INITIAL_SEND_ACK_VECTOR,
-	.dccpo_send_ndp_count	  = DCCPF_INITIAL_SEND_NDP_COUNT,
-};
+int dccp_feat_default_sequence_window = DCCPF_INITIAL_SEQUENCE_WINDOW;
+int dccp_feat_default_rx_ccid	      = DCCPF_INITIAL_CCID;
+int dccp_feat_default_tx_ccid	      = DCCPF_INITIAL_CCID;
+int dccp_feat_default_ack_ratio	      = DCCPF_INITIAL_ACK_RATIO;
+int dccp_feat_default_send_ack_vector = DCCPF_INITIAL_SEND_ACK_VECTOR;
+int dccp_feat_default_send_ndp_count  = DCCPF_INITIAL_SEND_NDP_COUNT;
 
 void dccp_options_init(struct dccp_options *dccpo)
 {
-	memcpy(dccpo, &dccpo_default_values, sizeof(*dccpo));
+	dccpo->dccpo_sequence_window = dccp_feat_default_sequence_window;
+	dccpo->dccpo_rx_ccid	     = dccp_feat_default_rx_ccid;
+	dccpo->dccpo_tx_ccid	     = dccp_feat_default_tx_ccid;
+	dccpo->dccpo_ack_ratio	     = dccp_feat_default_ack_ratio;
+	dccpo->dccpo_send_ack_vector = dccp_feat_default_send_ack_vector;
+	dccpo->dccpo_send_ndp_count  = dccp_feat_default_send_ndp_count;
 }
 
 static u32 dccp_decode_value_var(const unsigned char *bf, const u8 len)
net/dccp/proto.c +8 -1
index 1e9fdf6..04315c3 100644
@@ -934,11 +934,17 @@ static int __init dccp_init(void)
 	if (rc)
 		goto out_unregister_protosw;
 
-	rc = dccp_ctl_sock_init();
+	rc = dccp_sysctl_init();
 	if (rc)
 		goto out_ackvec_exit;
+
+	rc = dccp_ctl_sock_init();
+	if (rc)
+		goto out_sysctl_exit;
 out:
 	return rc;
+out_sysctl_exit:
+	dccp_sysctl_exit();
 out_ackvec_exit:
 	dccp_ackvec_exit();
 out_unregister_protosw:
@@ -983,6 +989,7 @@ static void __exit dccp_fini(void)
 	kmem_cache_destroy(dccp_hashinfo.bind_bucket_cachep);
 	proto_unregister(&dccp_prot);
 	dccp_ackvec_exit();
+	dccp_sysctl_exit();
 }
 
 module_init(dccp_init);
net/dccp/sysctl.c new file +124 -0

124 lines not on this page · raw message

Signature · 1 line
1.1.GIT