Commit 08ae9576 authored by Daniel Salzman's avatar Daniel Salzman Committed by Mark Karpilovskij

mod-geoip: bugfix, shared memory accross threads

parent 4e5753dd
......@@ -145,16 +145,6 @@ geodb_t *geodb_open(const char *filename)
#endif
}
geodb_data_t *geodb_alloc_entries(uint16_t count)
{
#if HAVE_MAXMINDDB
MMDB_entry_data_s *entries = calloc(count, sizeof(MMDB_entry_data_s));
return entries;
#else
return NULL;
#endif
}
void geodb_close(geodb_t *geodb)
{
#if HAVE_MAXMINDDB
......
......@@ -57,8 +57,6 @@ bool geodb_available(void);
geodb_t *geodb_open(const char *filename);
geodb_data_t *geodb_alloc_entries(uint16_t count);
void geodb_close(geodb_t *geodb);
int geodb_query(geodb_t *geodb, geodb_data_t *entries, struct sockaddr *remote,
......
......@@ -89,7 +89,6 @@ typedef struct {
bool dnssec;
geodb_t *geodb;
geodb_data_t *entries;
geodb_path_t paths[GEODB_MAX_DEPTH];
uint16_t path_count;
} geoip_ctx_t;
......@@ -549,7 +548,6 @@ static void free_geoip_ctx(geoip_ctx_t *ctx)
free(ctx->paths[i].path[j]);
}
}
free(ctx->entries);
free(ctx);
}
......@@ -617,7 +615,9 @@ static knotd_in_state_t geoip_process(knotd_in_state_t state, knot_pkt_t *pkt,
}
netmask = best_prefix;
} else if (ctx->mode == MODE_GEODB) {
int ret = geodb_query(ctx->geodb, ctx->entries, (struct sockaddr *)remote,
geodb_data_t entries[ctx->path_count];
int ret = geodb_query(ctx->geodb, entries, (struct sockaddr *)remote,
ctx->paths, ctx->path_count, &netmask);
// MMDB may supply IPv6 prefixes even for IPv4 address, see man libmaxminddb.
if (remote->ss_family == AF_INET && netmask > 32) {
......@@ -633,7 +633,7 @@ static knotd_in_state_t geoip_process(knotd_in_state_t state, knot_pkt_t *pkt,
for (int i = 0; i < data->count; i++) {
geo_view_t *view = &data->views[i];
if ((rr == NULL || view->geodepth > best_depth) &&
remote_in_geo(view->geodata, view->geodata_len, view->geodepth, ctx->entries)) {
remote_in_geo(view->geodata, view->geodata_len, view->geodepth, entries)) {
for (int j = 0; j < view->count; j++) {
if (view->rrsets[j].type == qtype) {
best_depth = view->geodepth;
......@@ -726,13 +726,6 @@ int geoip_load(knotd_mod_t *mod)
}
}
knotd_conf_free(&conf);
// Allocate space for query entries.
ctx->entries = geodb_alloc_entries(ctx->path_count);
if (ctx->entries == NULL) {
free_geoip_ctx(ctx);
return KNOT_ENOMEM;
}
}
// Is DNSSEC used on this zone?
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment