mm_free(mm, node);
}
+/**
+ * ptrlist_rem - remove all nodes with given pointer
+ * \p list: ptrlist
+ * \p val: pointer to remove
+ * \p mm: memory context
+ */
+void ptrlist_find_rem(list_t *list, void *val, knot_mm_t *mm)
+{
+ ptrnode_t *n, *nxt;
+ WALK_LIST_DELSAFE(n, nxt, *list) {
+ if (n->d == val) {
+ ptrlist_rem(n, mm);
+ }
+ }
+}
+
/**
* ptrlist_deep_free - free all nodes incl referenced data
* \p list: list nodes
ptrnode_t *ptrlist_add(list_t *, void *, knot_mm_t *);
void ptrlist_free(list_t *, knot_mm_t *);
void ptrlist_rem(ptrnode_t *node, knot_mm_t *mm);
+void ptrlist_find_rem(list_t *list, void *val, knot_mm_t *mm);
void ptrlist_deep_free(list_t *, knot_mm_t *);
typedef void (*ptrlist_free_cb)(void *);
ptrlist_add(&zone->internal_notify, subscribe, NULL);
}
+void zone_local_notify_unsubscribe(zone_t *zone, zone_t *subscribe)
+{
+ ptrlist_find_rem(&zone->internal_notify, subscribe, NULL);
+}
+
void zone_local_notify(zone_t *zone)
{
ptrnode_t *n;
int zone_dump_to_dir(conf_t *conf, zone_t *zone, const char *dir);
void zone_local_notify_subscribe(zone_t *zone, zone_t *subscribe);
+void zone_local_notify_unsubscribe(zone_t *zone, zone_t *subscribe);
void zone_local_notify(zone_t *zone);
int zone_set_master_serial(zone_t *zone, uint32_t serial);
return;
}
+ ptrnode_t *n;
+ WALK_LIST(n, zone->reverse_from) {
+ zone_local_notify_unsubscribe(n->d, zone);
+ }
+ ptrlist_free(&zone->reverse_from, NULL);
+
conf_val_t val = conf_zone_get(conf, C_REVERSE_GEN, zone->name);
while (val.code == KNOT_EOK) {
const knot_dname_t *forw_name = conf_dname(&val);
}
}
+static void unreg_reverse(zone_t *zone)
+{
+ ptrnode_t *n;
+ WALK_LIST(n, zone->reverse_from) {
+ zone_local_notify_unsubscribe(n->d, zone);
+ }
+ ptrlist_free(&zone->reverse_from, NULL);
+
+ WALK_LIST(n, zone->internal_notify) {
+ zone_t *reverse = n->d;
+ ptrlist_find_rem(&reverse->reverse_from, zone, NULL);
+ }
+ ptrlist_free(&zone->internal_notify, NULL);
+}
+
static bool same_group(zone_t *old_z, zone_t *new_z)
{
if (old_z->catalog_group == NULL || new_z->catalog_group == NULL) {
reg_reverse(conf, db_new, zone);
} else if (type & CONF_IO_TUNSET) {
zone_t *zone = knot_zonedb_find(db_new, name);
+ unreg_reverse(zone);
knot_zonedb_del(db_new, name);
catalog_generate_rem(zone, db_new);
} else {
break;
case CAT_UPD_REM:
zone = knot_zonedb_find(db_new, upd->member);
+ unreg_reverse(zone);
knot_zonedb_del(db_new, upd->member);
catalog_generate_rem(zone, db_new);
break;
from dnstest.utils import *
from dnstest.test import Test
+from dnstest.libknot import libknot
import random
+DYNAMIC = random.choice([False, True])
+
t = Test()
knot = t.server("knot")
r = knot.dig("8.2.0.192.in-addr.arpa.", "PTR")
r.check(rcode="NOERROR", rdata="dns1.example2.com.")
-knot.zones.pop(zones[2].name)
-knot.gen_confile()
-knot.reload()
+if DYNAMIC:
+ ctl = libknot.control.KnotCtl()
+ ctl.connect(os.path.join(knot.dir, "knot.sock"))
+ ctl.send_block(cmd="conf-begin")
+ resp = ctl.receive_block()
+ ctl.send_block(cmd="conf-unset", section="zone", item="domain", data=zones[2].name)
+ resp = ctl.receive_block()
+ ctl.send_block(cmd="conf-commit")
+ resp = ctl.receive_block()
+ ctl.send(libknot.control.KnotCtlType.END)
+ ctl.close()
+else:
+ knot.zones.pop(zones[2].name)
+ knot.gen_confile()
+ knot.reload()
t.sleep(5)
knot.update_zonefile(zones[0], version=2)
r = knot.dig("5.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.1.0.0.2.ip6.arpa.", "PTR")
r.check(rcode="NOERROR", rdata="added2.example.com.")
-knot.zones.pop(zones[0].name)
-knot.gen_confile()
-knot.reload()
+if DYNAMIC:
+ ctl = libknot.control.KnotCtl()
+ ctl.connect(os.path.join(knot.dir, "knot.sock"))
+ ctl.send_block(cmd="conf-begin")
+ resp = ctl.receive_block()
+ ctl.send_block(cmd="conf-unset", section="zone", item="domain", data=zones[0].name)
+ resp = ctl.receive_block()
+ ctl.send_block(cmd="conf-commit")
+ resp = ctl.receive_block()
+ ctl.send(libknot.control.KnotCtlType.END)
+ ctl.close()
+else:
+ knot.zones.pop(zones[0].name)
+ knot.gen_confile()
+ knot.reload()
t.sleep(5)
r = knot.dig("1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.1.0.0.2.ip6.arpa.", "PTR")