Skip to content

Commit

Permalink
Together with Mukund Sivaraman we found out PowerDNS sdig does not tr…
Browse files Browse the repository at this point in the history
…uncate

trailing bits of EDNS Client Subnet mask.  So if you'd truncate something as
a /9, we'd have to use 2 bytes anyhow, but we would not zero the last 7 bits.

We do now. Thanks Mukund & ISC!

(cherry picked from commit d7da15c)
  • Loading branch information
ahupowerdns authored and pieterlexis committed Nov 7, 2017
1 parent 315429b commit 2e58ac1
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pdns/ednssubnet.cc
Expand Up @@ -88,10 +88,13 @@ string makeEDNSSubnetOptsString(const EDNSSubnetOpts& eso)
ret.assign((const char*)&esow, sizeof(esow));
int octetsout = ((esow.sourceMask - 1)>> 3)+1;

ComboAddress src=eso.source.getNetwork();
src.truncate(esow.sourceMask);

if(family == htons(1))
ret.append((const char*) &eso.source.getNetwork().sin4.sin_addr.s_addr, octetsout);
ret.append((const char*) &src.sin4.sin_addr.s_addr, octetsout);
else
ret.append((const char*) &eso.source.getNetwork().sin6.sin6_addr.s6_addr, octetsout);
ret.append((const char*) &src.sin6.sin6_addr.s6_addr, octetsout);
return ret;
}

0 comments on commit 2e58ac1

Please sign in to comment.