summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorsbyx <steven@midlink.org>2014-04-24 11:07:19 +0200
committersbyx <steven@midlink.org>2014-04-24 11:07:19 +0200
commitd3cc614ef3120d504f2029a8e9494dccafdc14dd (patch)
treebd9d0532ea6ae7b8defb5e84ef34963e8e5a1d92
parent0c6ad596952d78267369561b57723b93d835b953 (diff)
parent749997650804f107ebb2f5ed6c91ed95b620b4dd (diff)
Merge pull request #13 from dedeckeh/bugfixes
Bugfixes
-rw-r--r--src/dhcpv6-ia.c9
-rw-r--r--src/dhcpv6.c2
2 files changed, 7 insertions, 4 deletions
diff --git a/src/dhcpv6-ia.c b/src/dhcpv6-ia.c
index 844dfd3..c655d93 100644
--- a/src/dhcpv6-ia.c
+++ b/src/dhcpv6-ia.c
@@ -972,6 +972,7 @@ ssize_t dhcpv6_handle_ia(uint8_t *buf, size_t buflen, struct interface *iface,
dhcpv6_for_each_option(start, end, otype, olen, odata) {
bool is_pd = (otype == DHCPV6_OPT_IA_PD);
bool is_na = (otype == DHCPV6_OPT_IA_NA);
+ bool ia_addr_present = false;
if (!is_pd && !is_na)
continue;
@@ -1024,6 +1025,7 @@ ssize_t dhcpv6_handle_ia(uint8_t *buf, size_t buflen, struct interface *iface,
if (stype != DHCPV6_OPT_IA_ADDR || slen < sizeof(struct dhcpv6_ia_addr) - 4)
continue;
+ ia_addr_present = true;
#ifdef DHCPV6_OPT_PREFIX_CLASS
uint8_t *xdata;
uint16_t xtype, xlen;
@@ -1178,8 +1180,8 @@ ssize_t dhcpv6_handle_ia(uint8_t *buf, size_t buflen, struct interface *iface,
a->valid_until = now + 3600; // Block address for 1h
update_state = true;
}
- } else if (hdr->msg_type == DHCPV6_MSG_CONFIRM) {
- // Always send NOTONLINK for CONFIRM so that clients restart connection
+ } else if (hdr->msg_type == DHCPV6_MSG_CONFIRM && ia_addr_present) {
+ // Send NOTONLINK for CONFIRM with addr present so that clients restart connection
status = DHCPV6_STATUS_NOTONLINK;
ia_response_len = append_reply(buf, buflen, status, ia, a, iface, true);
}
@@ -1189,7 +1191,8 @@ ssize_t dhcpv6_handle_ia(uint8_t *buf, size_t buflen, struct interface *iface,
response_len += ia_response_len;
}
- if (hdr->msg_type == DHCPV6_MSG_RELEASE && response_len + 6 < buflen) {
+ if ((hdr->msg_type == DHCPV6_MSG_RELEASE || hdr->msg_type == DHCPV6_MSG_DECLINE) &&
+ response_len + 6 < buflen) {
buf[0] = 0;
buf[1] = DHCPV6_OPT_STATUS;
buf[2] = 0;
diff --git a/src/dhcpv6.c b/src/dhcpv6.c
index 62f30e2..55b9ea9 100644
--- a/src/dhcpv6.c
+++ b/src/dhcpv6.c
@@ -320,7 +320,7 @@ static void handle_client_request(void *addr, void *data, size_t len,
if (opts[-4] != DHCPV6_MSG_INFORMATION_REQUEST) {
ssize_t ialen = dhcpv6_handle_ia(pdbuf, sizeof(pdbuf), iface, addr, &opts[-4], opts_end);
iov[6].iov_len = ialen;
- if (ialen < 0 || (ialen == 0 && opts[-4] == DHCPV6_MSG_REBIND))
+ if (ialen < 0 || (ialen == 0 && (opts[-4] == DHCPV6_MSG_REBIND || opts[-4] == DHCPV6_MSG_CONFIRM)))
return;
}