[smokeping-users] non-uniqe DNS IDs with SmokePing and AnotherDNS

Gert Doering gert at space.net
Wed Oct 24 19:07:18 CEST 2012


Hi,

forwarded to the list on request, in case someone might have more insight 
or better Perl-Fu...

gert
----- Forwarded message from Gert Doering <gert at space.net> -----

Date: Wed, 24 Oct 2012 12:14:11 +0200
From: Gert Doering <gert at space.net>
Subject: non-uniqe DNS IDs with SmokePing and AnotherDNS
User-Agent: Mutt/1.5.21 (2010-09-15)

Hi Olaf, Tobi,

I've run into an issue with SmokePing, its AnotherDNS probe, and Net::DNS
that I do not understand.

Specifically, every DNS probe SmokePing sends carries the very same
Query ID - which it shouldn't do from a DNS PoV, but even from staring
at the code involved, this should not happen (I have traces from various
versions of SmokePing and perl on FreeBSD and Linux that show this, so 
I claim it's not my local installation that is borked).


SmokePing does this (AnotherDNS.pm, pingone()):

-------------------- snip ---------------------
    my $packet = Net::DNS::Packet->new( $lookuphost, $recordtype )->data;
...
    for ( my $run = 0 ; $run < $self->pings($target) ; $run++ ) {
...
        $sock->send($packet);
...
-------------------- snip ---------------------

while Net::DNS::Header does:

-------------------- snip ---------------------
{
        sub nextid { int rand(MAX_ID); }
}

sub new {
        my $class = shift;

        bless { id      => nextid(),
...
-------------------- snip ---------------------

together, this should achieve:

 - for every invocation of pingone(), a new (random) DNS ID is rolled
 - for all $self->pings($target)  (5), the same ID is used, as the same
   Net::DNS::Packet is sent
   (whether this is "right" is debatable, but it is the way it is today)

but, what I see is that *every* *single* DNS packet that AnotherDNS
creates, no matter for which target (different packets!), or for which
run-of-5, will *always* use the very same DNS query ID - verified by
calling Data::Dumper on what Net::DNS::Packet->new() returns, "id => ..."
changes when I restart SmokePing, but after that, it's always the same.

Now, one could argue that "something in SmokePing is breaking rand()",
but it's not so easy.  If I change the SmokePing code to do this:

-------------------- snip ---------------------
    my $p1 = Net::DNS::Packet->new( $lookuphost, $recordtype );
...
    for ( my $run = 0 ; $run < $self->pings($target) ; $run++ ) {
...
        $p1->header->id( int(rand(65535)) );
        my $packet = $p1->data;
        $sock->send($packet);
...
-------------------- snip ---------------------

it will send a random query ID for every single packet - so rand() is not
to blame.

OTOH, Net::DNS::Packet is also very well-behaved if I call it from a 
test program

-------------------- snip ---------------------
#!/usr/bin/perl -w
use Data::Dumper;
use Net::DNS;

foreach my $i (0..4)
{
    my $packet = Net::DNS::Packet->new( "www.space.net", "A" );
    print Dumper($packet);
}
-------------------- snip ---------------------

-> new ID every time (this is what *should* happen for different runs of
SmokePing's "pingone()" - i.e. for different targets, or every 5 minutes
for a new set of DNS queries).


Soooo... something in SmokePing is affecting Net::DNS::Header's
"nextid()" in surprising ways, and I can't find it...

I think it's a SmokePing bug (the query ID should be randomized for 
every single packet, not only between runs) *but* the fact that it
can break what Net::DNS::Header is doing might warrant looking at the
implementation in Net::DNS - "applications should not be able to break
that!".  No?

thanks for your attention :-)

Gert Doering
        -- NetMaster
-- 
have you enabled IPv6 on something today...?

SpaceNet AG                        Vorstand: Sebastian v. Bomhard
Joseph-Dollinger-Bogen 14          Aufsichtsratsvors.: A. Grundner-Culemann
D-80807 Muenchen                   HRB: 136055 (AG Muenchen)
Tel: +49 (89) 32356-444            USt-IdNr.: DE813185279
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 306 bytes
Desc: not available
Url : http://lists.oetiker.ch/pipermail/smokeping-users/attachments/20121024/94d165f3/attachment-0001.pgp 


More information about the smokeping-users mailing list