From 7975e9cf145a97b0eeb717841bae845a0bb20a63 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Thu, 19 Mar 2009 11:16:29 -0700 Subject: [PATCH] vswitch: Add rate-limiting support. --- vswitchd/bridge.c | 12 ++++++++++++ vswitchd/vswitchd.conf.5.in | 32 ++++++++++++++++++++++++++++++-- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c index 35093fab..204e2596 100644 --- a/vswitchd/bridge.c +++ b/vswitchd/bridge.c @@ -854,6 +854,7 @@ bridge_reconfigure_one(struct bridge *br) if (ctl && strlen(ctl) != 0) { const char *fail_mode; int max_backoff, probe; + int rate_limit, burst_limit; if (!strcmp(ctl, "discover")) { ofproto_set_discovery(br->ofproto, true, @@ -919,6 +920,17 @@ bridge_reconfigure_one(struct bridge *br) } ofproto_set_max_backoff(br->ofproto, max_backoff); + rate_limit = cfg_get_int(0, "%s.rate-limit", pfx); + if (!rate_limit) { + rate_limit = cfg_get_int(0, "mgmt.rate-limit"); + } + burst_limit = cfg_get_int(0, "%s.burst-limit", pfx); + if (!burst_limit) { + burst_limit = cfg_get_int(0, "mgmt.burst-limit"); + } + printf("rate_limit=%d burst_limit=%d\n", rate_limit, burst_limit); + ofproto_set_rate_limit(br->ofproto, rate_limit, burst_limit); + ofproto_set_stp(br->ofproto, cfg_get_bool(0, "%s.stp", pfx)); if (cfg_has("%s.commands.acl", pfx)) { diff --git a/vswitchd/vswitchd.conf.5.in b/vswitchd/vswitchd.conf.5.in index 766f3a70..b9127eb5 100644 --- a/vswitchd/vswitchd.conf.5.in +++ b/vswitchd/vswitchd.conf.5.in @@ -2,12 +2,17 @@ .de TQ . br . ns -. TP \$1 +. TP "\\$1" +.. +.de IQ +. br +. ns +. IP "\\$1" .. .de ST . PP . RS -0.15in -. I \\$1 +. I "\\$1" . RE . PP .. @@ -524,6 +529,29 @@ Sets the maximum time between attempts to connect to the controller to connection attempts starts at 1 second and doubles on each failing attempt until it reaches the maximum. The default maximum backoff time is taken from \fBmgmt.max-backoff\fR. +.ST "Rate Limit Settings" +These settings configure how the virtual switch applies a ``token +bucket'' to limit the rate at which packets in unknown flows are +forwarded to the OpenFlow controller for flow-setup processing. This +feature prevents a single bridge from overwhelming a controller. +.IP "\fBbridge.\fIname\fB.controller.rate-limit = \fIrate\fR" +.IQ "\fBmgmt.rate-limit = \fIrate\fR" +Limits the maximum rate at which packets will be forwarded to the +OpenFlow controller to \fIrate\fR packets per second. The first of +these that is set takes effect. +.IP +If neither one of these settings is set, then the bridge does not +limit the rate at which packets are forwarded to the controller. +.IP "\fBbridge.\fIname\fB.controller.burst-limit = \fIburst\fR" +.IQ "\fBmgmt.burst-limit = \fIburst\fR" +Sets the maximum number of unused packet credits that the bridge will +allow to accumulate during time in which no packets are being +forwarded to the OpenFlow controller to \fIburst\fR (measured in +packets). The default \fIburst\fR is one-quarter of the \fIrate\fR +specified in the rate limit setting. +.IP +The first of these that is set takes effect. This option takes effect +only when a rate limit is specified. .ST "Remote Command Execution Settings" These settings configure the commands that remote OpenFlow connections are allowed to invoke using (e.g.) \fBdpctl execute\fR. To be -- 2.30.2