Skip to content

Commit 883ca83

Browse files
Gerrit Renkerdavem330
authored andcommitted
dccp: Initialisation and type-checking of feature sysctls
This patch takes care of initialising and type-checking sysctls related to feature negotiation. Type checking is important since some of the sysctls now directly impact the feature-negotiation process. The sysctls are initialised with the known default values for each feature. For the type-checking the value constraints from RFC 4340 are used: * Sequence Window uses the specified Wmin=32, the maximum is ulong (4 bytes), tested and confirmed that it works up to 4294967295 - for Gbps speed; * Ack Ratio is between 0 .. 0xffff (2-byte unsigned integer); * CCIDs are between 0 .. 255; * request_retries, retries1, retries2 also between 0..255 for good measure; * tx_qlen is checked to be non-negative; * sync_ratelimit remains as before. Notes: ------ 1. Die s@sysctl_dccp_feat@sysctl_dccp@g since the sysctls are now in feat.c. 2. As pointed out by Arnaldo, the pattern of type-checking repeats itself in other places, sometimes with exactly the same kind of definitions (e.g. "static int zero;"). It may be a good idea (kernel janitors?) to consolidate type checking. For the sake of keeping the changeset small and in order not to affect other subsystems, I have not strived to generalise here. Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk> Acked-by: Ian McDonald <ian.mcdonald@jandi.co.nz> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 792b487 commit 883ca83

6 files changed

Lines changed: 46 additions & 31 deletions

File tree

‎include/linux/dccp.h‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -355,14 +355,6 @@ static inline unsigned int dccp_hdr_len(const struct sk_buff *skb)
355355
return __dccp_hdr_len(dccp_hdr(skb));
356356
}
357357

358-
359-
/* initial values for each feature */
360-
#define DCCPF_INITIAL_SEQUENCE_WINDOW 100
361-
#define DCCPF_INITIAL_ACK_RATIO 2
362-
#define DCCPF_INITIAL_CCID DCCPC_CCID2
363-
/* FIXME: for now we're default to 1 but it should really be 0 */
364-
#define DCCPF_INITIAL_SEND_NDP_COUNT 1
365-
366358
/**
367359
* struct dccp_request_sock - represent DCCP-specific connection request
368360
* @dreq_inet_rsk: structure inherited from

‎net/dccp/dccp.h‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,6 @@ extern void dccp_time_wait(struct sock *sk, int state, int timeo);
9595
extern int sysctl_dccp_request_retries;
9696
extern int sysctl_dccp_retries1;
9797
extern int sysctl_dccp_retries2;
98-
extern int sysctl_dccp_feat_sequence_window;
99-
extern int sysctl_dccp_feat_rx_ccid;
100-
extern int sysctl_dccp_feat_tx_ccid;
10198
extern int sysctl_dccp_tx_qlen;
10299
extern int sysctl_dccp_sync_ratelimit;
103100

‎net/dccp/feat.c‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@
2525
#include "ccid.h"
2626
#include "feat.h"
2727

28+
/* feature-specific sysctls - initialised to the defaults from RFC 4340, 6.4 */
29+
unsigned long sysctl_dccp_sequence_window __read_mostly = 100;
30+
int sysctl_dccp_rx_ccid __read_mostly = 2,
31+
sysctl_dccp_tx_ccid __read_mostly = 2;
32+
2833
/*
2934
* Feature activation handlers.
3035
*
@@ -1146,7 +1151,7 @@ int dccp_feat_init(struct sock *sk)
11461151

11471152
/* Non-negotiable (NN) features */
11481153
rc = __feat_register_nn(fn, DCCPF_SEQUENCE_WINDOW, 0,
1149-
sysctl_dccp_feat_sequence_window);
1154+
sysctl_dccp_sequence_window);
11501155
if (rc)
11511156
return rc;
11521157

@@ -1172,8 +1177,8 @@ int dccp_feat_init(struct sock *sk)
11721177
ccid_get_builtin_ccids(&rx.val, &rx.len))
11731178
return -ENOBUFS;
11741179

1175-
if (!dccp_feat_prefer(sysctl_dccp_feat_tx_ccid, tx.val, tx.len) ||
1176-
!dccp_feat_prefer(sysctl_dccp_feat_rx_ccid, rx.val, rx.len))
1180+
if (!dccp_feat_prefer(sysctl_dccp_tx_ccid, tx.val, tx.len) ||
1181+
!dccp_feat_prefer(sysctl_dccp_rx_ccid, rx.val, rx.len))
11771182
goto free_ccid_lists;
11781183

11791184
rc = __feat_register_sp(fn, DCCPF_CCID, true, false, tx.val, tx.len);

‎net/dccp/feat.h‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,13 @@ struct ccid_dependency {
100100
u8 val;
101101
};
102102

103+
/*
104+
* Sysctls to seed defaults for feature negotiation
105+
*/
106+
extern unsigned long sysctl_dccp_sequence_window;
107+
extern int sysctl_dccp_rx_ccid;
108+
extern int sysctl_dccp_tx_ccid;
109+
103110
#ifdef CONFIG_IP_DCCP_DEBUG
104111
extern const char *dccp_feat_typename(const u8 type);
105112
extern const char *dccp_feat_name(const u8 feat);
@@ -114,6 +121,7 @@ static inline void dccp_feat_debug(const u8 type, const u8 feat, const u8 val)
114121
#endif /* CONFIG_IP_DCCP_DEBUG */
115122

116123
extern int dccp_feat_init(struct sock *sk);
124+
extern void dccp_feat_initialise_sysctls(void);
117125
extern int dccp_feat_register_sp(struct sock *sk, u8 feat, u8 is_local,
118126
u8 const *list, u8 len);
119127
extern int dccp_feat_register_nn(struct sock *sk, u8 feat, u64 val);

‎net/dccp/options.c‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@
2323
#include "dccp.h"
2424
#include "feat.h"
2525

26-
int sysctl_dccp_feat_sequence_window = DCCPF_INITIAL_SEQUENCE_WINDOW;
27-
int sysctl_dccp_feat_rx_ccid = DCCPF_INITIAL_CCID;
28-
int sysctl_dccp_feat_tx_ccid = DCCPF_INITIAL_CCID;
29-
3026
u64 dccp_decode_value_var(const u8 *bf, const u8 len)
3127
{
3228
u64 value = 0;

‎net/dccp/sysctl.c‎

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,55 +18,72 @@
1818
#error This file should not be compiled without CONFIG_SYSCTL defined
1919
#endif
2020

21+
/* Boundary values */
22+
static int zero = 0,
23+
u8_max = 0xFF;
24+
static unsigned long seqw_min = 32;
25+
2126
static struct ctl_table dccp_default_table[] = {
2227
{
2328
.procname = "seq_window",
24-
.data = &sysctl_dccp_feat_sequence_window,
25-
.maxlen = sizeof(sysctl_dccp_feat_sequence_window),
29+
.data = &sysctl_dccp_sequence_window,
30+
.maxlen = sizeof(sysctl_dccp_sequence_window),
2631
.mode = 0644,
27-
.proc_handler = proc_dointvec,
32+
.proc_handler = proc_doulongvec_minmax,
33+
.extra1 = &seqw_min, /* RFC 4340, 7.5.2 */
2834
},
2935
{
3036
.procname = "rx_ccid",
31-
.data = &sysctl_dccp_feat_rx_ccid,
32-
.maxlen = sizeof(sysctl_dccp_feat_rx_ccid),
37+
.data = &sysctl_dccp_rx_ccid,
38+
.maxlen = sizeof(sysctl_dccp_rx_ccid),
3339
.mode = 0644,
34-
.proc_handler = proc_dointvec,
40+
.proc_handler = proc_dointvec_minmax,
41+
.extra1 = &zero,
42+
.extra2 = &u8_max, /* RFC 4340, 10. */
3543
},
3644
{
3745
.procname = "tx_ccid",
38-
.data = &sysctl_dccp_feat_tx_ccid,
39-
.maxlen = sizeof(sysctl_dccp_feat_tx_ccid),
46+
.data = &sysctl_dccp_tx_ccid,
47+
.maxlen = sizeof(sysctl_dccp_tx_ccid),
4048
.mode = 0644,
41-
.proc_handler = proc_dointvec,
49+
.proc_handler = proc_dointvec_minmax,
50+
.extra1 = &zero,
51+
.extra2 = &u8_max, /* RFC 4340, 10. */
4252
},
4353
{
4454
.procname = "request_retries",
4555
.data = &sysctl_dccp_request_retries,
4656
.maxlen = sizeof(sysctl_dccp_request_retries),
4757
.mode = 0644,
48-
.proc_handler = proc_dointvec,
58+
.proc_handler = proc_dointvec_minmax,
59+
.extra1 = &zero,
60+
.extra2 = &u8_max,
4961
},
5062
{
5163
.procname = "retries1",
5264
.data = &sysctl_dccp_retries1,
5365
.maxlen = sizeof(sysctl_dccp_retries1),
5466
.mode = 0644,
55-
.proc_handler = proc_dointvec,
67+
.proc_handler = proc_dointvec_minmax,
68+
.extra1 = &zero,
69+
.extra2 = &u8_max,
5670
},
5771
{
5872
.procname = "retries2",
5973
.data = &sysctl_dccp_retries2,
6074
.maxlen = sizeof(sysctl_dccp_retries2),
6175
.mode = 0644,
62-
.proc_handler = proc_dointvec,
76+
.proc_handler = proc_dointvec_minmax,
77+
.extra1 = &zero,
78+
.extra2 = &u8_max,
6379
},
6480
{
6581
.procname = "tx_qlen",
6682
.data = &sysctl_dccp_tx_qlen,
6783
.maxlen = sizeof(sysctl_dccp_tx_qlen),
6884
.mode = 0644,
69-
.proc_handler = proc_dointvec,
85+
.proc_handler = proc_dointvec_minmax,
86+
.extra1 = &zero,
7087
},
7188
{
7289
.procname = "sync_ratelimit",

0 commit comments

Comments
 (0)