varnishcache-friends / libvmod-geoip2

Varnish VMOD to query MaxMind GeoIP2 DB files
BSD 2-Clause "Simplified" License
39 stars 17 forks source link

Compilation for varnish 6.0.12 lts #65

Closed rakotak closed 7 months ago

rakotak commented 7 months ago

Compiling this VMOD for varnish 6.0.12 (installed from the varnish repo not the default debian repo) fails with

/bin/bash ../libtool  --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I. -I..    -I/usr/include/varnish -I/usr/include/x86_64-linux-gnu  -g -O2 -MT libvmod_geoip2_la-vmod_geoip2.lo -MD -MP -MF .deps/libvmod_geoip2_la-vmod_geoip2.Tpo -c -o libvmod_geoip2_la-vmod_geoip2.lo `test -f 'vmod_geoip2.c' || echo './'`vmod_geoip2.c
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I.. -I/usr/include/varnish -I/usr/include/x86_64-linux-gnu -g -O2 -MT libvmod_geoip2_la-vmod_geoip2.lo -MD -MP -MF .deps/libvmod_geoip2_la-vmod_geoip2.Tpo -c vmod_geoip2.c  -fPIC -DPIC -o .libs/libvmod_geoip2_la-vmod_geoip2.o
vmod_geoip2.c: In function 'vslv':
vmod_geoip2.c:60:27: error: 'NO_VXID' undeclared (first use in this function); did you mean 'OA_VXID'?
   60 |                 VSLv(tag, NO_VXID, fmt, ap);
      |                           ^~~~~~~
      |                           OA_VXID
vmod_geoip2.c:60:27: note: each undeclared identifier is reported only once for each function it appears in
vmod_geoip2.c: In function 'vmod_geoip2__init':
vmod_geoip2.c:78:24: error: 'NO_VXID' undeclared (first use in this function); did you mean 'OA_VXID'?
   78 |         VSL(SLT_Debug, NO_VXID,
      |                        ^~~~~~~
      |                        OA_VXID

varnish version is:

varnishd -V
varnishd (varnish-6.0.12 revision 2c5044039fc39182af88e5b2df71f53fc47cba11)
Copyright (c) 2006 Verdens Gang AS
Copyright (c) 2006-2023 Varnish Software

I downloaded the sources for varnish 7.4.2 and 6.0.12 and compared bin/varnishd/cache/cache.h and it looks like NO_VXID is defined in the newest source only

ls -l /root/sources
drwxr-xr-x  8 root root    4096 Mar 15 11:22 libvmod-geoip2
drwxr-xr-x 10 1000 1000    4096 Nov 13 10:53 varnish-6.0.12
drwxr-xr-x 13 1000 1000    4096 Nov 13 09:13 varnish-7.4.2

grep NO_VXID varnish-*/bin/varnishd/cache/cache.h
varnish-7.4.2/bin/varnishd/cache/cache.h:#define NO_VXID ((struct vxids){0})
varnish-7.4.2/bin/varnishd/cache/cache.h:#define IS_NO_VXID(x) ((x).vxid == 0)

Can this VMOD still be compiled for varnish 6.x? (In CHANGES.md you state that support for 6.2, 6.3. and 6.4 is dropped but that is 2022)

rakotak commented 7 months ago

My bad for not reading that you have to switch to the main branch as suggested in a previous issue. I did

git checkout main
git pull

and then it compiled with

./autogen.sh
./configure 
make
make install

but when I try to import it in a .vcl I get:

Mar 15 11:57:59 localhost.localdomain varnishd[20117]: Error:
Mar 15 11:57:59 localhost.localdomain varnishd[20117]: Message from VCC-compiler:
Mar 15 11:57:59 localhost.localdomain varnishd[20117]: Incompatible VMOD geoip2
Mar 15 11:57:59 localhost.localdomain varnishd[20117]:         File name: /usr/lib/varnish/vmods/libvmod_geoip2.so
Mar 15 11:57:59 localhost.localdomain varnishd[20117]:         ABI mismatch, expected <Varnish 6.0.12 2c5044039fc39182af88e5b2df71f53fc47cba11>, got <[   [     "$VMOD",     "1.0"   ],   [     "$OBJ",     "geoip2",>
Mar 15 11:57:59 localhost.localdomain varnishd[20117]: >

Any suggestions?