Commit 0e8ec189 authored by Marek Vavruša's avatar Marek Vavruša

events: removed reimplemented code

parent 54256d16
......@@ -50,7 +50,7 @@ typedef struct remote_cmdargs_t {
typedef int (*remote_cmdf_t)(server_t*, remote_cmdargs_t*);
/*! \brief Callback prototype for per-zone operations. */
typedef int (remote_zonef_t)(server_t*, const zone_t *);
typedef int (remote_zonef_t)(server_t*, zone_t *);
/*! \brief Remote command table item. */
typedef struct remote_cmd_t {
......@@ -114,31 +114,29 @@ static int remote_rdata_apply(server_t *s, remote_cmdargs_t* a, remote_zonef_t *
}
/*! \brief Zone refresh callback. */
static int remote_zone_refresh(server_t *server, const zone_t *zone)
static int remote_zone_refresh(server_t *server, zone_t *zone)
{
if (!server || !zone) {
return KNOT_EINVAL;
}
#warning Implement me (schedule zone refresh)
zone_events_schedule(zone, ZONE_EVENT_REFRESH, ZONE_EVENT_NOW);
return KNOT_EOK;
}
/*! \brief Zone flush callback. */
static int remote_zone_flush(server_t *server, const zone_t *zone)
static int remote_zone_flush(server_t *server, zone_t *zone)
{
if (!server || !zone) {
return KNOT_EINVAL;
}
#warning Implement me (schedule zone file flush)
zone_events_schedule(zone, ZONE_EVENT_FLUSH, ZONE_EVENT_NOW);
return KNOT_EOK;
}
/*! \brief Sign zone callback. */
static int remote_zone_sign(server_t *server, const zone_t *zone)
static int remote_zone_sign(server_t *server, zone_t *zone)
{
if (!server || !zone) {
return KNOT_EINVAL;
......@@ -340,7 +338,8 @@ static int remote_c_refresh(server_t *s, remote_cmdargs_t* a)
dbg_server("remote: %s\n", __func__);
if (a->argc == 0) {
dbg_server_verb("remote: refreshing all zones\n");
knot_zonedb_foreach(s->zone_db, zones_schedule_refresh, ZONE_EVENT_NOW);
knot_zonedb_foreach(s->zone_db, zone_events_schedule,
ZONE_EVENT_REFRESH, ZONE_EVENT_NOW);
return KNOT_EOK;
}
......
......@@ -51,11 +51,12 @@ int internet_notify(knot_pkt_t *pkt, struct query_data *qdata)
}
/* RFC1996 require SOA question. */
zone_t *zone = (zone_t *)qdata->zone;
NS_NEED_QTYPE(qdata, KNOT_RRTYPE_SOA, KNOT_RCODE_FORMERR);
/* Check valid zone, transaction security. */
NS_NEED_ZONE(qdata, KNOT_RCODE_NOTAUTH);
NS_NEED_AUTH(qdata->zone->notify_in, qdata);
NS_NEED_AUTH(zone->notify_in, qdata);
/* Reserve space for TSIG. */
knot_pkt_reserve(pkt, tsig_wire_maxsize(qdata->sign.tsig_key));
......@@ -73,19 +74,10 @@ int internet_notify(knot_pkt_t *pkt, struct query_data *qdata)
}
}
int next_state = NS_PROC_FAIL;
/* Incoming NOTIFY expires REFRESH timer and renews EXPIRE timer. */
int ret = zones_schedule_refresh((zone_t *)qdata->zone, ZONE_EVENT_NOW);
zone_events_schedule(zone, ZONE_EVENT_REFRESH, ZONE_EVENT_NOW);
/* Format resulting log message. */
if (ret != KNOT_EOK) {
next_state = NS_PROC_NOOP; /* RFC1996: Ignore. */
NOTIFY_LOG(LOG_ERR, "%s", knot_strerror(ret));
} else {
next_state = NS_PROC_DONE;
NOTIFY_LOG(LOG_INFO, "received serial %u.", serial);
}
return next_state;
NOTIFY_LOG(LOG_INFO, "received serial %u.", serial);
return NS_PROC_DONE;
}
This diff is collapsed.
......@@ -109,41 +109,6 @@ int xfrin_transfer_needed(const zone_contents_t *zone,
/*----------------------------------------------------------------------------*/
int xfrin_create_soa_query(const zone_t *zone, knot_pkt_t *pkt)
{
return knot_pkt_put_question(pkt, zone->name, KNOT_CLASS_IN, KNOT_RRTYPE_SOA);
}
/*----------------------------------------------------------------------------*/
int xfrin_create_axfr_query(const zone_t *zone, knot_pkt_t *pkt)
{
return knot_pkt_put_question(pkt, zone->name, KNOT_CLASS_IN, KNOT_RRTYPE_AXFR);
}
/*----------------------------------------------------------------------------*/
int xfrin_create_ixfr_query(const zone_t *zone, knot_pkt_t *pkt)
{
if (zone->contents == NULL) {
return KNOT_EINVAL;
}
int ret = knot_pkt_put_question(pkt, zone->name, KNOT_CLASS_IN, KNOT_RRTYPE_IXFR);
if (ret != KNOT_EOK) {
return ret;
}
/* Add SOA RR to authority section for IXFR. */
zone_node_t *apex = zone->contents->apex;
knot_rrset_t soa = node_rrset(apex, KNOT_RRTYPE_SOA);
knot_pkt_begin(pkt, KNOT_AUTHORITY);
ret = knot_pkt_put(pkt, COMPR_HINT_QNAME, &soa, 0);
return ret;
}
/*----------------------------------------------------------------------------*/
static int xfrin_check_tsig(knot_pkt_t *packet, knot_ns_xfr_t *xfr,
int tsig_req)
{
......
......@@ -62,46 +62,6 @@ typedef enum xfrin_transfer_result {
int xfrin_transfer_needed(const zone_contents_t *zone,
knot_pkt_t *soa_response);
/*!
* \brief Creates normal query for the given zone name and the SOA type.
*
* \param zone Zone for which a query should be created.
* \param pkt Packet to be written.
*
* \retval KNOT_EOK
* \retval KNOT_ESPACE
* \retval KNOT_ERROR
*/
int xfrin_create_soa_query(const zone_t *zone, knot_pkt_t *pkt);
/*!
* \brief Creates normal query for the given zone name and the AXFR type.
*
* \param zone Zone for which a query should be created.
* \param pkt Packet to be written.
*
* \todo Parameter use_tsig probably not needed.
*
* \retval KNOT_EOK
* \retval KNOT_ESPACE
* \retval KNOT_ERROR
*/
int xfrin_create_axfr_query(const zone_t *zone, knot_pkt_t *pkt);
/*!
* \brief Creates normal query for the given zone name and the IXFR type.
*
* \param zone Zone for which a query should be created.
* \param pkt Packet to be written.
*
* \todo Parameter use_tsig probably not needed.
*
* \retval KNOT_EOK
* \retval KNOT_ESPACE
* \retval KNOT_ERROR
*/
int xfrin_create_ixfr_query(const zone_t *zone, knot_pkt_t *pkt);
/*!
* \brief Processes one incoming packet of AXFR transfer by updating the given
* zone.
......
......@@ -694,99 +694,6 @@ void zone_events_start(zone_t *zone)
}
/* ------------ Legacy API to be converted (not functional now) ------------- */
#warning TODO: vvv legacy API to be converted vvv
int zones_schedule_refresh(zone_t *zone, int64_t timeout)
{
if (!zone) {
return KNOT_EINVAL;
}
#warning TODO: reimplement schedule_refresh
#if 0
/* Cancel REFRESH/EXPIRE timer. */
// evsched_cancel(zone->xfr_in.expire);
// evsched_cancel(zone->xfr_in.timer);
/* Check XFR/IN master server. */
pthread_mutex_lock(&zone->lock);
rcu_read_lock();
if (zone_master(zone) != NULL) {
knot_rdataset_t *soa = zone_contents_soa(zone->contents);
/* Schedule EXPIRE timer. */
if (zone->contents != NULL) {
int64_t expire_tmr = knot_soa_expire(soa);
// Allow for timeouts. Otherwise zones with very short
// expiry may expire before the timeout is reached.
expire_tmr += 2 * (conf()->max_conn_idle * 1000);
// evsched_schedule(zone->xfr_in.expire, expire_tmr);
}
/* Schedule REFRESH timer. */
if (timeout < 0) {
if (zone->contents) {
timeout = knot_soa_refresh(soa);
} else {
timeout = zone->xfr_in.bootstrap_retry;
}
}
// evsched_schedule(zone->xfr_in.timer, timeout);
}
rcu_read_unlock();
pthread_mutex_unlock(&zone->lock);
#endif
return KNOT_EOK;
}
int zones_schedule_notify(zone_t *zone, server_t *server)
{
if (!zone) {
return KNOT_EINVAL;
}
#warning TODO: reimplement schedule_notify
#if 0
/* Do not issue NOTIFY queries if stub. */
if (!zone->contents) {
return KNOT_EOK;
}
/* Schedule NOTIFY to slaves. */
conf_zone_t *cfg = zone->conf;
conf_remote_t *r = 0;
WALK_LIST(r, cfg->acl.notify_out) {
/* Fetch remote. */
conf_iface_t *cfg_if = r->remote;
/* Create request. */
knot_ns_xfr_t *rq = xfr_task_create(zone, XFR_TYPE_NOTIFY, XFR_FLAG_UDP);
if (!rq) {
log_zone_error("Failed to create NOTIFY for '%s', "
"not enough memory.\n", cfg->name);
continue;
}
xfr_task_setaddr(rq, &cfg_if->addr, &cfg_if->via);
rq->tsig_key = cfg_if->key;
rq->data = (void *)((long)cfg->notify_retries);
#warning "XFR enqueue."
// if (xfr_enqueue(server->xfr, rq) != KNOT_EOK) {
// log_zone_error("Failed to enqueue NOTIFY for '%s'.\n",
// cfg->name);
// continue;
// }
}
#endif
return KNOT_EOK;
}
int zones_schedule_dnssec(zone_t *zone, time_t unixtime)
{
......
......@@ -106,31 +106,6 @@ void zone_events_start(struct zone_t *zone);
/* ------------ Legacy API to be converted (not functional now) ------------- */
#define REFRESH_DEFAULT -1
/*!
* \brief Update zone timers.
*
* REFRESH/RETRY/EXPIRE timers are updated according to SOA.
*
* \param zone Related zone.
* \param time Specific timeout or REFRESH_DEFAULT for default.
*
* \retval KNOT_EOK
* \retval KNOT_EINVAL
* \retval KNOT_ERROR
*/
int zones_schedule_refresh(struct zone_t *zone, int64_t timeout);
/*!
* \brief Schedule NOTIFY after zone update.
* \param zone Related zone.
*
* \retval KNOT_EOK
* \retval KNOT_ERROR
*/
int zones_schedule_notify(struct zone_t *zone, struct server_t *server);
/*!
* \brief Schedule DNSSEC event.
* \param zone Related zone.
......
......@@ -27,10 +27,6 @@
#include "knot/server/server.h"
#include "libknot/dname.h"
/* Constants */
#define XFRIN_BOOTSTRAP_DELAY 2000 /*!< AXFR bootstrap avg. delay */
/*- zone file status --------------------------------------------------------*/
/*!
......
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