40 #include <sys/socket.h> 42 static const char* notify_str =
"notify";
44 static void notify_handle_zone(
netio_type* netio,
75 if(t > notify_time(notify) + 10) {
76 time_t extra = t - notify_time(notify);
77 time_t base = extra*9/10;
78 #ifdef HAVE_ARC4RANDOM_UNIFORM 79 t = notify_time(notify) + base +
80 arc4random_uniform(extra-base);
82 t = notify_time(notify) + base +
83 arc4random()%(extra-base);
85 t = notify_time(notify) + base +
86 random()%(extra-base);
105 if (!xfrhandler || !zone) {
111 "allocator_create() failed", notify_str);
117 " allocator_alloc() failed", notify_str);
168 notify_set_timer(notify, notify_time(notify));
207 notify_str, zone->
name);
235 ods_log_debug(
"[%s] zone %s no more secondaries, disable notify",
236 notify_str, zone->
name);
237 notify_disable(notify);
251 ssize_t received = 0;
258 if (received == -1) {
259 ods_log_error(
"[%s] unable to read packet: recvfrom() failed fd %d " 260 "(%s)", notify_str, notify->
handler.
fd, strerror(errno));
288 ods_log_error(
"[%s] zone %s received bad notify reply opcode/qr from %s",
293 ods_log_error(
"[%s] zone %s received bad notify reply id from %s",
300 ods_log_error(
"[%s] zone %s received bad notify rcode %s from %s",
301 notify_str, zone->
name, str?str:
"UNKNOWN",
308 ods_log_debug(
"[%s] zone %s secondary %s notify reply ok", notify_str,
321 struct sockaddr_storage to;
322 socklen_t to_len = 0;
337 fd = socket(family, SOCK_DGRAM, IPPROTO_UDP);
350 (
struct sockaddr*)&to, to_len);
377 ods_log_error(
"[%s] unable to sign notify: tsig unknown algorithm " 394 ods_log_debug(
"[%s] tsig append rr to notify id=%u", notify_str,
435 notify_tsig_sign(notify, xfrhandler->
packet);
440 ods_log_error(
"[%s] unable to send notify retry %u for zone %s to " 441 "%s: notify_send_udp() failed", notify_str, notify->
retry,
445 ods_log_verbose(
"[%s] notify retry %u for zone %s sent to %s", notify_str,
456 notify_handle_zone(
netio_type* ATTR_UNUSED(netio),
475 ods_log_debug(
"[%s] already waiting, skipping notify for zone %s",
476 notify_str, zone->
name);
484 if (notify_udp_read_packet(notify)) {
485 if (notify_handle_reply(notify)) {
515 notify_update_soa(
notify_type* notify, ldns_rr* soa)
521 ldns_rr_free(notify->
soa);
556 ods_log_debug(
"[%s] zone %s already on waiting list", notify_str,
560 notify_update_soa(notify, soa);
562 notify_setup(notify);
579 ods_log_debug(
"[%s] zone %s notify on waiting list", notify_str,
602 ldns_rr_free(notify->
soa);
ldns_pkt_opcode buffer_pkt_opcode(buffer_type *buffer)
void tsig_rr_update(tsig_rr_type *trr, buffer_type *buffer, size_t length)
void notify_enable(notify_type *notify, ldns_rr *soa)
void notify_send(notify_type *notify)
void ods_log_debug(const char *format,...)
notify_type * notify_create(void *xfrhandler, void *zone)
uint16_t buffer_pkt_arcount(buffer_type *buffer)
void * allocator_alloc(allocator_type *allocator, size_t size)
void buffer_flip(buffer_type *buffer)
void buffer_clear(buffer_type *buffer)
enum netio_events_enum netio_events_type
socklen_t xfrd_acl_sockaddr_to(acl_type *acl, struct sockaddr_storage *to)
tsig_algo_type * tsig_lookup_algo(const char *name)
void ods_log_error(const char *format,...)
int buffer_pkt_qr(buffer_type *buffer)
void tsig_rr_reset(tsig_rr_type *trr, tsig_algo_type *algo, tsig_key_type *key)
void tsig_rr_append(tsig_rr_type *trr, buffer_type *buffer)
uint16_t buffer_pkt_id(buffer_type *buffer)
void notify_cleanup(notify_type *notify)
uint8_t * buffer_current(buffer_type *buffer)
adapter_type * adoutbound
void tsig_rr_prepare(tsig_rr_type *trr)
time_t xfrhandler_time(xfrhandler_type *xfrhandler)
void buffer_pkt_set_ancount(buffer_type *buffer, uint16_t count)
void buffer_set_limit(buffer_type *buffer, size_t limit)
allocator_type * allocator_create(void *(*allocator)(size_t size), void(*deallocator)(void *))
notify_type * notify_waiting_first
netio_event_handler_type event_handler
void tsig_rr_cleanup(tsig_rr_type *trr)
void log_dname(ldns_rdf *rdf, const char *pre, int level)
notify_type * notify_waiting_last
allocator_type * allocator
#define NOTIFY_RETRY_TIMEOUT
void buffer_pkt_set_aa(buffer_type *buffer)
tsig_rr_type * tsig_rr_create(allocator_type *allocator)
const char * buffer_rcode2str(ldns_pkt_rcode rcode)
void ods_log_verbose(const char *format,...)
netio_events_type event_types
void buffer_pkt_notify(buffer_type *buffer, ldns_rdf *qname, ldns_rr_class qclass)
void allocator_cleanup(allocator_type *allocator)
size_t buffer_remaining(buffer_type *buffer)
void ods_log_deeebug(const char *format,...)
int buffer_write_rr(buffer_type *buffer, ldns_rr *rr)
void tsig_rr_sign(tsig_rr_type *trr)
notify_type * waiting_next
void allocator_deallocate(allocator_type *allocator, void *data)
size_t buffer_position(buffer_type *buffer)
void buffer_pkt_set_arcount(buffer_type *buffer, uint16_t count)
netio_handler_type handler
struct timespec * timeout
#define ods_log_assert(x)
void ods_log_warning(const char *format,...)
uint16_t original_query_id
uint8_t * buffer_begin(buffer_type *buffer)
ldns_pkt_rcode buffer_pkt_rcode(buffer_type *buffer)