Commit Diff
Diff:
28c8ba3dab2d8af2b24899f5f96a53939f6dc43f
3070fbd313f0a8affd7cc622adfd25274fc2b672
Commit:
3070fbd313f0a8affd7cc622adfd25274fc2b672
Tree:
168282b9ce33c012e0f31382e0c7a8e077097021
Author:
Peter J. Philipp <pjp@delphinusdns.org>
Committer:
Peter J. Philipp <pjp@delphinusdns.org>
Date:
Tue Jan 5 08:42:57 2021 UTC
Message:
fix the last commit, it was too slow, this speeds it up by identifying what domainname is used as glue with match_zoneglue() because those are identified with 2 different zone numbers
blob - ebb046f6ed371aafa6bd4802d648dabbbb498bb5
blob + ba2ca44d40c207b1706434a1da32702a4b99f6b6
--- db.c
+++ db.c
@@ -69,7 +69,7 @@ void flag_rr(struct rbtree *rbt);
int expire_rr(ddDB *, char *, int, u_int16_t, time_t);
int expire_db(ddDB *, int);
void remove_rbt(struct rbtree *);
-uint32_t match_zonenumber(struct rbtree *rbt, uint32_t);
+uint32_t match_zoneglue(struct rbtree *rbt);
extern void dolog(int, char *, ...);
@@ -559,17 +559,26 @@ remove_rbt(struct rbtree *rbt)
return;
}
+/*
+ * MATCH_ZONEGLUE - match if there is over 1 links to different zones inside
+ * this rbt, this means that there is glue information
+ * out there...
+ */
+
uint32_t
-match_zonenumber(struct rbtree *rbt, uint32_t zonenumberx)
+match_zoneglue(struct rbtree *rbt)
{
struct rrset *rrset = NULL;
struct rr *rt1 = NULL;
+ uint32_t lastzonenum = (uint32_t)-1;
TAILQ_FOREACH(rrset, &rbt->rrset_head, entries) {
if (rrset) {
TAILQ_FOREACH(rt1, &rrset->rr_head, entries) {
- if (rt1->zonenumber == zonenumberx)
+ if (lastzonenum != (uint32_t)-1 &&
+ lastzonenum != rt1->zonenumber)
return 1;
+ lastzonenum = rt1->zonenumber;
}
}
}
blob - 34f1f4bbab764951d6095e350eca53ff17dbbe49
blob + b70e0d90548ac654125baf0ba76db29d1be589c2
--- zone.c
+++ zone.c
@@ -71,7 +71,7 @@ extern void dolog(int, char *, ...);
extern char * dns_label(char *, int *);
extern void ddd_shutdown(void);
extern int dn_contains(char *name, int len, char *anchorname, int alen);
-extern uint32_t match_zonenumber(struct rbtree *, uint32_t);
+extern uint32_t match_zoneglue(struct rbtree *);
extern int debug, verbose;
extern uint32_t zonenumber;
@@ -123,26 +123,59 @@ populate_zone(ddDB *db)
struct rbtree *rbt = NULL;
char *p;
int plen;
- uint32_t i;
+ RB_FOREACH(walk, domaintree, &db->head) {
+ rbt = (struct rbtree *)walk->data;
+ if (rbt == NULL) {
+ continue;
+ }
- for (i = 0; i < zonenumber; i++) {
- RB_FOREACH(walk, domaintree, &db->head) {
- rbt = (struct rbtree *)walk->data;
- if (rbt == NULL) {
- continue;
+ res = NULL;
+ for (plen = rbt->zonelen, p = rbt->zone; plen > 0;
+ p++, plen--) {
+ memcpy(find.name, p, plen);
+ find.namelen = plen;
+ if ((res = RB_FIND(zonetree, &zonehead, &find)) != NULL) {
+ break;
}
- if (match_zonenumber(rbt, i) == 0)
- continue;
+ plen -= *p;
+ p += *p;
+ }
+ if (res == NULL)
+ continue;
+
+ TAILQ_FOREACH(wep, &res->walkhead, walk_entry) {
+ if (wep->rbt == rbt)
+ break;
+ }
+
+ if (wep)
+ continue;
+
+ if ((wep = malloc(sizeof(struct walkentry))) == NULL) {
+ dolog(LOG_INFO, "malloc: %s\n", strerror(errno));
+ ddd_shutdown();
+ sleep(10);
+ exit(1);
+ }
+
+ wep->rbt = rbt;
+ /* wep->zonenumber = res->zonenumber; */
+ TAILQ_INSERT_TAIL(&res->walkhead, wep, walk_entry);
+
+ /* there is a parent zone that has another entry */
+ if (match_zoneglue(rbt)) {
res = NULL;
- for (plen = rbt->zonelen, p = rbt->zone; plen > 0;
- p++, plen--) {
+
+ plen -= *p; /* advance to higher parent */
+ p += *p;
+
+ for (p++, plen--; plen > 0; p++, plen--) {
memcpy(find.name, p, plen);
find.namelen = plen;
- if (((res = RB_FIND(zonetree, &zonehead, &find)) != NULL) &&
- (i == res->zonenumber)) {
+ if ((res = RB_FIND(zonetree, &zonehead, &find)) != NULL) {
break;
}
repomaster@centroid.eu