Skip to content

Commit fc006d7

Browse files
jukkarhenrikbrixandersen
authored andcommitted
net: dns: Do not pass 0 as TTL or hop limit
We specifically set TTL/hoplimit to 1 for LLMNR, but only want to set it if in that specific case. We must not pass TTL/hoplimit value 0 as that would cause the packet to be dropped. Signed-off-by: Jukka Rissanen <[email protected]>
1 parent 921c945 commit fc006d7

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

subsys/net/lib/dns/resolve.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -906,10 +906,12 @@ static int dns_write(struct dns_resolve_context *ctx,
906906
dns_qname->len + 2);
907907

908908
if (IS_ENABLED(CONFIG_NET_IPV6) &&
909-
net_context_get_family(net_ctx) == AF_INET6) {
909+
net_context_get_family(net_ctx) == AF_INET6 &&
910+
hop_limit > 0) {
910911
net_context_set_ipv6_hop_limit(net_ctx, hop_limit);
911912
} else if (IS_ENABLED(CONFIG_NET_IPV4) &&
912-
net_context_get_family(net_ctx) == AF_INET) {
913+
net_context_get_family(net_ctx) == AF_INET &&
914+
hop_limit > 0) {
913915
net_context_set_ipv4_ttl(net_ctx, hop_limit);
914916
}
915917

0 commit comments

Comments
 (0)