Skip to content
Snippets Groups Projects
Commit 556a19cf authored by Jan Hák's avatar Jan Hák Committed by Daniel Salzman
Browse files

knotd: expiration aborts transaction in progress

parent 363f9282
No related branches found
No related tags found
1 merge request!1725Zone expiration aborts transaction in progress
Pipeline #132371 passed
/* Copyright (C) 2022 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
/* Copyright (C) 2024 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -32,6 +32,11 @@ int event_expire(conf_t *conf, zone_t *zone)
log_zone_info(zone->name, "zone expired");
synchronize_rcu();
pthread_mutex_lock(&zone->cu_lock);
zone_control_clear(zone);
pthread_mutex_unlock(&zone->cu_lock);
knot_sem_wait(&zone->cow_lock);
zone_contents_deep_free(expired);
knot_sem_post(&zone->cow_lock);
......
$ORIGIN expire.
@ SOA dns1 hostmaster 2010111201 2 1 4 7200
NS dns1
dns1 A 192.0.2.1
#!/usr/bin/env python3
'''Test for automatic zone transaction abort when zone expires'''
from dnstest.libknot import libknot
from dnstest.test import Test
from dnstest.utils import *
def check_txn(server, zone, is_open):
ctl = libknot.control.KnotCtl()
ctl.connect(os.path.join(slave.dir, "knot.sock"))
ctl.send_block(cmd="zone-status", zone=zone, flags="B", filters="t")
resp = ctl.receive_block()
if is_open:
isset(resp[zone]["transaction"] == "open", "open transaction")
else:
isset(resp[zone]["transaction"] == "-", "no transaction")
ctl.send(libknot.control.KnotCtlType.END)
ctl.close()
def test_expire(master, slave, zone, manual_expiration):
slave.ctl("zone-refresh")
slave.zone_wait(zone)
master.stop()
slave.ctl("zone-begin expire")
check_txn(slave, zone[0].name, True)
slave.ctl("zone-set expire test TXT test")
if manual_expiration:
slave.ctl("-f zone-purge +expire expire")
else:
t.sleep(5)
try:
slave.ctl("zone-commit expire")
set_err("control txn not aborted")
except Exception:
pass
check_txn(slave, zone[0].name, False)
resp = slave.dig("test.expire", "TXT")
resp.check(rcode="SERVFAIL")
master.start()
t = Test()
master = t.server("knot")
slave = t.server("knot")
zone = t.zone("expire.", storage=".")
t.link(zone, master, slave)
t.start()
# Expire manually
test_expire(master, slave, zone, True)
# Expire by the SOA timer
test_expire(master, slave, zone, False)
t.end()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment