[rbldnsd] Option -d (Bind dump) and wildcards: a small problem
Amos Jeffries
amos at treenetnz.com
Mon Dec 13 05:08:52 MSK 2004
----- Original Message -----
From: "Michael Tokarev" <mjt at tls.msk.ru>
To: "Small Daemon for DNSBLs" <rbldnsd at corpit.ru>
Sent: Monday, December 13, 2004 7:18 AM
Subject: Re: [rbldnsd] Option -d (Bind dump) and wildcards: a small problem
> Amos Jeffries wrote:
>> Okay,
>> I have been working on this a bit more.
>
> Thank you, Amos!
>
>> I can see what you mean by ugly.
>> It should now fill in the 'holes' so every IP that should be listed has at
>> least one relevant RR and exclusions are dealt with cleanly.
>>
>> The only potential problem I can see is if there is a /16 exclusion and a few
>> /32 listed inside it.
>> The /32 will appear as listed, the /16 itself and all implicit /24 below get
>> ignored nicely.
>
> What's a problem in that?
>
I thought maybe some people might want _all_ IPs inside an exclusion to be
excluded.
>> Code for the replacement ds_ip4set_dump function is at
>> http://eyezone.mine.nu/source/rbldnsd/rbldnsd_ip4set_dump.c
>> for checkup testing and approval.
>> I have debugged it as far as logic and compiling against 0.993.1 (29 Jul
>> 2004).
>
> Got it. Care to explain how it works? ;)
> Funny enouth, I can't seem to understand it.
Um, lets see.
By small_est_ below I mean, the first IP in the range. 127/8 is smaller than
127.1/16
Basically it breaks/wraps large listings /8,/16,/24 down into the largest
sub-ranges that don't include any smaller listings or exclusions.
It grabs the smallest IP out of any list and checks to see if there are any
ranges inside it.
If no sub-ranges are found it outputs the listing as normal
If there are sub-ranges
it processes them recursively, caching which ranges have been output
then outputs a list of smaller ranges for the broken parent.
cache[r] and list[r] variables are used to restrict the recursion to a
single-pass over the data and save time.
cache[r]
4x8 bit mask of ranges output so far.
restricts wrap output of RR to ranges that have not yet been output.
mainly used to stop output of exclusions.
list[r]
simulates 4 FIFO lists of IP ranges
GET_SMALLEST() returning NULL when the lists are empty
UNGET_SMALLEST handling loop 1-off problems
>
> I see at least one obvious problem with the code.
>
> Basically, what missing is the lengths of all the 4 arrays -- *this*
> should be in the loop condition and everywhere else. The dsd->e[]
> arrays aren't 0-terminated, but there's dsd->n[] wich specifies lengths
> of arrays, in numbers of elements. It should be easy to "fix" - either
> in the dumping routine by changing all the conditions from !list[X] to
> be list[X] < end[X], or by changing the reading routine to always add
> last "terminator" entry.
>
Oops. Beginners mistake at that.
That fix sounds right to me. I have added the LISTEND(X) tests to keep the
changes simple and in one part of the code.
AYJ
More information about the rbldnsd
mailing list