<div dir="ltr">Hi,<div><br></div><div>I installed Varnish 3.0.3 from <a href="http://repo.varnish-cache.org">repo.varnish-cache.org</a> on Debian Squeeze.</div><div>I got the plugin from <a href="https://www.varnish-cache.org/trac/wiki/GeoipUsingInlineC">https://www.varnish-cache.org/trac/wiki/GeoipUsingInlineC</a> ( GeoIP-plugin-2.tar.gz ).</div>
<div><br></div><div>The plugin seems to work on its own :</div><div><div># make test</div><div>gcc geoip_plugin_test.c -o geoip_plugin_test -ldl</div><div>LD_LIBRARY_PATH=$PWD ./geoip_plugin_test</div><div>GeoIP plugin loaded successfully.</div>
<div>Testing IPs:</div><div>195.110.128.11 => IT (OK)</div><div>157.166.224.25 => US (OK)</div><div>212.58.224.138 => GB (OK)</div><div>80.91.37.210 => NO (OK)</div><div>192.168.0.1 => Unknown (OK)</div><div>
(null) => Unknown (OK)</div></div><div><br></div><div>However, Varnish fails to start :</div><div><div># /etc/init.d/varnish start</div><div>Starting HTTP accelerator: varnishd failed!</div><div>Message from C-compiler:</div>
<div>./vcl.IoMQyW5q.c: In function ‘VGC_function_vcl_hash’:</div><div>./vcl.IoMQyW5q.c:569: warning: implicit declaration of function ‘VRT_l_req_hash’</div><div>Message from dlopen:</div><div>Compiled VCL program failed to load:</div>
<div> ./<a href="http://vcl.IoMQyW5q.so">vcl.IoMQyW5q.so</a>: undefined symbol: VRT_l_req_hash</div><div>Running dlopen failed, exit 1</div><div><br></div><div>VCL compilation failed</div></div><div><br></div><div><br></div>
<div>Any idea what could cause that ?</div><div>If not, any alternative that is known to work ?</div><div><br></div><div><br></div><div>Below is my default.vcl configuration (which is the file provided with the plugin, with just the correct path added) :</div>
<div><br></div><div>#################################</div><div><div># This block of inline C loads the library</div><div>C{</div><div> #include <dlfcn.h></div><div> #include <stdlib.h></div><div> #include <stdio.h></div>
<div><br></div><div>static const char* (*get_country_code)(char* ip) = NULL;</div><div><br></div><div>__attribute__((constructor)) void</div><div>load_module()</div><div>{</div><div> const char* symbol_name = "get_country_code";</div>
<div> const char* plugin_name = "/usr/local/lib/geoip_plugin.so";</div><div> void* handle = NULL;</div><div><br></div><div> handle = dlopen( plugin_name, RTLD_NOW );</div><div> if (handle != NULL) {</div>
<div> get_country_code = dlsym( handle, symbol_name );</div><div> if (get_country_code == NULL)</div><div> fprintf( stderr, "\nError: Could not load GeoIP plugin:\n%s\n\n", dlerror() );</div>
<div> else</div><div> printf( "GeoIP plugin loaded successfully.\n");</div><div> }</div><div> else</div><div> fprintf( stderr, "\nError: Could not load GeoIP plugin:\n%s\n\n", dlerror() );</div>
<div>}</div><div>}C</div><div><br></div><div># A sample backend declaration used for testing</div><div>backend default {</div><div> .host = "localhost";</div><div> .port = "8080";</div><div>}</div>
<div><br></div><div>sub vcl_hash {</div><div># This block of inline C adds the country code to the hash</div><div> C{</div><div> if (get_country_code)</div><div> VRT_l_req_hash(sp, (*get_country_code)( VRT_IP_string(sp, VRT_r_server_ip(sp))));</div>
<div> }C</div><div><br></div><div># Insert any custom hashing here</div><div><br></div><div>}</div></div><div><br></div><meta http-equiv="content-type" content="text/html; charset=utf-8"></div>