Hi, forwarded to the list on request, in case someone might have more insight or better Perl-Fu...
gert ----- Forwarded message from Gert Doering <[email protected]> ----- Date: Wed, 24 Oct 2012 12:14:11 +0200 From: Gert Doering <[email protected]> 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
pgpSL2jC7H5pH.pgp
Description: PGP signature
_______________________________________________ smokeping-users mailing list [email protected] https://lists.oetiker.ch/cgi-bin/listinfo/smokeping-users
