From ac1908875b68bd4a57ef324cb5ebf5efb50574b7 Mon Sep 17 00:00:00 2001 From: Darell Tan Date: Wed, 17 Oct 2012 21:57:15 +0800 Subject: [PATCH] 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). --- mdnsd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mdnsd.c b/mdnsd.c index 58e9617..37f39d1 100644 --- a/mdnsd.c +++ b/mdnsd.c @@ -280,8 +280,10 @@ static int process_mdns_pkt(struct mdnsd *svr, struct mdns_pkt *pkt, struct mdns 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);