Browse code

sctp: fix cfg.set_delayed* setting some config options immediately

- all the runtime cfg options that involve setting socket options
are now set using a per-child cfg callback with
CFG_CB_ONLY_ONCE and not in the value fixup function. This fixes
cfg.set_delayed* (up until now it did set these options
immediately and not after cfg.commit).
- init_max_timeo valid range fixed (from 0-1024 to 0-2^30).

Andrei Pelinescu-Onciul authored on 30/11/2009 11:02:37
Showing 1 changed files
... ...
@@ -50,22 +50,34 @@ struct cfg_group_sctp sctp_default_cfg;
50 50
 
51 51
 #include "sctp_sockopts.h"
52 52
 
53
-static int set_autoclose(void* cfg_h, str* gname, str* name, void** val);
54
-static int set_assoc_tracking(void* cfg_h, str* gname, str* name, void** val);
55
-static int set_assoc_reuse(void* cfg_h, str* gname, str* name, void** val);
56
-static int set_srto_initial(void* cfg_h, str* gname, str* name, void** val);
57
-static int set_srto_max(void* cfg_h, str* gname, str* name, void** val);
58
-static int set_srto_min(void* cfg_h, str* gname, str* name, void** val);
59
-static int set_asocmaxrxt(void* cfg_h, str* gname, str* name, void** val);
60
-static int set_sinit_max_attempts(void* cfg_h, str* gname, str* name,
53
+static int fix_autoclose(void* cfg_h, str* gname, str* name, void** val);
54
+static void set_autoclose(str* gname, str* name);
55
+static int fix_assoc_tracking(void* cfg_h, str* gname, str* name, void** val);
56
+static int fix_assoc_reuse(void* cfg_h, str* gname, str* name, void** val);
57
+static int fix_srto_initial(void* cfg_h, str* gname, str* name, void** val);
58
+static void set_srto_initial(str* gname, str* name);
59
+static int fix_srto_max(void* cfg_h, str* gname, str* name, void** val);
60
+static void set_srto_max(str* gname, str* name);
61
+static int fix_srto_min(void* cfg_h, str* gname, str* name, void** val);
62
+static void set_srto_min(str* gname, str* name);
63
+static int fix_asocmaxrxt(void* cfg_h, str* gname, str* name, void** val);
64
+static void set_asocmaxrxt(str* gname, str* name);
65
+static int fix_sinit_max_init_timeo(void* cfg_h, str* gname, str* name,
61 66
 										void** val);
62
-static int set_sinit_max_init_timeo(void* cfg_h, str* gname, str* name,
67
+static void set_sinit_max_init_timeo(str* gname, str* name);
68
+static int fix_sinit_max_attempts(void* cfg_h, str* gname, str* name,
63 69
 										void** val);
64
-static int set_hbinterval(void* cfg_h, str* gname, str* name, void** val);
65
-static int set_pathmaxrxt(void* cfg_h, str* gname, str* name, void** val);
66
-static int set_sack_freq(void* cfg_h, str* gname, str* name, void** val);
67
-static int set_sack_delay(void* cfg_h, str* gname, str* name, void** val);
68
-static int set_max_burst(void* cfg_h, str* gname, str* name, void** val);
70
+static void set_sinit_max_attempts(str* gname, str* name);
71
+static int fix_hbinterval(void* cfg_h, str* gname, str* name, void** val);
72
+static void set_hbinterval(str* gname, str* name);
73
+static int fix_pathmaxrxt(void* cfg_h, str* gname, str* name, void** val);
74
+static void set_pathmaxrxt(str* gname, str* name);
75
+static int fix_sack_delay(void* cfg_h, str* gname, str* name, void** val);
76
+static void set_sack_delay(str* gname, str* name);
77
+static int fix_sack_freq(void* cfg_h, str* gname, str* name, void** val);
78
+static void set_sack_freq(str* gname, str* name);
79
+static int fix_max_burst(void* cfg_h, str* gname, str* name, void** val);
80
+static void set_max_burst(str* gname, str* name);
69 81
 
70 82
 /** cfg_group_sctp description (for the config framework). */
71 83
 static cfg_def_t sctp_cfg_def[] = {
... ...
@@ -75,43 +87,53 @@ static cfg_def_t sctp_cfg_def[] = {
75 75
 		"socket receive buffer size (read-only)" },
76 76
 	{ "socket_sndbuf", CFG_VAR_INT| CFG_READONLY, 512, 102400, 0, 0,
77 77
 		"socket send buffer size (read-only)" },
78
-	{ "autoclose", CFG_VAR_INT| CFG_ATOMIC, 1, 1<<30, set_autoclose, 0,
78
+	{ "autoclose", CFG_VAR_INT| CFG_CB_ONLY_ONCE, 1, 1<<30,
79
+		fix_autoclose, set_autoclose,
79 80
 		"seconds before closing and idle connection (must be non-zero)" },
80 81
 	{ "send_ttl", CFG_VAR_INT| CFG_ATOMIC, 0, 1<<30, 0, 0,
81 82
 		"milliseconds before aborting a send" },
82 83
 	{ "send_retries", CFG_VAR_INT| CFG_ATOMIC, 0, MAX_SCTP_SEND_RETRIES, 0, 0,
83 84
 		"re-send attempts on failure" },
84
-	{ "assoc_tracking", CFG_VAR_INT| CFG_ATOMIC, 0, 1, set_assoc_tracking, 0,
85
+	{ "assoc_tracking", CFG_VAR_INT| CFG_ATOMIC, 0, 1, fix_assoc_tracking, 0,
85 86
 		"connection/association tracking (see also assoc_reuse)" },
86
-	{ "assoc_reuse", CFG_VAR_INT| CFG_ATOMIC, 0, 1, set_assoc_reuse, 0,
87
+	{ "assoc_reuse", CFG_VAR_INT| CFG_ATOMIC, 0, 1, fix_assoc_reuse, 0,
87 88
 		"connection/association reuse (for now used only for replies)"
88 89
 		", depends on assoc_tracking being set"},
89 90
 	{ "max_assocs", CFG_VAR_INT| CFG_ATOMIC, 0, 0, 0, 0,
90 91
 		"maximum allowed open associations (-1 = disable, "
91 92
 			"as many as allowed by the OS)"},
92
-	{ "srto_initial", CFG_VAR_INT| CFG_ATOMIC, 0, 1<<30, set_srto_initial, 0,
93
+	{ "srto_initial", CFG_VAR_INT| CFG_CB_ONLY_ONCE, 0, 1<<30,
94
+		fix_srto_initial, set_srto_initial,
93 95
 		"initial value of the retr. timeout, used in RTO calculations,"
94 96
 			" in msecs" },
95
-	{ "srto_max", CFG_VAR_INT| CFG_ATOMIC, 0, 1<<30, set_srto_max, 0,
97
+	{ "srto_max", CFG_VAR_INT| CFG_CB_ONLY_ONCE, 0, 1<<30,
98
+		fix_srto_max, set_srto_max,
96 99
 		"maximum value of the retransmission timeout (RTO), in msecs" },
97
-	{ "srto_min", CFG_VAR_INT| CFG_ATOMIC, 0, 1<<30, set_srto_min, 0,
100
+	{ "srto_min", CFG_VAR_INT| CFG_CB_ONLY_ONCE, 0, 1<<30,
101
+		fix_srto_min, set_srto_min,
98 102
 		"minimum value of the retransmission timeout (RTO), in msecs" },
99
-	{ "asocmaxrxt", CFG_VAR_INT| CFG_ATOMIC, 0, 1<<10, set_asocmaxrxt, 0,
103
+	{ "asocmaxrxt", CFG_VAR_INT| CFG_CB_ONLY_ONCE, 0, 1<<10,
104
+		fix_asocmaxrxt, set_asocmaxrxt,
100 105
 		"maximum retransmission attempts per association" },
101
-	{ "init_max_attempts", CFG_VAR_INT| CFG_ATOMIC, 0, 1<<10,
102
-		set_sinit_max_attempts, 0, "max INIT retransmission attempts" },
103
-	{ "init_max_timeo", CFG_VAR_INT| CFG_ATOMIC, 0, 1<<10,
104
-		set_sinit_max_init_timeo, 0,
106
+	{ "init_max_attempts", CFG_VAR_INT| CFG_CB_ONLY_ONCE, 0, 1<<10,
107
+		fix_sinit_max_attempts, set_sinit_max_attempts,
108
+		"max INIT retransmission attempts" },
109
+	{ "init_max_timeo", CFG_VAR_INT| CFG_CB_ONLY_ONCE, 0, 1<<30,
110
+		fix_sinit_max_init_timeo, set_sinit_max_init_timeo,
105 111
 		"max INIT retransmission timeout (RTO max for INIT), in msecs" },
106
-	{ "hbinterval", CFG_VAR_INT| CFG_ATOMIC, 0, 0, set_hbinterval, 0,
107
-		"heartbeat interval in msecs" },
108
-	{ "pathmaxrxt", CFG_VAR_INT| CFG_ATOMIC, 0, 1<<10, set_pathmaxrxt, 0,
112
+	{ "hbinterval", CFG_VAR_INT| CFG_CB_ONLY_ONCE, 0, 1<<30,
113
+		fix_hbinterval, set_hbinterval, "heartbeat interval in msecs" },
114
+	{ "pathmaxrxt", CFG_VAR_INT| CFG_CB_ONLY_ONCE, 0, 1<<10,
115
+		fix_pathmaxrxt, set_pathmaxrxt,
109 116
 		"maximum retransmission attempts per path" },
110
-	{ "sack_delay", CFG_VAR_INT| CFG_ATOMIC, 0, 1<<30, set_sack_delay, 0,
117
+	{ "sack_delay", CFG_VAR_INT| CFG_CB_ONLY_ONCE, 0, 1<<30,
118
+		fix_sack_delay, set_sack_delay,
111 119
 		"time since the last received packet before sending a SACK, in msecs"},
112
-	{ "sack_freq", CFG_VAR_INT| CFG_ATOMIC, 0, 1<<10, set_sack_freq, 0,
120
+	{ "sack_freq", CFG_VAR_INT| CFG_CB_ONLY_ONCE, 0, 1<<10,
121
+		fix_sack_freq, set_sack_freq,
113 122
 		"number of received packets that trigger the sending of a SACK"},
114
-	{ "max_burst", CFG_VAR_INT| CFG_ATOMIC, 0, 1<<10, set_max_burst, 0,
123
+	{ "max_burst", CFG_VAR_INT| CFG_CB_ONLY_ONCE, 0, 1<<10,
124
+		fix_max_burst, set_max_burst,
115 125
 		"maximum burst of packets that can be emitted by an association"},
116 126
 	{0, 0, 0, 0, 0, 0, 0}
117 127
 };
... ...
@@ -232,25 +254,34 @@ int sctp_register_cfg()
232 232
 	return -(err!=0)
233 233
 
234 234
 
235
+static int fix_autoclose(void*cfg_h, str* gname, str* name, void** val)
236
+{
237
+#ifdef SCTP_AUTOCLOSE
238
+	return 0;
239
+#else
240
+	ERR("no SCTP_AUTOCLOSE support, please upgrade your sctp library\n");
241
+	return -1;
242
+#endif /* SCTP_AUTOCLOSE */
243
+}
244
+
235 245
 
236
-static int set_autoclose(void* cfg_h, str* gname, str* name, void** val)
246
+static void set_autoclose(str* gname, str* name)
237 247
 {
238 248
 #ifdef SCTP_AUTOCLOSE
239 249
 	int optval;
240 250
 	SCTP_SET_SOCKOPT_DECLS;
241 251
 	
242
-	optval=(int)(long)(*val);
243
-	SCTP_SET_SOCKOPT_BODY(IPPROTO_SCTP, SCTP_AUTOCLOSE, optval,
244
-							"cfg: setting SCTP_AUTOCLOSE");
252
+	optval=cfg_get(sctp, sctp_cfg, autoclose);
253
+	SCTP_SET_SOCKOPT_BODY_NRET(IPPROTO_SCTP, SCTP_AUTOCLOSE, optval,
254
+								"cfg: setting SCTP_AUTOCLOSE");
245 255
 #else
246 256
 	ERR("no SCTP_AUTOCLOSE support, please upgrade your sctp library\n");
247
-	return -1;
248 257
 #endif /* SCTP_AUTOCLOSE */
249 258
 }
250 259
 
251 260
 
252 261
 
253
-static int set_assoc_tracking(void* cfg_h, str* gname, str* name, void** val)
262
+static int fix_assoc_tracking(void* cfg_h, str* gname, str* name, void** val)
254 263
 {
255 264
 	int optval;
256 265
 	
... ...
@@ -281,7 +312,7 @@ static int set_assoc_tracking(void* cfg_h, str* gname, str* name, void** val)
281 281
 
282 282
 
283 283
 
284
-static int set_assoc_reuse(void* cfg_h, str* gname, str* name, void** val)
284
+static int fix_assoc_reuse(void* cfg_h, str* gname, str* name, void** val)
285 285
 {
286 286
 	int optval;
287 287
 	
... ...
@@ -304,21 +335,13 @@ static int set_assoc_reuse(void* cfg_h, str* gname, str* name, void** val)
304 304
 
305 305
 
306 306
 
307
-static int set_srto_initial(void* cfg_h, str* gname, str* name, void** val)
307
+static int fix_srto_initial(void* cfg_h, str* gname, str* name, void** val)
308 308
 {
309 309
 #ifdef SCTP_RTOINFO
310
-	struct sctp_rtoinfo rto;
311
-	SCTP_SET_SOCKOPT_DECLS;
312
-	
313 310
 	if ((int)(long)(*val)==0){ /* do nothing for 0, keep the old value */
314 311
 		*val=(void*)(long)cfg_get(sctp, cfg_h, srto_initial);
315
-		return 0;
316 312
 	}
317
-	memset(&rto, 0, sizeof(rto)); /* zero everything we don't care about */
318
-	rto.srto_assoc_id=0; /* all */
319
-	rto.srto_initial=(int)(long)(*val);
320
-	SCTP_SET_SOCKOPT_BODY(IPPROTO_SCTP, SCTP_RTOINFO, rto,
321
-							"cfg: setting SCTP_RTOINFO");
313
+	return 0;
322 314
 #else
323 315
 	ERR("no SCTP_RTOINFO support, please upgrade your sctp library\n");
324 316
 	return -1;
... ...
@@ -326,22 +349,33 @@ static int set_srto_initial(void* cfg_h, str* gname, str* name, void** val)
326 326
 }
327 327
 
328 328
 
329
-
330
-static int set_srto_max(void* cfg_h, str* gname, str* name, void** val)
329
+static void set_srto_initial(str* gname, str* name)
331 330
 {
332 331
 #ifdef SCTP_RTOINFO
333 332
 	struct sctp_rtoinfo rto;
333
+	int optval;
334 334
 	SCTP_SET_SOCKOPT_DECLS;
335 335
 	
336
+	optval=cfg_get(sctp, sctp_cfg, srto_initial);
337
+	memset(&rto, 0, sizeof(rto)); /* zero everything we don't care about */
338
+	rto.srto_assoc_id=0; /* all */
339
+	rto.srto_initial=optval;
340
+	SCTP_SET_SOCKOPT_BODY_NRET(IPPROTO_SCTP, SCTP_RTOINFO, rto,
341
+								"cfg: setting SCTP_RTOINFO");
342
+#else
343
+	ERR("no SCTP_RTOINFO support, please upgrade your sctp library\n");
344
+#endif /* SCTP_RTOINFO */
345
+}
346
+
347
+
348
+
349
+static int fix_srto_max(void* cfg_h, str* gname, str* name, void** val)
350
+{
351
+#ifdef SCTP_RTOINFO
336 352
 	if ((int)(long)(*val)==0){ /* do nothing for 0, keep the old value */
337 353
 		*val=(void*)(long)cfg_get(sctp, cfg_h, srto_max);
338
-		return 0;
339 354
 	}
340
-	memset(&rto, 0, sizeof(rto)); /* zero everything we don't care about */
341
-	rto.srto_assoc_id=0; /* all */
342
-	rto.srto_max=(int)(long)(*val);
343
-	SCTP_SET_SOCKOPT_BODY(IPPROTO_SCTP, SCTP_RTOINFO, rto,
344
-							"cfg: setting SCTP_RTOINFO");
355
+	return 0;
345 356
 #else
346 357
 	ERR("no SCTP_RTOINFO support, please upgrade your sctp library\n");
347 358
 	return -1;
... ...
@@ -349,68 +383,96 @@ static int set_srto_max(void* cfg_h, str* gname, str* name, void** val)
349 349
 }
350 350
 
351 351
 
352
-
353
-static int set_srto_min(void* cfg_h, str* gname, str* name, void** val)
352
+static void set_srto_max(str* gname, str* name)
354 353
 {
355 354
 #ifdef SCTP_RTOINFO
356 355
 	struct sctp_rtoinfo rto;
357 356
 	SCTP_SET_SOCKOPT_DECLS;
358 357
 	
358
+	memset(&rto, 0, sizeof(rto)); /* zero everything we don't care about */
359
+	rto.srto_assoc_id=0; /* all */
360
+	rto.srto_max=cfg_get(sctp, sctp_cfg, srto_max);
361
+	SCTP_SET_SOCKOPT_BODY_NRET(IPPROTO_SCTP, SCTP_RTOINFO, rto,
362
+								"cfg: setting SCTP_RTOINFO");
363
+#else
364
+	ERR("no SCTP_RTOINFO support, please upgrade your sctp library\n");
365
+#endif /* SCTP_RTOINFO */
366
+}
367
+
368
+
369
+
370
+static int fix_srto_min(void* cfg_h, str* gname, str* name, void** val)
371
+{
372
+#ifdef SCTP_RTOINFO
359 373
 	if ((int)(long)(*val)==0){ /* do nothing for 0, keep the old value */
360 374
 		*val=(void*)(long)cfg_get(sctp, cfg_h, srto_min);
361
-		return 0;
362 375
 	}
376
+	return 0;
377
+#else
378
+	ERR("no SCTP_RTOINFO support, please upgrade your sctp library\n");
379
+	return -1;
380
+#endif /* SCTP_RTOINFO */
381
+}
382
+
383
+
384
+static void set_srto_min(str* gname, str* name)
385
+{
386
+#ifdef SCTP_RTOINFO
387
+	struct sctp_rtoinfo rto;
388
+	SCTP_SET_SOCKOPT_DECLS;
389
+	
363 390
 	memset(&rto, 0, sizeof(rto)); /* zero everything we don't care about */
364 391
 	rto.srto_assoc_id=0; /* all */
365
-	rto.srto_min=(int)(long)(*val);
366
-	SCTP_SET_SOCKOPT_BODY(IPPROTO_SCTP, SCTP_RTOINFO, rto,
367
-							"cfg: setting SCTP_RTOINFO");
392
+	rto.srto_min=cfg_get(sctp, sctp_cfg, srto_min);
393
+	SCTP_SET_SOCKOPT_BODY_NRET(IPPROTO_SCTP, SCTP_RTOINFO, rto,
394
+								"cfg: setting SCTP_RTOINFO");
368 395
 #else
369 396
 	ERR("no SCTP_RTOINFO support, please upgrade your sctp library\n");
370
-	return -1;
371 397
 #endif /* SCTP_RTOINFO */
372 398
 }
373 399
 
374 400
 
375 401
 
376
-static int set_asocmaxrxt(void* cfg_h, str* gname, str* name, void** val)
402
+static int fix_asocmaxrxt(void* cfg_h, str* gname, str* name, void** val)
377 403
 {
378 404
 #ifdef SCTP_ASSOCINFO
379
-	struct sctp_assocparams ap;
380
-	SCTP_SET_SOCKOPT_DECLS;
381
-	
382 405
 	if ((int)(long)(*val)==0){ /* do nothing for 0, keep the old value */
383 406
 		*val=(void*)(long)cfg_get(sctp, cfg_h, asocmaxrxt);
384
-		return 0;
385 407
 	}
408
+	return 0;
409
+#else
410
+	ERR("no SCTP_ASSOCINFO support, please upgrade your sctp library\n");
411
+	return -1;
412
+#endif /* SCTP_ASSOCINFO */
413
+}
414
+
415
+
416
+static void set_asocmaxrxt(str* gname, str* name)
417
+{
418
+#ifdef SCTP_ASSOCINFO
419
+	struct sctp_assocparams ap;
420
+	SCTP_SET_SOCKOPT_DECLS;
421
+	
386 422
 	memset(&ap, 0, sizeof(ap)); /* zero everything we don't care about */
387 423
 	ap.sasoc_assoc_id=0; /* all */
388
-	ap.sasoc_asocmaxrxt=(int)(long)(*val);
389
-	SCTP_SET_SOCKOPT_BODY(IPPROTO_SCTP, SCTP_ASSOCINFO, ap,
390
-							"cfg: setting SCTP_ASSOCINFO");
424
+	ap.sasoc_asocmaxrxt= cfg_get(sctp, sctp_cfg, asocmaxrxt);
425
+	SCTP_SET_SOCKOPT_BODY_NRET(IPPROTO_SCTP, SCTP_ASSOCINFO, ap,
426
+								"cfg: setting SCTP_ASSOCINFO");
391 427
 #else
392 428
 	ERR("no SCTP_ASSOCINFO support, please upgrade your sctp library\n");
393
-	return -1;
394 429
 #endif /* SCTP_ASSOCINFO */
395 430
 }
396 431
 
397 432
 
398 433
 
399
-static int set_sinit_max_init_timeo(void* cfg_h, str* gname, str* name,
434
+static int fix_sinit_max_init_timeo(void* cfg_h, str* gname, str* name,
400 435
 									void** val)
401 436
 {
402 437
 #ifdef SCTP_INITMSG
403
-	struct sctp_initmsg im;
404
-	SCTP_SET_SOCKOPT_DECLS;
405
-	
406 438
 	if ((int)(long)(*val)==0){ /* do nothing for 0, keep the old value */
407 439
 		*val=(void*)(long)cfg_get(sctp, cfg_h, init_max_timeo);
408
-		return 0;
409 440
 	}
410
-	memset(&im, 0, sizeof(im)); /* zero everything we don't care about */
411
-	im.sinit_max_init_timeo=(int)(long)(*val);
412
-	SCTP_SET_SOCKOPT_BODY(IPPROTO_SCTP, SCTP_INITMSG, im,
413
-							"cfg: setting SCTP_INITMSG");
441
+	return 0;
414 442
 #else
415 443
 	ERR("no SCTP_INITMSG support, please upgrade your sctp library\n");
416 444
 	return -1;
... ...
@@ -418,22 +480,31 @@ static int set_sinit_max_init_timeo(void* cfg_h, str* gname, str* name,
418 418
 }
419 419
 
420 420
 
421
-
422
-static int set_sinit_max_attempts(void* cfg_h, str* gname, str* name,
423
-									void** val)
421
+static void set_sinit_max_init_timeo(str* gname, str* name)
424 422
 {
425 423
 #ifdef SCTP_INITMSG
426 424
 	struct sctp_initmsg im;
427 425
 	SCTP_SET_SOCKOPT_DECLS;
428 426
 	
427
+	memset(&im, 0, sizeof(im)); /* zero everything we don't care about */
428
+	im.sinit_max_init_timeo=cfg_get(sctp, sctp_cfg, init_max_timeo);
429
+	SCTP_SET_SOCKOPT_BODY_NRET(IPPROTO_SCTP, SCTP_INITMSG, im,
430
+								"cfg: setting SCTP_INITMSG");
431
+#else
432
+	ERR("no SCTP_INITMSG support, please upgrade your sctp library\n");
433
+#endif /* SCTP_INITMSG */
434
+}
435
+
436
+
437
+
438
+static int fix_sinit_max_attempts(void* cfg_h, str* gname, str* name,
439
+									void** val)
440
+{
441
+#ifdef SCTP_INITMSG
429 442
 	if ((int)(long)(*val)==0){ /* do nothing for 0, keep the old value */
430 443
 		*val=(void*)(long)cfg_get(sctp, cfg_h, init_max_attempts);
431
-		return 0;
432 444
 	}
433
-	memset(&im, 0, sizeof(im)); /* zero everything we don't care about */
434
-	im.sinit_max_attempts=(int)(long)(*val);
435
-	SCTP_SET_SOCKOPT_BODY(IPPROTO_SCTP, SCTP_INITMSG, im,
436
-							"cfg: setting SCTP_INITMSG");
445
+	return 0;
437 446
 #else
438 447
 	ERR("no SCTP_INITMSG support, please upgrade your sctp library\n");
439 448
 	return -1;
... ...
@@ -441,21 +512,50 @@ static int set_sinit_max_attempts(void* cfg_h, str* gname, str* name,
441 441
 }
442 442
 
443 443
 
444
+static void set_sinit_max_attempts(str* gname, str* name)
445
+{
446
+#ifdef SCTP_INITMSG
447
+	struct sctp_initmsg im;
448
+	SCTP_SET_SOCKOPT_DECLS;
449
+	
450
+	memset(&im, 0, sizeof(im)); /* zero everything we don't care about */
451
+	im.sinit_max_attempts=cfg_get(sctp, sctp_cfg, init_max_attempts);
452
+	SCTP_SET_SOCKOPT_BODY_NRET(IPPROTO_SCTP, SCTP_INITMSG, im,
453
+								"cfg: setting SCTP_INITMSG");
454
+#else
455
+	ERR("no SCTP_INITMSG support, please upgrade your sctp library\n");
456
+#endif /* SCTP_INITMSG */
457
+}
444 458
 
445
-static int set_hbinterval(void* cfg_h, str* gname, str* name,
459
+
460
+
461
+static int fix_hbinterval(void* cfg_h, str* gname, str* name,
446 462
 									void** val)
447 463
 {
448 464
 #ifdef SCTP_PEER_ADDR_PARAMS
449
-	struct sctp_paddrparams pp;
450
-	SCTP_SET_SOCKOPT_DECLS;
451
-	
452 465
 	if ((int)(long)(*val)==0){ /* do nothing for 0, keep the old value */
453 466
 		*val=(void*)(long)cfg_get(sctp, cfg_h, hbinterval);
454
-		return 0;
455 467
 	}
468
+	return 0;
469
+#else
470
+	ERR("no SCTP_PEER_ADDR_PARAMS support, please upgrade your"
471
+			" sctp library\n");
472
+	return -1;
473
+#endif /* SCTP_PEER_ADDR_PARAMS */
474
+}
475
+
476
+
477
+static void set_hbinterval(str* gname, str* name)
478
+{
479
+#ifdef SCTP_PEER_ADDR_PARAMS
480
+	struct sctp_paddrparams pp;
481
+	int optval;
482
+	SCTP_SET_SOCKOPT_DECLS;
483
+	
484
+	optval=cfg_get(sctp, sctp_cfg, hbinterval);
456 485
 	memset(&pp, 0, sizeof(pp)); /* zero everything we don't care about */
457
-	if ((int)(long)(*val)!=-1){
458
-		pp.spp_hbinterval=(int)(long)(*val);
486
+	if (optval!=-1){
487
+		pp.spp_hbinterval=optval;
459 488
 		pp.spp_flags=SPP_HB_ENABLE;
460 489
 	}else{
461 490
 		pp.spp_flags=SPP_HB_DISABLE;
... ...
@@ -468,29 +568,38 @@ static int set_hbinterval(void* cfg_h, str* gname, str* name,
468 468
 								(void*)(&pp), sizeof(pp),
469 469
 								"cfg: setting SCTP_PEER_ADDR_PARAMS")<0);
470 470
 	}
471
-	return -(err!=0);
472 471
 #else
473 472
 	ERR("no SCTP_PEER_ADDR_PARAMS support, please upgrade your"
474 473
 			" sctp library\n");
475
-	return -1;
476 474
 #endif /* SCTP_PEER_ADDR_PARAMS */
477 475
 }
478 476
 
479 477
 
480 478
 
481
-static int set_pathmaxrxt(void* cfg_h, str* gname, str* name,
479
+static int fix_pathmaxrxt(void* cfg_h, str* gname, str* name,
482 480
 									void** val)
483 481
 {
484 482
 #ifdef SCTP_PEER_ADDR_PARAMS
485
-	struct sctp_paddrparams pp;
486
-	SCTP_SET_SOCKOPT_DECLS;
487
-	
488 483
 	if ((int)(long)(*val)==0){ /* do nothing for 0, keep the old value */
489 484
 		*val=(void*)(long)cfg_get(sctp, cfg_h, pathmaxrxt);
490
-		return 0;
491 485
 	}
486
+	return 0;
487
+#else
488
+	ERR("no SCTP_PEER_ADDR_PARAMS support, please upgrade your"
489
+			" sctp library\n");
490
+	return -1;
491
+#endif /* SCTP_PEER_ADDR_PARAMS */
492
+}
493
+
494
+
495
+static void set_pathmaxrxt(str* gname, str* name)
496
+{
497
+#ifdef SCTP_PEER_ADDR_PARAMS
498
+	struct sctp_paddrparams pp;
499
+	SCTP_SET_SOCKOPT_DECLS;
500
+	
492 501
 	memset(&pp, 0, sizeof(pp)); /* zero everything we don't care about */
493
-	pp.spp_pathmaxrxt=(int)(long)(*val);
502
+	pp.spp_pathmaxrxt=cfg_get(sctp, sctp_cfg, pathmaxrxt);
494 503
 	err=0;
495 504
 	for (si=sctp_listen; si; si=si->next){
496 505
 		/* set the AF, needed on older linux kernels even for INADDR_ANY */
... ...
@@ -499,17 +608,29 @@ static int set_pathmaxrxt(void* cfg_h, str* gname, str* name,
499 499
 								(void*)(&pp), sizeof(pp),
500 500
 								"cfg: setting SCTP_PEER_ADDR_PARAMS")<0);
501 501
 	}
502
-	return -(err!=0);
503 502
 #else
504 503
 	ERR("no SCTP_PEER_ADDR_PARAMS support, please upgrade your"
505 504
 			" sctp library\n");
506
-	return -1;
507 505
 #endif /* SCTP_PEER_ADDR_PARAMS */
508 506
 }
509 507
 
510 508
 
511 509
 
512
-static int set_sack_delay(void* cfg_h, str* gname, str* name, void** val)
510
+static int fix_sack_delay(void* cfg_h, str* gname, str* name, void** val)
511
+{
512
+#if defined SCTP_DELAYED_SACK || defined SCTP_DELAYED_ACK_TIME
513
+	if ((int)(long)(*val)==0){ /* do nothing for 0, keep the old value */
514
+		*val=(void*)(long)cfg_get(sctp, cfg_h, sack_delay);
515
+	}
516
+	return 0;
517
+#else
518
+	ERR("no SCTP_DELAYED_SACK support, please upgrade your sctp library\n");
519
+	return -1;
520
+#endif /* SCTP_DELAYED_SACK | SCTP_DELAYED_ACK_TIME */
521
+}
522
+
523
+
524
+static void set_sack_delay(str* gname, str* name)
513 525
 {
514 526
 #if defined SCTP_DELAYED_SACK || defined SCTP_DELAYED_ACK_TIME
515 527
 #ifdef SCTP_DELAYED_SACK
... ...
@@ -520,17 +641,13 @@ static int set_sack_delay(void* cfg_h, str* gname, str* name, void** val)
520 520
 #endif /* SCTP_DELAYED_ACK_TIME */
521 521
 	SCTP_SET_SOCKOPT_DECLS;
522 522
 	
523
-	if ((int)(long)(*val)==0){ /* do nothing for 0, keep the old value */
524
-		*val=(void*)(long)cfg_get(sctp, cfg_h, sack_delay);
525
-		return 0;
526
-	}
527 523
 #ifdef SCTP_DELAYED_SACK
528 524
 	memset(&sack_info, 0, sizeof(sack_info)); /* zero everything we don't
529 525
 												 care about */
530
-	sack_info.sack_delay=(int)(long)(*val);
526
+	sack_info.sack_delay=cfg_get(sctp, sctp_cfg, sack_delay);
531 527
 	SCTP_SET_SOCKOPT_BODY_NRET(IPPROTO_SCTP, SCTP_DELAYED_SACK, sack_info, 0);
532 528
 	if (err==0){
533
-		return 0;
529
+		return;
534 530
 	}else
535 531
 #endif /* SCTP_DELAYED_SACK */
536 532
 	{
... ...
@@ -539,39 +656,33 @@ static int set_sack_delay(void* cfg_h, str* gname, str* name, void** val)
539 539
 #ifdef	SCTP_DELAYED_ACK_TIME
540 540
 		memset(&sack_val, 0, sizeof(sack_val)); /* zero everything we don't
541 541
 												   care about */
542
-		sack_val.assoc_value=(int)(long)(*val);
543
-		SCTP_SET_SOCKOPT_BODY(IPPROTO_SCTP, SCTP_DELAYED_ACK_TIME, sack_val,
544
-								"cfg: setting SCTP_DELAYED_ACK_TIME");
542
+		sack_val.assoc_value=cfg_get(sctp, sctp_cfg, sack_delay);
543
+		SCTP_SET_SOCKOPT_BODY_NRET(IPPROTO_SCTP, SCTP_DELAYED_ACK_TIME,
544
+									sack_val,
545
+									"cfg: setting SCTP_DELAYED_ACK_TIME");
546
+		if (err==0)
547
+			return;
545 548
 #else	/* SCTP_DELAYED_ACK_TIME */
546 549
 		/* no SCTP_DELAYED_ACK_TIME support and SCTP_DELAYED_SACK failed
547 550
 		   => error */
548 551
 		ERR("cfg: setting SCTP_DELAYED_SACK: %s [%d]\n",
549 552
 					strerror(errno), errno);
550
-		return -1;
551 553
 #endif /* SCTP_DELAYED_ACK_TIME */
552 554
 	}
553 555
 #else
554 556
 	ERR("no SCTP_DELAYED_SACK support, please upgrade your sctp library\n");
555
-	return -1;
556 557
 #endif /* SCTP_DELAYED_SACK | SCTP_DELAYED_ACK_TIME */
557 558
 }
558 559
 
559 560
 
560 561
 
561
-static int set_sack_freq(void* cfg_h, str* gname, str* name, void** val)
562
+static int fix_sack_freq(void* cfg_h, str* gname, str* name, void** val)
562 563
 {
563 564
 #ifdef SCTP_DELAYED_SACK
564
-	struct sctp_sack_info sa;
565
-	SCTP_SET_SOCKOPT_DECLS;
566
-	
567 565
 	if ((int)(long)(*val)==0){ /* do nothing for 0, keep the old value */
568 566
 		*val=(void*)(long)cfg_get(sctp, cfg_h, sack_freq);
569
-		return 0;
570 567
 	}
571
-	memset(&sa, 0, sizeof(sa)); /* zero everything we don't care about */
572
-	sa.sack_freq=(int)(long)(*val);
573
-	SCTP_SET_SOCKOPT_BODY(IPPROTO_SCTP, SCTP_DELAYED_SACK, sa,
574
-							"cfg: setting SCTP_DELAYED_SACK");
568
+	return 0;
575 569
 #else
576 570
 	ERR("no SCTP_DELAYED_SACK support, please upgrade your sctp library\n");
577 571
 	return -1;
... ...
@@ -579,25 +690,50 @@ static int set_sack_freq(void* cfg_h, str* gname, str* name, void** val)
579 579
 }
580 580
 
581 581
 
582
-
583
-static int set_max_burst(void* cfg_h, str* gname, str* name, void** val)
582
+static void set_sack_freq(str* gname, str* name)
584 583
 {
585
-#ifdef SCTP_MAX_BURST
586
-	struct sctp_assoc_value av;
584
+#ifdef SCTP_DELAYED_SACK
585
+	struct sctp_sack_info sa;
587 586
 	SCTP_SET_SOCKOPT_DECLS;
588 587
 	
588
+	memset(&sa, 0, sizeof(sa)); /* zero everything we don't care about */
589
+	sa.sack_freq=cfg_get(sctp, sctp_cfg, sack_freq);
590
+	SCTP_SET_SOCKOPT_BODY_NRET(IPPROTO_SCTP, SCTP_DELAYED_SACK, sa,
591
+								"cfg: setting SCTP_DELAYED_SACK");
592
+#else
593
+	ERR("no SCTP_DELAYED_SACK support, please upgrade your sctp library\n");
594
+#endif /* SCTP_DELAYED_SACK */
595
+}
596
+
597
+
598
+
599
+static int fix_max_burst(void* cfg_h, str* gname, str* name, void** val)
600
+{
601
+#ifdef SCTP_MAX_BURST
589 602
 	if ((int)(long)(*val)==0){ /* do nothing for 0, keep the old value */
590 603
 		*val=(void*)(long)cfg_get(sctp, cfg_h, max_burst);
591
-		return 0;
592 604
 	}
593
-	memset(&av, 0, sizeof(av)); /* zero everything we don't care about */
594
-	av.assoc_value=(int)(long)(*val);
595
-	SCTP_SET_SOCKOPT_BODY(IPPROTO_SCTP, SCTP_MAX_BURST, av,
596
-							"cfg: setting SCTP_MAX_BURST");
605
+	return 0;
597 606
 #else
598 607
 	ERR("no SCTP_MAX_BURST support, please upgrade your sctp library\n");
599 608
 	return -1;
600 609
 #endif /* SCTP_MAX_BURST */
601 610
 }
602 611
 
612
+
613
+static void set_max_burst(str* gname, str* name)
614
+{
615
+#ifdef SCTP_MAX_BURST
616
+	struct sctp_assoc_value av;
617
+	SCTP_SET_SOCKOPT_DECLS;
618
+	
619
+	memset(&av, 0, sizeof(av)); /* zero everything we don't care about */
620
+	av.assoc_value=cfg_get(sctp, sctp_cfg, max_burst);
621
+	SCTP_SET_SOCKOPT_BODY_NRET(IPPROTO_SCTP, SCTP_MAX_BURST, av,
622
+								"cfg: setting SCTP_MAX_BURST");
623
+#else
624
+	ERR("no SCTP_MAX_BURST support, please upgrade your sctp library\n");
625
+#endif /* SCTP_MAX_BURST */
626
+}
627
+
603 628
 #endif /* USE_SCTP */