From: Ben Pfaff Date: Tue, 14 Oct 2008 23:11:06 +0000 (-0700) Subject: Set DHCP maximum retransmission timeout to 3 seconds in secchan. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2c5272bc28b515e5bf17d4d622113fa25f78d574;p=openvswitch Set DHCP maximum retransmission timeout to 3 seconds in secchan. This should help discovery complete faster, especially with hops across multiple OpenFlow switches to the controller. --- diff --git a/include/dhcp-client.h b/include/dhcp-client.h index e0d1e37c..8dfc50cb 100644 --- a/include/dhcp-client.h +++ b/include/dhcp-client.h @@ -44,6 +44,7 @@ int dhclient_create(const char *netdev, void (*modify_request)(struct dhcp_msg *, void *aux), bool (*validate_offer)(const struct dhcp_msg *, void *aux), void *aux, struct dhclient **); +void dhclient_set_max_timeout(struct dhclient *, unsigned int max_timeout); void dhclient_destroy(struct dhclient *); struct netdev *dhclient_get_netdev(struct dhclient *); diff --git a/lib/dhcp-client.c b/lib/dhcp-client.c index c770f2a6..460fedf9 100644 --- a/lib/dhcp-client.c +++ b/lib/dhcp-client.c @@ -103,6 +103,7 @@ struct dhclient { bool changed; unsigned int retransmit, delay; /* Used by send_reliably(). */ + unsigned int max_timeout; unsigned int init_delay; /* Used by S_INIT. */ @@ -199,6 +200,7 @@ dhclient_create(const char *netdev_name, cli->ipaddr = 0; cli->server_ip = 0; cli->retransmit = cli->delay = 0; + cli->max_timeout = 64; cli->min_timeout = 1; ds_init(&cli->s); cli->changed = true; @@ -206,6 +208,15 @@ dhclient_create(const char *netdev_name, return 0; } +/* Sets the maximum amount of timeout that 'cli' will wait for a reply from + * the DHCP server before retransmitting, in seconds, to 'max_timeout'. The + * default is 64 seconds. */ +void +dhclient_set_max_timeout(struct dhclient *cli, unsigned int max_timeout) +{ + cli->max_timeout = MAX(2, max_timeout); +} + /* Destroys 'cli' and frees all related resources. */ void dhclient_destroy(struct dhclient *cli) @@ -867,7 +878,7 @@ send_reliably(struct dhclient *cli, cli->modify_request(&msg, cli->aux); } do_send_msg(cli, &msg); - cli->delay = MIN(64, MAX(4, cli->delay * 2)); + cli->delay = MIN(cli->max_timeout, MAX(4, cli->delay * 2)); cli->retransmit += fuzz(cli->delay, 1); timeout(cli, cli->retransmit); dhcp_msg_uninit(&msg); diff --git a/secchan/secchan.c b/secchan/secchan.c index 78ccf307..27ecf1b7 100644 --- a/secchan/secchan.c +++ b/secchan/secchan.c @@ -2378,6 +2378,7 @@ discovery_local_port_cb(const struct ofp_phy_port *port, void *d_) "discovery disabled: %s", strerror(retval)); return; } + dhclient_set_max_timeout(d->dhcp, 3); dhclient_init(d->dhcp, 0); } else { dhclient_destroy(d->dhcp);