From: Ben Pfaff Date: Mon, 14 Jul 2008 20:20:00 +0000 (-0700) Subject: Add new --max-backoff option to secchan and switch programs. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ab6f9e079b77d721d1b059a6abaf12e64a9bb653;p=openvswitch Add new --max-backoff option to secchan and switch programs. One use case is when NOX is running on localhost, in which case waiting for the full default backoff interval is unnecessary and undesirable. Also changes default maximum backoff to 15 seconds (from 60). --- diff --git a/secchan/secchan.8.in b/secchan/secchan.8.in index b1826b9a..8cf8ee8b 100644 --- a/secchan/secchan.8.in +++ b/secchan/secchan.8.in @@ -150,6 +150,14 @@ more information about in-band control). As a result, when both \fB--fail=open\fR and in-band control are not in use, this option has no effect. +.TP +\fB--max-backoff=\fIsecs\fR +Sets the maximum time between attempts to connect to the controller to +\fIsecs\fR, which must be at least 1. The actual interval between +connection attempts starts at 1 second and doubles on each failing +attempt until it reaches the maximum. The default maximum backoff +time is 15 seconds. + .TP \fB-l\fR, \fB--listen=\fImethod\fR Configures the switch to additionally listen for incoming OpenFlow diff --git a/secchan/secchan.c b/secchan/secchan.c index c5793dd7..61039b5b 100644 --- a/secchan/secchan.c +++ b/secchan/secchan.c @@ -114,6 +114,10 @@ static int probe_interval = 15; * fail-open mode. */ static int max_idle = 15; +/* --max-backoff: Maximum interval between controller connection attempts, in + * seconds. */ +static int max_backoff = 15; + static void parse_options(int argc, char *argv[]); static void usage(void) NO_RETURN; @@ -197,9 +201,9 @@ main(int argc, char *argv[]) daemonize(); - controller_relay = relay_create(rconn_new(argv[optind], 1, 0, 0), + controller_relay = relay_create(rconn_new(argv[optind], 1, 0, max_backoff), rconn_new(argv[optind + 1], 1, - probe_interval, 0), + probe_interval, max_backoff), false); for (;;) { struct relay *r, *n; @@ -539,11 +543,16 @@ fail_open_hook(struct relay *r) static void parse_options(int argc, char *argv[]) { - enum { OPT_INACTIVITY_PROBE = UCHAR_MAX + 1, OPT_MAX_IDLE }; + enum { + OPT_INACTIVITY_PROBE = UCHAR_MAX + 1, + OPT_MAX_IDLE, + OPT_MAX_BACKOFF + }; static struct option long_options[] = { {"fail", required_argument, 0, 'f'}, {"inactivity-probe", required_argument, 0, OPT_INACTIVITY_PROBE}, {"max-idle", required_argument, 0, OPT_MAX_IDLE}, + {"max-backoff", required_argument, 0, OPT_MAX_BACKOFF}, {"listen", required_argument, 0, 'l'}, {"detach", no_argument, 0, 'D'}, {"pidfile", optional_argument, 0, 'P'}, @@ -594,6 +603,15 @@ parse_options(int argc, char *argv[]) } break; + case OPT_MAX_BACKOFF: + max_backoff = atoi(optarg); + if (max_backoff < 1) { + fatal(0, "--max-backoff argument must be at least 1"); + } else if (max_backoff > 3600) { + max_backoff = 3600; + } + break; + case 'D': set_detach(); break; @@ -647,6 +665,8 @@ usage(void) " open (default): act as learning switch\n" " --inactivity-probe=SECS time between inactivity probes\n" " --max-idle=SECS max idle for flows set up by secchan\n" + " --max-backoff=SECS max time between controller connection\n" + " attempts (default: 15 seconds)\n" " -l, --listen=METHOD allow management connections on METHOD\n" " (a passive OpenFlow connection method)\n" "\nOther options:\n" diff --git a/switch/switch.8.in b/switch/switch.8.in index 93e6868f..6617101b 100644 --- a/switch/switch.8.in +++ b/switch/switch.8.in @@ -56,6 +56,14 @@ Specifies the OpenFlow switch ID (a 48-bit number that uniquely identifies a controller) as \fIdpid\fR, which consists of exactly 12 hex digits. Without this option, \fBswitch\fR picks an ID randomly. +.TP +\fB--max-backoff=\fIsecs\fR +Sets the maximum time between attempts to connect to the controller to +\fIsecs\fR, which must be at least 1. The actual interval between +connection attempts starts at 1 second and doubles on each failing +attempt until it reaches the maximum. The default maximum backoff +time is 15 seconds. + .TP \fB-p\fR, \fB--private-key=\fIprivkey.pem\fR Specifies a PEM file containing the private key used as the switch's diff --git a/switch/switch.c b/switch/switch.c index 8a1f94e2..77d43bb8 100644 --- a/switch/switch.c +++ b/switch/switch.c @@ -33,6 +33,7 @@ #include #include +#include #include #include #include @@ -61,6 +62,10 @@ static struct datapath *dp; static uint64_t dpid = UINT64_MAX; static char *port_list; +/* --max-backoff: Maximum interval between controller connection attempts, in + * seconds. */ +static int max_backoff = 15; + static void add_ports(struct datapath *dp, char *port_list); int @@ -77,7 +82,7 @@ main(int argc, char *argv[]) fatal(0, "missing controller argument; use --help for usage"); } - error = dp_new(&dp, dpid, rconn_new(argv[optind], 128, 60, 0)); + error = dp_new(&dp, dpid, rconn_new(argv[optind], 128, 60, max_backoff)); if (listen_vconn_name) { struct vconn *listen_vconn; int retval; @@ -135,9 +140,14 @@ add_ports(struct datapath *dp, char *port_list) static void parse_options(int argc, char *argv[]) { + enum { + OPT_MAX_BACKOFF = UCHAR_MAX + 1 + }; + static struct option long_options[] = { {"interfaces", required_argument, 0, 'i'}, {"datapath-id", required_argument, 0, 'd'}, + {"max-backoff", required_argument, 0, OPT_MAX_BACKOFF}, {"listen", required_argument, 0, 'l'}, {"detach", no_argument, 0, 'D'}, {"pidfile", optional_argument, 0, 'P'}, @@ -198,6 +208,15 @@ parse_options(int argc, char *argv[]) } break; + case OPT_MAX_BACKOFF: + max_backoff = atoi(optarg); + if (max_backoff < 1) { + fatal(0, "--max-backoff argument must be at least 1"); + } else if (max_backoff > 3600) { + max_backoff = 3600; + } + break; + case 'l': if (listen_vconn_name) { fatal(0, "-l or --listen may be only specified once"); @@ -230,6 +249,8 @@ usage(void) " add specified initial switch ports\n" " -d, --datapath-id=ID Use ID as the OpenFlow switch ID\n" " (ID must consist of 12 hex digits)\n" + " --max-backoff=SECS max time between controller connection\n" + " attempts (default: 15 seconds)\n" " -l, --listen=METHOD allow management connections on METHOD\n" " (a passive OpenFlow connection method)\n" "\nOther options:\n"