View | Details | Raw Unified | Return to bug 220677 | Differences between
and this patch

Collapse All | Expand All

(-)b/sys/netinet/cc/cc_newreno.c (-1 / +52 lines)
Lines 48-53 Link Here
48
 *   http://caia.swin.edu.au/urp/newtcp/
48
 *   http://caia.swin.edu.au/urp/newtcp/
49
 */
49
 */
50
50
51
/*
52
 * Dec 2014 garmitage@swin.edu.au
53
 * Borrowed code fragments from cc_cdg.c to add modifiable beta
54
 * via sysctls.
55
 *
56
 */
57
51
#include <sys/cdefs.h>
58
#include <sys/cdefs.h>
52
__FBSDID("$FreeBSD$");
59
__FBSDID("$FreeBSD$");
53
60
Lines 68-78 __FBSDID("$FreeBSD$"); Link Here
68
#include <netinet/cc/cc.h>
75
#include <netinet/cc/cc.h>
69
#include <netinet/cc/cc_module.h>
76
#include <netinet/cc/cc_module.h>
70
77
78
#define	CAST_PTR_INT(X) (*((int*)(X)))
79
80
#ifndef	VIMAGE
81
#define	vnet_sysctl_handle_uint(oidp, arg1, arg2, req) \
82
    sysctl_handle_int(oidp, arg1, arg2, req)
83
#endif
84
71
static void	newreno_ack_received(struct cc_var *ccv, uint16_t type);
85
static void	newreno_ack_received(struct cc_var *ccv, uint16_t type);
72
static void	newreno_after_idle(struct cc_var *ccv);
86
static void	newreno_after_idle(struct cc_var *ccv);
73
static void	newreno_cong_signal(struct cc_var *ccv, uint32_t type);
87
static void	newreno_cong_signal(struct cc_var *ccv, uint32_t type);
74
static void	newreno_post_recovery(struct cc_var *ccv);
88
static void	newreno_post_recovery(struct cc_var *ccv);
75
89
90
static VNET_DEFINE(uint32_t, newreno_beta_loss) = 50;
91
static VNET_DEFINE(uint32_t, newreno_beta_ecn) = 80;
92
#define V_newreno_beta_loss VNET(newreno_beta_loss)
93
#define V_newreno_beta_ecn VNET(newreno_beta_ecn)
94
76
struct cc_algo newreno_cc_algo = {
95
struct cc_algo newreno_cc_algo = {
77
	.name = "newreno",
96
	.name = "newreno",
78
	.ack_received = newreno_ack_received,
97
	.ack_received = newreno_ack_received,
Lines 195-204 newreno_cong_signal(struct cc_var *ccv, uint32_t type) Link Here
195
	KASSERT((type & CC_SIGPRIVMASK) == 0,
214
	KASSERT((type & CC_SIGPRIVMASK) == 0,
196
	    ("%s: congestion signal type 0x%08x is private\n", __func__, type));
215
	    ("%s: congestion signal type 0x%08x is private\n", __func__, type));
197
216
198
	cwin = max(cwin / 2 / mss, 2) * mss;
199
217
200
	switch (type) {
218
	switch (type) {
201
	case CC_NDUPACK:
219
	case CC_NDUPACK:
220
		if (V_tcp_do_abe)
221
			cwin = max((cwin * V_newreno_beta_loss)/100 / mss, 2) * mss;
222
		else
223
			cwin = max(cwin / 2 / mss, 2) * mss;
224
202
		if (!IN_FASTRECOVERY(CCV(ccv, t_flags))) {
225
		if (!IN_FASTRECOVERY(CCV(ccv, t_flags))) {
203
			if (!IN_CONGRECOVERY(CCV(ccv, t_flags))) {
226
			if (!IN_CONGRECOVERY(CCV(ccv, t_flags))) {
204
				CCV(ccv, snd_ssthresh) = ssthresh_on_loss;
227
				CCV(ccv, snd_ssthresh) = ssthresh_on_loss;
Lines 208-213 newreno_cong_signal(struct cc_var *ccv, uint32_t type) Link Here
208
		}
231
		}
209
		break;
232
		break;
210
	case CC_ECN:
233
	case CC_ECN:
234
		if (V_tcp_do_abe)
235
			cwin = max((cwin * V_newreno_beta_ecn)/100 / mss, 2) * mss;
236
		else
237
			cwin = max(cwin / 2 / mss, 2) * mss;
238
211
		if (!IN_CONGRECOVERY(CCV(ccv, t_flags))) {
239
		if (!IN_CONGRECOVERY(CCV(ccv, t_flags))) {
212
			CCV(ccv, snd_ssthresh) = ssthresh_on_loss;
240
			CCV(ccv, snd_ssthresh) = ssthresh_on_loss;
213
			CCV(ccv, snd_cwnd) = cwin;
241
			CCV(ccv, snd_cwnd) = cwin;
Lines 252-256 newreno_post_recovery(struct cc_var *ccv) Link Here
252
	}
280
	}
253
}
281
}
254
282
283
static int
284
newreno_beta_handler(SYSCTL_HANDLER_ARGS)
285
{
286
	if (req->newptr != NULL &&
287
		(CAST_PTR_INT(req->newptr) <= 0 || CAST_PTR_INT(req->newptr) > 100))
288
		return (EINVAL);
289
290
	return (vnet_sysctl_handle_uint(oidp, arg1, arg2, req));
291
}
292
293
SYSCTL_DECL(_net_inet_tcp_cc_newreno);
294
SYSCTL_NODE(_net_inet_tcp_cc, OID_AUTO, newreno, CTLFLAG_RW, NULL,
295
    "New Reno related settings");
296
297
SYSCTL_PROC(_net_inet_tcp_cc_newreno, OID_AUTO, beta_loss,
298
	CTLFLAG_VNET | CTLTYPE_UINT | CTLFLAG_RW,
299
	&VNET_NAME(newreno_beta_loss), 3, &newreno_beta_handler, "IU",
300
	"newreno beta loss, specified as number between 0 and 100");
301
302
SYSCTL_PROC(_net_inet_tcp_cc_newreno, OID_AUTO, beta_ecn,
303
	CTLFLAG_VNET | CTLTYPE_UINT | CTLFLAG_RW,
304
	&VNET_NAME(newreno_beta_ecn), 3, &newreno_beta_handler, "IU",
305
	"newreno beta ecn, specified as number between 0 and 100");
255
306
256
DECLARE_CC_MODULE(newreno, &newreno_cc_algo);
307
DECLARE_CC_MODULE(newreno, &newreno_cc_algo);
(-)b/sys/netinet/tcp_input.c (+5 lines)
Lines 181-186 SYSCTL_INT(_net_inet_tcp, OID_AUTO, abc_l_var, CTLFLAG_VNET | CTLFLAG_RW, Link Here
181
    &VNET_NAME(tcp_abc_l_var), 2,
181
    &VNET_NAME(tcp_abc_l_var), 2,
182
    "Cap the max cwnd increment during slow-start to this number of segments");
182
    "Cap the max cwnd increment during slow-start to this number of segments");
183
183
184
VNET_DEFINE(int, tcp_do_abe) = 0;
185
SYSCTL_INT(_net_inet_tcp, OID_AUTO, abe, CTLFLAG_VNET | CTLFLAG_RW,
186
    &VNET_NAME(tcp_do_abe), 0,
187
    "Enable ABE for NewReno (Alternative Backoff with ECN)");
188
184
static SYSCTL_NODE(_net_inet_tcp, OID_AUTO, ecn, CTLFLAG_RW, 0, "TCP ECN");
189
static SYSCTL_NODE(_net_inet_tcp, OID_AUTO, ecn, CTLFLAG_RW, 0, "TCP ECN");
185
190
186
VNET_DEFINE(int, tcp_do_ecn) = 2;
191
VNET_DEFINE(int, tcp_do_ecn) = 2;
(-)b/sys/netinet/tcp_var.h (+2 lines)
Lines 708-713 VNET_DECLARE(int, tcp_recvspace); Link Here
708
VNET_DECLARE(int, path_mtu_discovery);
708
VNET_DECLARE(int, path_mtu_discovery);
709
VNET_DECLARE(int, tcp_do_rfc3465);
709
VNET_DECLARE(int, tcp_do_rfc3465);
710
VNET_DECLARE(int, tcp_abc_l_var);
710
VNET_DECLARE(int, tcp_abc_l_var);
711
VNET_DECLARE(int, tcp_do_abe);
711
#define	V_tcb			VNET(tcb)
712
#define	V_tcb			VNET(tcb)
712
#define	V_tcbinfo		VNET(tcbinfo)
713
#define	V_tcbinfo		VNET(tcbinfo)
713
#define	V_tcp_mssdflt		VNET(tcp_mssdflt)
714
#define	V_tcp_mssdflt		VNET(tcp_mssdflt)
Lines 720-725 VNET_DECLARE(int, tcp_abc_l_var); Link Here
720
#define	V_path_mtu_discovery	VNET(path_mtu_discovery)
721
#define	V_path_mtu_discovery	VNET(path_mtu_discovery)
721
#define	V_tcp_do_rfc3465	VNET(tcp_do_rfc3465)
722
#define	V_tcp_do_rfc3465	VNET(tcp_do_rfc3465)
722
#define	V_tcp_abc_l_var		VNET(tcp_abc_l_var)
723
#define	V_tcp_abc_l_var		VNET(tcp_abc_l_var)
724
#define	V_tcp_do_abe		VNET(tcp_do_abe)
723
725
724
VNET_DECLARE(int, tcp_do_sack);			/* SACK enabled/disabled */
726
VNET_DECLARE(int, tcp_do_sack);			/* SACK enabled/disabled */
725
VNET_DECLARE(int, tcp_sc_rst_sock_fail);	/* RST on sock alloc failure */
727
VNET_DECLARE(int, tcp_sc_rst_sock_fail);	/* RST on sock alloc failure */

Return to bug 220677