From 5a7f99b44b6debc8e5ebe167357cb88df90a73ed Mon Sep 17 00:00:00 2001 From: bert hubert Date: Fri, 5 Oct 2018 15:25:59 +0200 Subject: [PATCH] emit a /0 ECS response on non-variable answers when using use-incoming-ecs, for the eventual benefit of dnsdist --- pdns/pdns_recursor.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index 19a28408f2..67ea44375f 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -1486,6 +1486,17 @@ static void startDoResolve(void *p) } sendit:; + if(g_useIncomingECS && haveEDNS && !sr.wasVariable()) { + EDNSSubnetOpts eo; + eo.source = dc->d_ednssubnet.source; + ComboAddress sa; + memset(&sa, 0, sizeof(sa)); + sa.sin4.sin_family = eo.source.getNetwork().sin4.sin_family; + eo.scope = Netmask(sa, 0); + + returnedEdnsOptions.push_back(make_pair(EDNSOptionCode::ECS, makeEDNSSubnetOptsString(eo))); + } + if (haveEDNS) { /* we try to add the EDNS OPT RR even for truncated answers, as rfc6891 states: -- 2.39.5