Commits

geekman committed 5c272a6

Check TTL in known-answers list and only reply if it's less than half.
This ensures we still update responders that do not remove records that are about to expire (with less than half of the actual TTL).

  • Participants
  • Parent commits 0e43136

Comments (0)

Files changed (1)

 		struct rr_list *ans = NULL, *prev_ans = NULL;
 		for (ans = reply->rr_ans; ans; ) {
 			struct rr_list *next_ans = ans->next;
+			struct rr_entry *known_ans = rr_entry_match(pkt->rr_ans, ans->e);
 
-			if (rr_entry_match(pkt->rr_ans, ans->e)) {
+			// discard answers that have at least half of the actual TTL
+			if (known_ans != NULL && known_ans->ttl >= ans->e->ttl / 2) {
 				char *namestr = nlabel_to_str(ans->e->name);
 				DEBUG_PRINTF("removing answer for %s\n", namestr);
 				free(namestr);