]> granicus.if.org Git - pdns/commitdiff
Together with Mukund Sivaraman we found out PowerDNS sdig does not truncate
authorbert hubert <bert.hubert@netherlabs.nl>
Fri, 12 May 2017 19:25:16 +0000 (21:25 +0200)
committerPieter Lexis <pieter.lexis@powerdns.com>
Mon, 13 Nov 2017 14:13:55 +0000 (15:13 +0100)
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 d7da15c560946cadaadfc173b8964dd6b40932ed)

modules/remotebackend/Makefile.am
pdns/Makefile.am
pdns/ednssubnet.cc

index ffe8a353ae1e88a3b8e3d14edb8b2916a53f85c1..e965c51b42abaffb6e500baa5e8f063cf32881d8 100644 (file)
@@ -105,6 +105,7 @@ libtestremotebackend_la_SOURCES = \
        ../../pdns/dnsrecords.cc \
        ../../pdns/dnssecinfra.cc \
        ../../pdns/ednssubnet.cc \
+       ../../pdns/iputils.cc \
        ../../pdns/logger.cc \
        ../../pdns/misc.cc \
        ../../pdns/nsecrecords.cc \
index f423cc01d8d402c4d4bc348e5e92c44743f87c9f..13085e1ff801106818c9b6c16ad94ff1dcb0499d 100644 (file)
@@ -455,6 +455,7 @@ sdig_SOURCES = \
        dnsrecords.cc \
        dnswriter.cc dnswriter.hh \
        ednssubnet.cc \
+       iputils.hh iputils.cc \
        logger.cc \
        misc.cc misc.hh \
        nsecrecords.cc \
@@ -682,6 +683,7 @@ toysdig_SOURCES = \
        dnssecinfra.cc \
        dnswriter.cc dnswriter.hh \
        ednssubnet.cc ednssubnet.hh \
+       iputils.cc iputils.hh \
        filterpo.hh \
        gss_context.cc gss_context.hh \
        logger.cc \
@@ -894,6 +896,7 @@ dnsreplay_SOURCES = \
        dnswriter.cc dnswriter.hh \
        ednssubnet.cc ednssubnet.hh \
        ednsoptions.cc ednsoptions.hh \
+       iputils.hh iputils.cc \
        logger.cc \
        misc.cc \
        nsecrecords.cc \
index 62fa73ee511fed8a377d7f13b851e2efbb193aa1..2258a64bd7598d0d0d2cb47134bba3f60c5d3c08 100644 (file)
@@ -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;
 }