]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- Fix round robin for failed addresses with prefer-ip6: yes
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Fri, 6 Jul 2018 14:40:35 +0000 (14:40 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Fri, 6 Jul 2018 14:40:35 +0000 (14:40 +0000)
git-svn-id: file:///svn/unbound/trunk@4776 be551aaa-1e26-0410-a405-d3ace91eadb9

doc/Changelog
iterator/iter_utils.c

index 52ede2978afe955ce2362476f476c5431049036f..c4c1e1864aac5240554750f14189f5aed3c48fcb 100644 (file)
@@ -4,6 +4,7 @@
        - iana port update.
        - Note RFC8162 support.  SMIMEA record type can be read in by the
          zone record parser.
+       - Fix round robin for failed addresses with prefer-ip6: yes
 
 4 July 2018: Wouter
        - Fix #4112: Fix that unbound-anchor -f /etc/resolv.conf will not pass
index df66776ae80d7d069a8fa926fa16a50af172cec7..90c8cf114e3328a64404bdf8592746b12a6981ac 100644 (file)
@@ -378,17 +378,32 @@ iter_filter_order(struct iter_env* iter_env, struct module_env* env,
                int attempt = -1; /* filter to make sure addresses have
                  less attempts on them than the first, to force round
                  robin when all the IPv6 addresses fail */
+               int num4ok = 0; /* number ip4 at low attempt count */
+               int num4_lowrtt = 0;
                prev = NULL;
                a = dp->result_list;
                for(i = 0; i < got_num; i++) {
                        swap_to_front = 0;
-                       if(a->addr.ss_family != AF_INET6 && attempt == -1)
+                       if(a->addr.ss_family != AF_INET6 && attempt == -1) {
+                               /* if we only have ip4 at low attempt count,
+                                * then ip6 is failing, and we need to
+                                * select one of the remaining IPv4 addrs */
                                attempt = a->attempts;
-                       if(a->addr.ss_family == AF_INET6 &&
-                               (attempt==-1 || a->attempts<=attempt)) {
-                               got_num6++;
-                               if(attempt == -1)
+                               num4ok++;
+                               num4_lowrtt = a->sel_rtt;
+                       } else if(a->addr.ss_family != AF_INET6 && attempt == a->attempts) {
+                               num4ok++;
+                               if(num4_lowrtt == 0 || a->sel_rtt < num4_lowrtt) {
+                                       num4_lowrtt = a->sel_rtt;
+                               }
+                       }
+                       if(a->addr.ss_family == AF_INET6) {
+                               if(attempt == -1) {
                                        attempt = a->attempts;
+                               } else if(a->attempts > attempt) {
+                                       break;
+                               }
+                               got_num6++;
                                swap_to_front = 1;
                                if(low_rtt6 == 0 || a->sel_rtt < low_rtt6) {
                                        low_rtt6 = a->sel_rtt;
@@ -409,6 +424,9 @@ iter_filter_order(struct iter_env* iter_env, struct module_env* env,
                if(got_num6 > 0) {
                        got_num = got_num6;
                        *selected_rtt = low_rtt6;
+               } else if(num4ok > 0) {
+                       got_num = num4ok;
+                       *selected_rtt = num4_lowrtt;
                }
        }
        return got_num;