42 #include <sys/socket.h>
44 static const char* notify_str =
"notify";
46 static void notify_handle_zone(
netio_type* netio,
77 if(t > notify_time(notify) + 10) {
78 time_t extra = t - notify_time(notify);
79 time_t base = extra*9/10;
80 t = notify_time(notify) + base +
81 random()%(extra-base);
99 if (!xfrhandler || !zone) {
105 "allocator_create() failed", notify_str);
111 " allocator_alloc() failed", notify_str);
162 notify_set_timer(notify, notify_time(notify));
201 notify_str, zone->
name);
229 ods_log_debug(
"[%s] zone %s no more secondaries, disable notify",
230 notify_str, zone->
name);
231 notify_disable(notify);
245 ssize_t received = 0;
252 if (received == -1) {
253 ods_log_error(
"[%s] unable to read packet: recvfrom() failed fd %d "
254 "(%s)", notify_str, notify->
handler.
fd, strerror(errno));
281 ods_log_error(
"[%s] zone %s received bad notify reply opcode/qr",
282 notify_str, zone->
name);
287 notify_str, zone->
name);
299 ods_log_debug(
"[%s] zone %s secondary %s notify reply ok", notify_str,
312 struct sockaddr_storage to;
313 socklen_t to_len = 0;
328 fd = socket(family, SOCK_DGRAM, IPPROTO_UDP);
341 (
struct sockaddr*)&to, to_len);
368 ods_log_error(
"[%s] unable to sign notify: tsig unknown algorithm "
385 ods_log_debug(
"[%s] tsig append rr to notify id=%u", notify_str,
426 notify_tsig_sign(notify, xfrhandler->
packet);
431 ods_log_error(
"[%s] unable to send notify retry %u for zone %s to "
432 "%s: notify_send_udp() failed", notify_str, notify->
retry,
436 ods_log_verbose(
"[%s] notify retry %u for zone %s sent to %s", notify_str,
447 notify_handle_zone(
netio_type* ATTR_UNUSED(netio),
466 ods_log_debug(
"[%s] already waiting, skipping notify for zone %s",
467 notify_str, zone->
name);
475 if (notify_udp_read_packet(notify)) {
476 if (notify_handle_reply(notify)) {
506 notify_update_soa(
notify_type* notify, ldns_rr* soa)
512 ldns_rr_free(notify->
soa);
546 notify_update_soa(notify, soa);
548 ods_log_debug(
"[%s] zone %s already on waiting list", notify_str,
553 notify_setup(notify);
570 ods_log_debug(
"[%s] zone %s notify on waiting list", notify_str,
593 ldns_rr_free(notify->
soa);