Restart transaction if server returns IAID error code
authorSteven Barth <steven@midlink.org>
Wed, 18 Sep 2013 10:25:20 +0000 (12:25 +0200)
committerSteven Barth <steven@midlink.org>
Wed, 18 Sep 2013 10:25:20 +0000 (12:25 +0200)
src/dhcpv6.c

index 50bbb0225cf20755f320c8906d03613de0598df2..ee2031d1a81d8abc999a9625235a5ea69fc631c3 100644 (file)
@@ -744,18 +744,20 @@ static int dhcpv6_handle_reply(enum dhcpv6_msg orig,
                        if (ia_hdr->iaid != 1 || l_t2 < l_t1)
                                continue;
 
-                       bool error = false;
+                       int error = 0;
                        uint16_t stype, slen;
                        uint8_t *sdata;
                        // Test status and bail if error
                        dhcpv6_for_each_option(&ia_hdr[1], odata + olen,
                                        stype, slen, sdata)
-                               if (stype == DHCPV6_OPT_STATUS && slen >= 2 &&
-                                               (sdata[0] || sdata[1]))
-                                       error = true;
+                               if (stype == DHCPV6_OPT_STATUS && slen >= 2)
+                                       error = ((int)sdata[0]) << 8 | ((int)sdata[1]);
 
-                       if (error)
-                               continue;
+                       if (error) {
+                               syslog(LOG_WARNING, "Server returned IAID status %i!", error);
+                               raise(SIGUSR2);
+                               break;
+                       }
 
                        uint32_t n = dhcpv6_parse_ia(&ia_hdr[1], odata + olen);