diff.c File Reference

#include <config.h>
#include <stdlib.h>
#include <isc/buffer.h>
#include <isc/file.h>
#include <isc/mem.h>
#include <isc/string.h>
#include <isc/util.h>
#include <dns/db.h>
#include <dns/diff.h>
#include <dns/log.h>
#include <dns/rdataclass.h>
#include <dns/rdatalist.h>
#include <dns/rdataset.h>
#include <dns/rdatastruct.h>
#include <dns/rdatatype.h>
#include <dns/result.h>

Go to the source code of this file.

Defines

#define CHECK(op)
#define DIFF_COMMON_LOGARGS   dns_lctx, DNS_LOGCATEGORY_GENERAL, DNS_LOGMODULE_DIFF

Functions

static dns_rdatatype_t rdata_covers (dns_rdata_t *rdata)
isc_result_t dns_difftuple_create (isc_mem_t *mctx, dns_diffop_t op, dns_name_t *name, dns_ttl_t ttl, dns_rdata_t *rdata, dns_difftuple_t **tp)
 Create a tuple. Deep copies are made of the name and rdata, so they need not remain valid after the call.
void dns_difftuple_free (dns_difftuple_t **tp)
 Free a tuple.
isc_result_t dns_difftuple_copy (dns_difftuple_t *orig, dns_difftuple_t **copyp)
 Copy a tuple.
void dns_diff_init (isc_mem_t *mctx, dns_diff_t *diff)
 Initialize a diff.
void dns_diff_clear (dns_diff_t *diff)
 Clear a diff, destroying all its tuples.
void dns_diff_append (dns_diff_t *diff, dns_difftuple_t **tuplep)
 Append a single tuple to a diff.
void dns_diff_appendminimal (dns_diff_t *diff, dns_difftuple_t **tuplep)
 Append 'tuple' to 'diff', removing any duplicate or conflicting updates as needed to create a minimal diff.
static isc_stdtime_t setresign (dns_rdataset_t *modified)
static void getownercase (dns_rdataset_t *rdataset, dns_name_t *name)
static void setownercase (dns_rdataset_t *rdataset, dns_name_t *name)
static isc_result_t diff_apply (dns_diff_t *diff, dns_db_t *db, dns_dbversion_t *ver, isc_boolean_t warn)
isc_result_t dns_diff_apply (dns_diff_t *diff, dns_db_t *db, dns_dbversion_t *ver)
isc_result_t dns_diff_applysilently (dns_diff_t *diff, dns_db_t *db, dns_dbversion_t *ver)
 Apply 'diff' to the database 'db'.
isc_result_t dns_diff_load (dns_diff_t *diff, dns_addrdatasetfunc_t addfunc, void *add_private)
 Like dns_diff_apply, but for use when loading a new database instead of modifying an existing one. This bypasses the database transaction mechanisms.
isc_result_t dns_diff_sort (dns_diff_t *diff, dns_diff_compare_func *compare)
 Sort 'diff' in-place according to the comparison function 'compare'.
static isc_result_t diff_tuple_tordataset (dns_difftuple_t *t, dns_rdata_t *rdata, dns_rdatalist_t *rdl, dns_rdataset_t *rds)
isc_result_t dns_diff_print (dns_diff_t *diff, FILE *file)
 Print the differences to 'file' or if 'file' is NULL via the logging system.


Detailed Description

Definition in file diff.c.


Define Documentation

#define CHECK ( op   ) 

Value:

do { result = (op);                                     \
                if (result != ISC_R_SUCCESS) goto failure;      \
        } while (0)

Definition at line 42 of file diff.c.

#define DIFF_COMMON_LOGARGS   dns_lctx, DNS_LOGCATEGORY_GENERAL, DNS_LOGMODULE_DIFF

Definition at line 47 of file diff.c.

Referenced by diff_apply(), dns_diff_load(), and dns_diff_print().


Function Documentation

static dns_rdatatype_t rdata_covers ( dns_rdata_t rdata  )  [static]

Definition at line 51 of file diff.c.

References dns_rdata_covers(), and dns_rdata::type.

Referenced by diff_apply(), and dns_diff_load().

isc_result_t dns_difftuple_create ( isc_mem_t mctx,
dns_diffop_t  op,
dns_name_t name,
dns_ttl_t  ttl,
dns_rdata_t rdata,
dns_difftuple_t **  tp 
)

Create a tuple. Deep copies are made of the name and rdata, so they need not remain valid after the call.

Requires:

Returns:

Definition at line 57 of file diff.c.

References dns_rdata::data, DNS_DIFFTUPLE_MAGIC, dns_name_clone(), dns_name_init(), dns_rdata_clone(), dns_rdata_init(), INSIST, ISC_LINK_INIT, isc_mem_allocate, isc_mem_attach(), ISC_R_NOMEMORY, ISC_R_SUCCESS, dns_rdata::length, dns_name::length, dns_difftuple::magic, dns_difftuple::mctx, dns_difftuple::name, dns_name::ndata, dns_difftuple::op, dns_difftuple::rdata, REQUIRE, and dns_difftuple::ttl.

Referenced by add_nsec(), add_nsec3param_records(), add_placeholder_nsec(), add_rr_prepare_action(), add_signing_records(), axfr_putdata(), delete(), dns_db_createsoatuple(), dns_difftuple_copy(), dns_journal_print(), dns_nsec3_addnsec3(), dns_nsec3_delnsec3(), dns_nsec3param_deletechains(), get_name_diff(), ixfr_putdata(), loadds(), namelist_append_name(), publish_key(), remove_key(), roll_forward(), rollback_private(), rrset_cleanup(), signset(), signwithkey(), sync_secure_journal(), temp_append(), update_one_rr(), and writeset().

void dns_difftuple_free ( dns_difftuple_t **  tp  ) 

Free a tuple.

Requires:

Ensures:

Definition at line 107 of file diff.c.

References DNS_DIFFTUPLE_VALID, dns_name_invalidate(), isc_mem_detach(), isc_mem_free, dns_difftuple::magic, dns_difftuple::mctx, mctx, dns_difftuple::name, and REQUIRE.

Referenced by dns_diff_appendminimal(), dns_diff_clear(), dns_diff_subtract(), do_one_tuple(), ns_xfr_start(), receive_secure_serial(), soa_rrstream_destroy(), sync_secure_db(), sync_secure_journal(), uniqify_name_list(), update_soa_serial(), and xfrin_send_request().

isc_result_t dns_difftuple_copy ( dns_difftuple_t orig,
dns_difftuple_t **  copyp 
)

Copy a tuple.

Requires:

Definition at line 122 of file diff.c.

References dns_difftuple_create(), dns_difftuple::mctx, dns_difftuple::name, dns_difftuple::op, dns_difftuple::rdata, and dns_difftuple::ttl.

Referenced by update_soa_serial().

void dns_diff_init ( isc_mem_t mctx,
dns_diff_t diff 
)

Initialize a diff.

Requires:

Ensures:

Definition at line 128 of file diff.c.

References DNS_DIFF_MAGIC, ISC_LIST_INIT, dns_diff::magic, and dns_diff::mctx.

Referenced by add_nsec3param_records(), add_signing_records(), add_soa(), ATF_TC_BODY(), build_final_keylist(), cleanup_zone(), diff_namespace(), dns_db_diff(), dns_journal_print(), dns_update_signaturesinc(), do_one_tuple(), keydone(), keyfetch_done(), loadds(), receive_secure_serial(), remove_orphaned_ds(), restore_nsec3param(), roll_forward(), rollback_private(), signname(), sync_keyzone(), temp_check(), update_action(), writeset(), xfrin_create(), zone_nsec3chain(), zone_refreshkeys(), zone_resigninc(), zone_sign(), and zone_unchanged().

void dns_diff_clear ( dns_diff_t diff  ) 

Clear a diff, destroying all its tuples.

Requires:

Ensures: Notes:

Definition at line 135 of file diff.c.

References DNS_DIFF_VALID, dns_difftuple_free(), ENSURE, ISC_LIST_EMPTY, ISC_LIST_HEAD, ISC_LIST_UNLINK, and REQUIRE.

Referenced by add_nsec3param_records(), add_signing_records(), add_soa(), ATF_TC_BODY(), axfr_apply(), build_final_keylist(), cleanup_zone(), diff_namespace(), dns_db_diff(), dns_journal_print(), dns_update_signaturesinc(), do_diff(), ixfr_apply(), keydone(), keyfetch_done(), loadds(), maybe_free(), receive_secure_serial(), restore_nsec3param(), roll_forward(), rollback_private(), signname(), sync_keyzone(), temp_check(), update_action(), writeset(), xfrin_reset(), zone_nsec3chain(), zone_refreshkeys(), zone_resigninc(), zone_sign(), and zone_unchanged().

void dns_diff_append ( dns_diff_t diff,
dns_difftuple_t **  tuple 
)

Append a single tuple to a diff.

Ensures:

Definition at line 146 of file diff.c.

References ISC_LIST_APPEND.

Referenced by add_rr_prepare_action(), axfr_putdata(), dns_journal_print(), get_name_diff(), ixfr_putdata(), loadds(), namelist_append_name(), roll_forward(), rrset_cleanup(), signset(), signwithkey(), and writeset().

void dns_diff_appendminimal ( dns_diff_t diff,
dns_difftuple_t **  tuple 
)

Append 'tuple' to 'diff', removing any duplicate or conflicting updates as needed to create a minimal diff.

Requires:

Ensures:

Definition at line 155 of file diff.c.

References DNS_DIFF_VALID, dns_difftuple_free(), DNS_DIFFTUPLE_VALID, dns_name_caseequal(), dns_rdata_compare(), ENSURE, ISC_LIST_APPEND, ISC_LIST_HEAD, ISC_LIST_NEXT, ISC_LIST_UNLINK, dns_difftuple::name, dns_difftuple::op, dns_difftuple::rdata, REQUIRE, dns_difftuple::ttl, and UNEXPECTED_ERROR.

Referenced by add_nsec3param_records(), dns_update_signaturesinc(), do_one_tuple(), publish_key(), remove_key(), remove_orphaned_ds(), sync_secure_journal(), and update_sigs().

static isc_stdtime_t setresign ( dns_rdataset_t modified  )  [static]

Definition at line 203 of file diff.c.

References DNS_RDATA_INIT, DNS_RDATA_OFFLINE, dns_rdata_reset(), dns_rdata_tostruct(), dns_rdataset_current(), dns_rdataset_first(), dns_rdataset_next(), dns_rdata::flags, INSIST, ISC_R_NOMORE, and ISC_R_SUCCESS.

Referenced by diff_apply().

static void getownercase ( dns_rdataset_t rdataset,
dns_name_t name 
) [static]

Definition at line 237 of file diff.c.

References dns_rdataset_getownercase(), and dns_rdataset_isassociated().

Referenced by diff_apply().

static void setownercase ( dns_rdataset_t rdataset,
dns_name_t name 
) [static]

Definition at line 243 of file diff.c.

References dns_rdataset_isassociated(), and dns_rdataset_setownercase().

Referenced by addrdataset(), diff_apply(), loading_addrdataset(), and rdataset_setownercase().

static isc_result_t diff_apply ( dns_diff_t diff,
dns_db_t db,
dns_dbversion_t ver,
isc_boolean_t  warn 
) [static]

Definition at line 249 of file diff.c.

References CHECK, dns_rdatalist::covers, DIFF_COMMON_LOGARGS, dns_db_addrdataset(), dns_db_class(), dns_db_detachnode(), dns_db_findnode(), dns_db_findnsec3node(), dns_db_origin(), dns_db_setsigningtime(), dns_db_subtractrdataset(), DNS_DB_VALID, DNS_DBADD_EXACT, DNS_DBADD_EXACTTTL, DNS_DBADD_MERGE, DNS_DBSUB_EXACT, DNS_DBSUB_WANTOLD, DNS_DIFF_VALID, DNS_DIFFOP_ADD, DNS_DIFFOP_ADDRESIGN, DNS_DIFFOP_DEL, DNS_DIFFOP_DELRESIGN, dns_name_equal(), dns_name_format(), DNS_NAME_FORMATSIZE, DNS_R_NXRRSET, DNS_R_UNCHANGED, dns_rdataclass_format(), DNS_RDATACLASS_FORMATSIZE, dns_rdatalist_init(), dns_rdatalist_tordataset(), dns_rdataset_disassociate(), dns_rdataset_init(), dns_rdataset_isassociated(), dns_rdatatype_format(), DNS_RDATATYPE_FORMATSIZE, dns_trust_ultimate, getownercase(), INSIST, ISC_LIST_APPEND, ISC_LIST_HEAD, ISC_LIST_NEXT, ISC_LOG_WARNING, isc_log_write(), ISC_R_SUCCESS, ISC_TRUE, dns_difftuple::name, name, namebuf, dns_difftuple::op, dns_difftuple::rdata, rdata_covers(), dns_rdata::rdclass, dns_rdatalist::rdclass, REQUIRE, setownercase(), setresign(), dns_rdataset::trust, dns_difftuple::ttl, dns_rdatalist::ttl, dns_rdataset::type, dns_rdatalist::type, and dns_rdata::type.

Referenced by dns_diff_apply(), and dns_diff_applysilently().

isc_result_t dns_diff_apply ( dns_diff_t diff,
dns_db_t db,
dns_dbversion_t ver 
)

Definition at line 454 of file diff.c.

References diff_apply(), and ISC_TRUE.

Referenced by do_one_tuple(), ixfr_apply(), loadds(), receive_secure_serial(), roll_forward(), and writeset().

isc_result_t dns_diff_applysilently ( dns_diff_t diff,
dns_db_t db,
dns_dbversion_t ver 
)

Apply 'diff' to the database 'db'.

dns_diff_apply() logs warnings about updates with no effect or with inconsistent TTLs; dns_diff_applysilently() does not.

For efficiency, the diff should be sorted by owner name. If it is not sorted, operation will still be correct, but less efficient.

Requires:

Definition at line 459 of file diff.c.

References diff_apply(), and ISC_FALSE.

Referenced by build_final_keylist(), cleanup_zone(), and signname().

isc_result_t dns_diff_load ( dns_diff_t diff,
dns_addrdatasetfunc_t  addfunc,
void *  add_private 
)

Like dns_diff_apply, but for use when loading a new database instead of modifying an existing one. This bypasses the database transaction mechanisms.

Requires:

Definition at line 466 of file diff.c.

References CHECK, dns_rdatalist::covers, DIFF_COMMON_LOGARGS, DNS_DIFF_VALID, DNS_DIFFOP_ADD, dns_name_equal(), DNS_R_NXRRSET, DNS_R_UNCHANGED, dns_rdatalist_init(), dns_rdatalist_tordataset(), dns_rdataset_init(), dns_trust_ultimate, INSIST, ISC_LIST_APPEND, ISC_LIST_HEAD, ISC_LIST_NEXT, ISC_LOG_WARNING, isc_log_write(), ISC_R_SUCCESS, dns_difftuple::name, name, dns_difftuple::op, dns_difftuple::rdata, rdata_covers(), dns_rdata::rdclass, dns_rdatalist::rdclass, REQUIRE, dns_rdataset::trust, dns_difftuple::ttl, dns_rdatalist::ttl, dns_rdatalist::type, and dns_rdata::type.

Referenced by axfr_apply().

isc_result_t dns_diff_sort ( dns_diff_t diff,
dns_diff_compare_func compare 
)

Sort 'diff' in-place according to the comparison function 'compare'.

Definition at line 537 of file diff.c.

References DNS_DIFF_VALID, INSIST, ISC_LIST_APPEND, ISC_LIST_HEAD, ISC_LIST_NEXT, ISC_LIST_UNLINK, isc_mem_get, isc_mem_put, ISC_R_NOMEMORY, ISC_R_SUCCESS, dns_diff::mctx, and REQUIRE.

Referenced by dns_diff_subtract(), dns_journal_write_transaction(), dns_update_signaturesinc(), temp_check(), uniqify_name_list(), and update_action().

static isc_result_t diff_tuple_tordataset ( dns_difftuple_t t,
dns_rdata_t rdata,
dns_rdatalist_t rdl,
dns_rdataset_t rds 
) [static]

Definition at line 575 of file diff.c.

References DNS_DIFFTUPLE_VALID, dns_rdata_clone(), dns_rdatalist_init(), dns_rdatalist_tordataset(), dns_rdataset_init(), ISC_LINK_INIT, ISC_LIST_APPEND, dns_difftuple::rdata, dns_rdata::rdclass, dns_rdatalist::rdclass, REQUIRE, dns_difftuple::ttl, dns_rdatalist::ttl, dns_rdata::type, and dns_rdatalist::type.

Referenced by dns_diff_print().

isc_result_t dns_diff_print ( dns_diff_t diff,
FILE *  file 
)

Print the differences to 'file' or if 'file' is NULL via the logging system.

Require:

Returns:

Definition at line 594 of file diff.c.

References isc_region::base, isc_buffer::base, cleanup(), DIFF_COMMON_LOGARGS, diff_tuple_tordataset(), DNS_DIFF_VALID, DNS_DIFFOP_ADD, DNS_DIFFOP_ADDRESIGN, DNS_DIFFOP_DEL, DNS_DIFFOP_DELRESIGN, DNS_DIFFOP_EXISTS, DNS_RDATA_INIT, dns_rdataset_totext(), dns_result_totext(), INSIST, isc_buffer_init, isc_buffer_usedregion, ISC_FALSE, ISC_LIST_HEAD, ISC_LIST_NEXT, ISC_LOG_DEBUG, isc_log_write(), isc_mem_get, isc_mem_put, ISC_R_NOMEMORY, ISC_R_NOSPACE, ISC_R_SUCCESS, ISC_R_UNEXPECTED, isc_region::length, dns_diff::mctx, dns_difftuple::name, dns_difftuple::op, r, REQUIRE, UNEXPECTED_ERROR, and isc_buffer::used.

Referenced by dns_journal_print(), dns_journal_writediff(), and roll_forward().


Generated on Tue Apr 28 17:41:08 2015 by Doxygen 1.5.4 for BIND9 Internals 9.11.0pre-alpha