Ok, thanks Willy. The news path in attachment. David, can you test the FreeBSD build ? The patch is tested and validated for Linux.
Thierry On Fri, 23 Dec 2016 14:50:38 +0100 Willy Tarreau <[email protected]> wrote: > On Fri, Dec 23, 2016 at 02:37:13PM +0100, [email protected] wrote: > > thanks Willy for the idea. I will write a patch ASAP, but. why a 32bits > > cast and not a 64 bit cast ? > > First because existing code uses this already and it works. Second because > the 64-bit check might be more expensive for 32-bit platforms than the > double 32-bit check is for 64-bit platforms (though that's still to be > verified in the assembly code, as some compilers manage to assign register > pairs correctly). > > Willy >
>From d5995d34504daf2a66a6b046ecd5da0477f6036e Mon Sep 17 00:00:00 2001 From: Thierry FOURNIER <[email protected]> Date: Fri, 23 Dec 2016 17:03:25 +0100 Subject: [PATCH] BUILD: lua: build failed on FreeBSD. X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 s6_addr* fields are not available in the userland on BSD systems in general. bug reported by David Carlier needs backport to 1.7.x --- src/hlua_fcn.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/hlua_fcn.c b/src/hlua_fcn.c index 5ac533a..58905d7 100644 --- a/src/hlua_fcn.c +++ b/src/hlua_fcn.c @@ -1016,14 +1016,16 @@ int hlua_match_addr(lua_State *L) return 1; } } else { - if (((addr1->addr.v6.ip.s6_addr32[0] & addr2->addr.v6.mask.s6_addr32[0]) == - (addr2->addr.v6.ip.s6_addr32[0] & addr1->addr.v6.mask.s6_addr32[0])) && - ((addr1->addr.v6.ip.s6_addr32[1] & addr2->addr.v6.mask.s6_addr32[1]) == - (addr2->addr.v6.ip.s6_addr32[1] & addr1->addr.v6.mask.s6_addr32[1])) && - ((addr1->addr.v6.ip.s6_addr32[2] & addr2->addr.v6.mask.s6_addr32[2]) == - (addr2->addr.v6.ip.s6_addr32[2] & addr1->addr.v6.mask.s6_addr32[2])) && - ((addr1->addr.v6.ip.s6_addr32[3] & addr2->addr.v6.mask.s6_addr32[3]) == - (addr2->addr.v6.ip.s6_addr32[3] & addr1->addr.v6.mask.s6_addr32[3]))) { + int i; + + for (i = 0; i < 16; i += 4) { + if ((*(uint32_t *)&addr1->addr.v6.ip.s6_addr[i] & + *(uint32_t *)&addr2->addr.v6.mask.s6_addr[i]) != + (*(uint32_t *)&addr2->addr.v6.ip.s6_addr[i] & + *(uint32_t *)&addr1->addr.v6.mask.s6_addr[i])) + break; + } + if (i == 16) { lua_pushboolean(L, 1); return 1; } -- 1.7.10.4

