[LEDE-DEV] [PATCH mdns] Don't call dns_reply_a from service_reply

Rafał Miłecki zajec5 at gmail.com
Wed Feb 8 09:04:27 PST 2017


From: Rafał Miłecki <rafal at milecki.pl>

This simplifies code without changing any behavior. Having this call in
service_reply required checking two conditions and was making code flow
harder to follow.

There are 2 more service_reply calls in the project:
1) In service_announce_services where we iterate over &services and
   every element of this list has "service" field filled. It means match
   argument was never NULL and dns_reply_a was never called from there.
2) In parse_question which also receives some name (there is a proper
   check in the dns_handle_packet). No call there neither.

So after all there was only 1 place that was indeed calling dns_reply_a.

Signed-off-by: Rafał Miłecki <rafal at milecki.pl>
---
 dns.c     | 4 +++-
 service.c | 6 ------
 2 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/dns.c b/dns.c
index 7ca705e..aac1de1 100644
--- a/dns.c
+++ b/dns.c
@@ -360,8 +360,10 @@ parse_question(struct interface *iface, char *name, struct dns_question *q)
 
 	switch (q->type) {
 	case TYPE_ANY:
-		if (!strcmp(name, mdns_hostname_local))
+		if (!strcmp(name, mdns_hostname_local)) {
 			service_reply(iface, NULL, announce_ttl);
+			dns_reply_a(iface, announce_ttl);
+		}
 		break;
 
 	case TYPE_PTR:
diff --git a/service.c b/service.c
index a3a5bb4..f45784b 100644
--- a/service.c
+++ b/service.c
@@ -153,12 +153,6 @@ service_reply(struct interface *iface, const char *match, int ttl)
 
 	vlist_for_each_element(&services, s, node)
 		service_reply_single(iface, s, match, ttl, 0);
-
-	if (match)
-		return;
-
-	if (ttl)
-		dns_reply_a(iface, ttl);
 }
 
 void
-- 
2.11.0




More information about the Lede-dev mailing list