aboutsummaryrefslogtreecommitdiffstats
path: root/main/gdnsd
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2012-05-28 10:20:10 +0300
committerTimo Teräs <timo.teras@iki.fi>2012-05-28 10:20:10 +0300
commit0425feadb3965f05b8ed48edb0af3e1c76256b5c (patch)
treecf9aa24d546ccc58f6dc5d0950f871ee8cb2fccd /main/gdnsd
parent939241b58edee52d1dd308d78a23c00ae3550409 (diff)
downloadaports-0425feadb3965f05b8ed48edb0af3e1c76256b5c.tar.bz2
aports-0425feadb3965f05b8ed48edb0af3e1c76256b5c.tar.xz
main/gdnsd: cherry pick some improvements from bug tracker
* faster startup time with cities geodb * more flexible autodc support
Diffstat (limited to 'main/gdnsd')
-rw-r--r--main/gdnsd/APKBUILD6
-rw-r--r--main/gdnsd/geoip-autodc.patch45
-rw-r--r--main/gdnsd/geoip-speedup.patch101
3 files changed, 151 insertions, 1 deletions
diff --git a/main/gdnsd/APKBUILD b/main/gdnsd/APKBUILD
index a2ad148b8e..ef6935d70c 100644
--- a/main/gdnsd/APKBUILD
+++ b/main/gdnsd/APKBUILD
@@ -2,7 +2,7 @@
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=gdnsd
pkgver=1.6.7
-pkgrel=0
+pkgrel=1
pkgdesc="Geographic Authoritative DNS server"
url="http://code.google.com/p/gdnsd/"
arch="all"
@@ -13,6 +13,8 @@ makedepends="libev-dev libcap-dev"
install="$pkgname.pre-install"
subpackages="$pkgname-dev $pkgname-doc"
source="http://gdnsd.googlecode.com/files/gdnsd-$pkgver.tar.xz
+ geoip-autodc.patch
+ geoip-speedup.patch
gdnsd.initd"
_builddir="$srcdir"/gdnsd-$pkgver
@@ -46,4 +48,6 @@ package() {
}
md5sums="86b95b6533d2f73174f21feb34a5cf3f gdnsd-1.6.7.tar.xz
+7955bf52d394862512ae6c000c8b6242 geoip-autodc.patch
+7fb697653b8295322e53492f9051e831 geoip-speedup.patch
00f2838e0908effaaa2f6e6a1699f25b gdnsd.initd"
diff --git a/main/gdnsd/geoip-autodc.patch b/main/gdnsd/geoip-autodc.patch
new file mode 100644
index 0000000000..ec88491a15
--- /dev/null
+++ b/main/gdnsd/geoip-autodc.patch
@@ -0,0 +1,45 @@
+From: Timo TerÃs <timo.teras@iki.fi>
+
+plugin_geoip: allow datacenters to be omitted from auto_dc_coords
+
+sometimes we might need a datacenter to be accessible only via
+overrides of map (via specific territory) or via nets (only
+specific nets). this makes those datacenters to be sorted always
+last.
+
+http://code.google.com/p/gdnsd/issues/detail?id=17
+
+diff --git a/plugins/meta/libgdmaps/gdmaps.c b/plugins/meta/libgdmaps/gdmaps.c
+index b49bfa5..9d20351 100644
+--- a/plugins/meta/libgdmaps/gdmaps.c
++++ b/plugins/meta/libgdmaps/gdmaps.c
+@@ -180,13 +180,13 @@ static dcinfo_t* dcinfo_new(const vscf_data_t* dc_cfg, const vscf_data_t* dc_aut
+ if(!vscf_is_hash(dc_auto_cfg))
+ log_fatal("plugin_geoip: map '%s': auto_dc_coords must be a key-value hash", map_name);
+ const unsigned num_auto = vscf_hash_get_len(dc_auto_cfg);
+- if(num_auto != num_dcs)
+- log_fatal("plugin_geoip: map '%s': auto_dc_coords hash must contain one entry for each datacenter in 'datacenters'", map_name);
+- info->coords = malloc(num_auto * 2 * sizeof(double));
++ info->coords = malloc(num_dcs * 2 * sizeof(double));
++ for(unsigned i = 0; i < 2*num_dcs; i++)
++ info->coords[i] = NAN;
+ for(unsigned i = 0; i < num_auto; i++) {
+ const char* dcname = vscf_hash_get_key_byindex(dc_auto_cfg, i, NULL);
+ unsigned dcidx;
+- for(dcidx = 0; dcidx < info->num_dcs; dcidx++) {
++ for(dcidx = 0; dcidx < num_dcs; dcidx++) {
+ if(!strcmp(dcname, info->names[dcidx]))
+ break;
+ }
+@@ -438,7 +438,10 @@ static unsigned dclists_city_auto_map(dclists_t* lists, const char* map_name, co
+ double dists[store_len];
+ for(unsigned i = 0; i < num_dcs; i++) {
+ const unsigned c_offs = i * 2;
+- dists[i + 1] = haversine(lat_rad, lon_rad, coords[c_offs], coords[c_offs + 1]);
++ if (coords[c_offs] != NAN)
++ dists[i + 1] = haversine(lat_rad, lon_rad, coords[c_offs], coords[c_offs + 1]);
++ else
++ dists[i + 1] = +INFINITY;
+ }
+
+ // Given the relatively small num_dcs of most configs,
diff --git a/main/gdnsd/geoip-speedup.patch b/main/gdnsd/geoip-speedup.patch
new file mode 100644
index 0000000000..3816df44ed
--- /dev/null
+++ b/main/gdnsd/geoip-speedup.patch
@@ -0,0 +1,101 @@
+From: Timo TerÃs <timo.teras@iki.fi>
+
+plugin_geoip: speed up cities database loading
+
+Gives over 10x speed-up in loading the large cities database.
+http://code.google.com/p/gdnsd/issues/detail?id=18
+
+diff --git a/plugins/meta/libgdmaps/gdmaps.c b/plugins/meta/libgdmaps/gdmaps.c
+index 9d20351..6bbc410 100644
+--- a/plugins/meta/libgdmaps/gdmaps.c
++++ b/plugins/meta/libgdmaps/gdmaps.c
+@@ -1215,6 +1215,12 @@ typedef struct {
+ } gdmap_t;
+
+ typedef struct {
++ unsigned offset;
++ unsigned dclist;
++} offset_cache_item_t;
++#define OFFSET_CACHE_SIZE (1 << 18)
++
++typedef struct {
+ char* pathname;
+ uint8_t* data;
+ const fips_t* fips;
+@@ -1223,6 +1229,8 @@ typedef struct {
+ int type;
+ unsigned base;
+ bool ipv6;
++
++ offset_cache_item_t *offset_cache[OFFSET_CACHE_SIZE];
+ } geoip_db_t;
+
+ F_NONNULL
+@@ -1230,7 +1238,7 @@ static int geoip_db_close(geoip_db_t* db);
+ F_NONNULLX(1)
+ static geoip_db_t* geoip_db_open(const char* pathname, const fips_t* fips, const char* map_name, const bool city_required);
+ F_NONNULLX(1, 2, 3)
+-static int geoip_tree_xlate(const gdmap_t* gdmap, ntree_t* tree, const geoip_db_t* db, const geoip_db_t* db_v4o);
++static int geoip_tree_xlate(const gdmap_t* gdmap, ntree_t* tree, geoip_db_t* db, geoip_db_t* db_v4o);
+
+ F_NONNULL
+ static ntree_t* gdmap_make_tree(const gdmap_t* gdmap, const dclists_t* old_dclists) {
+@@ -1957,10 +1965,18 @@ static unsigned city_lookup_dclist(const geoip_db_t* db, unsigned int offs, cons
+ }
+
+ F_NONNULL
+-static unsigned get_dclist(const gdmap_t* gdmap, const ntree_t* tree, const geoip_db_t* db, const unsigned int offset) {
++static unsigned get_dclist(const gdmap_t* gdmap, const ntree_t* tree, geoip_db_t* db, const unsigned int offset) {
+ dmn_assert(gdmap); dmn_assert(db);
+
+ unsigned dclist = 0;
++ unsigned bucket_size = 0;
++ unsigned ndx = offset % OFFSET_CACHE_SIZE;
++
++ if (db->offset_cache[ndx]) {
++ for (bucket_size = 0; db->offset_cache[ndx][bucket_size].offset; bucket_size++)
++ if (db->offset_cache[ndx][bucket_size].offset == offset)
++ return db->offset_cache[ndx][bucket_size].dclist;
++ }
+
+ switch(db->type) {
+ case GEOIP_CITY_EDITION_REV1_V6:
+@@ -1983,6 +1999,11 @@ static unsigned get_dclist(const gdmap_t* gdmap, const ntree_t* tree, const geoi
+ break;
+ }
+
++ db->offset_cache[ndx] = realloc(db->offset_cache[ndx], sizeof(offset_cache_item_t) * (bucket_size+2));
++ db->offset_cache[ndx][bucket_size].offset = offset;
++ db->offset_cache[ndx][bucket_size].dclist = dclist;
++ db->offset_cache[ndx][bucket_size+1].offset = 0;
++
+ return dclist;
+ }
+
+@@ -1991,7 +2012,7 @@ static unsigned get_dclist(const gdmap_t* gdmap, const ntree_t* tree, const geoi
+ // C really needs a better macro/template idea :(
+ #define DEFUN_TREE_XLATE(IPVN, IPTYPE, IPZERO, BITDEPTH, V4ROOT_CODE, SKIP_CODE) \
+ F_NONNULL \
+-static int geoip_tree_xlate_ ## IPVN(const gdmap_t* gdmap, ntree_t* tree, const geoip_db_t* db) { \
++static int geoip_tree_xlate_ ## IPVN(const gdmap_t* gdmap, ntree_t* tree, geoip_db_t* db) { \
+ dmn_assert(gdmap); dmn_assert(tree); dmn_assert(db); \
+ struct { \
+ int depth; \
+@@ -2107,7 +2128,7 @@ DEFUN_TREE_XLATE(v4, uint32_t, 0, 32, ;, ;)
+
+ DEFUN_TREE_XLATE(v6, struct in6_addr, ip6_zero, 128, V6_V4ROOT_CODE, V6_SKIP_CODE)
+
+-static int geoip_tree_xlate(const gdmap_t* gdmap, ntree_t* tree, const geoip_db_t* db, const geoip_db_t* db_v4o) {
++static int geoip_tree_xlate(const gdmap_t* gdmap, ntree_t* tree, geoip_db_t* db, geoip_db_t* db_v4o) {
+ dmn_assert(gdmap); dmn_assert(tree); dmn_assert(db);
+
+ log_info("plugin_geoip: map '%s': Processing GeoIP database '%s'...", gdmap->name, gdmap->geoip_path);
+@@ -2145,6 +2166,8 @@ static int geoip_db_close(geoip_db_t* db) {
+ }
+ }
+
++ for (unsigned i = 0; i < OFFSET_CACHE_SIZE; i++)
++ free(db->offset_cache[i]);
+ if(db->pathname)
+ free(db->pathname);
+ free(db);