From 0f72844fc537413df8595ad07ad6ce2b86989521 Mon Sep 17 00:00:00 2001 From: Vladislav Grishenko Date: Sat, 25 Apr 2015 20:52:57 +0500 Subject: Avoid of waiting for Advertise in stateless-only mode Start with Information-request when configured not to ask IA_NA/IA_PD. It allows to complete the exchange using only two messages, instead of four, and fixes infinite Advertise waiting loop with servers that just ignore Solicit messages. --- src/dhcpv6.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'src/dhcpv6.c') diff --git a/src/dhcpv6.c b/src/dhcpv6.c index bc403b9..425aee1 100644 --- a/src/dhcpv6.c +++ b/src/dhcpv6.c @@ -216,10 +216,19 @@ enum { IOV_TOTAL }; -void dhcpv6_set_ia_mode(enum odhcp6c_ia_mode na, enum odhcp6c_ia_mode pd) +int dhcpv6_set_ia_mode(enum odhcp6c_ia_mode na, enum odhcp6c_ia_mode pd) { + int mode = DHCPV6_UNKNOWN; + na_mode = na; pd_mode = pd; + + if (na_mode == IA_MODE_NONE && pd_mode == IA_MODE_NONE) + mode = DHCPV6_STATELESS; + else if (na_mode == IA_MODE_FORCE || pd_mode == IA_MODE_FORCE) + mode = DHCPV6_STATEFUL; + + return mode; } static void dhcpv6_send(enum dhcpv6_msg type, uint8_t trid[3], uint32_t ecs) @@ -547,10 +556,15 @@ int dhcpv6_request(enum dhcpv6_msg type) round_end = timeout * 1000 + start; // Built and send package - if (type != DHCPV6_MSG_UNKNOWN) { - if (type != DHCPV6_MSG_SOLICIT) - syslog(LOG_NOTICE, "Send %s message (elapsed %llums, rc %d)", - retx->name, (unsigned long long)elapsed, rc); + switch (type) { + case DHCPV6_MSG_UNKNOWN: + break; + default: + syslog(LOG_NOTICE, "Send %s message (elapsed %llums, rc %d)", + retx->name, (unsigned long long)elapsed, rc); + // Fall through + case DHCPV6_MSG_SOLICIT: + case DHCPV6_MSG_INFO_REQ: dhcpv6_send(type, trid, elapsed / 10); rc++; } -- cgit v1.2.1