On Fri, 23 Dec 2016 22:04:57 +0100
Willy Tarreau <[email protected]> wrote:

> On Fri, Dec 23, 2016 at 09:50:53PM +0100, [email protected] wrote:
> > On Fri, 23 Dec 2016 18:07:07 +0100
> > Willy Tarreau <[email protected]> wrote:
> > 
> > > On Fri, Dec 23, 2016 at 05:54:47PM +0100, [email protected] 
> > > wrote:
> > > > Thanks ! Willy, can you apply the patch ?
> > > 
> > > Done, thanks guys.
> > > 
> > > However Thierry my previous question still stands : what *real* type of 
> > > test
> > > is this supposed to validate ? Because in my opinion this test consisting 
> > > in
> > > matching that two networks are part of each other only validates that they
> > > are equal, or certain random cases where the smallest one happens to have
> > > zeroes where it matches the other one.
> > 
> > 
> > It is a comparaison of two networks. One of the network can be
> > condsidered as an IP (/32). The function returns true if one of the
> > network contains the other.
> 
> From what I remember from the code, it returns true if both of them
> contain each other, which is why I claim it cannot work. For example,
> 192.168.1.0/24 contains 192.168.1.10/32 but not the other way around.


I return true if the largest network contains the smaller. The order of
networks are not important.

I wrote this code a long time ago, I'm not remember exactly. Maybe I
wrote bullshit.

I write this code for testing:

    7 a = core.parse_addr("192.168.1.0/24")
    8 b = core.parse_addr("192.168.1.10/32")
    9 
   10 print_r(core.match_addr(a, b))
   11 print_r(core.match_addr(b, a))
   12 
   13 a = core.parse_addr("193.168.1.0/24")
   14 b = core.parse_addr("192.168.1.10/32")
   15 
   16 print_r(core.match_addr(a, b))
   17 print_r(core.match_addr(b, a))

The result is:

   (boolean) true
   (boolean) true
   (boolean) false
   (boolean) false

It is the expected result.

Thierry

Reply via email to