From e0e87cb2c8629f2c75c19d2a121b07d4856e0876 Mon Sep 17 00:00:00 2001 From: Jan Kadlec <jan.kadlec@nic.cz> Date: Wed, 18 Jul 2012 18:45:13 +0200 Subject: [PATCH] Added new error code. - Added KNOT(D)_ENODIFF, which is now being returned when no zone diff could be produced. - if new zone has lower serial than old zone, return KNOT_ERANGE - Proper comparison of serials added. Refs #1949 --- src/knot/other/error.c | 3 ++- src/knot/other/error.h | 3 ++- src/knot/server/zones.c | 6 ++++-- src/libknot/util/error.h | 3 ++- src/libknot/util/libknot_error.c | 1 + src/libknot/zone/zone-diff.c | 13 +++++++++++-- 6 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/knot/other/error.c b/src/knot/other/error.c index 70c84a3a4b..80343bd2ba 100644 --- a/src/knot/other/error.c +++ b/src/knot/other/error.c @@ -41,6 +41,7 @@ const error_table_t knotd_error_msgs[] = { {KNOTD_ENOIPV6, "IPv6 support disabled."}, {KNOTD_EMALF, "Malformed data."}, {KNOTD_ESPACE, "Not enough space provided."}, - {KNOTD_EEXPIRED, "Resource is expired."}, + {KNOTD_EEXPIRED, "Resource is expired."}, + {KNOTD_ENODIFF, "Cannot create zone diff."}, {KNOTD_ERROR, 0} }; diff --git a/src/knot/other/error.h b/src/knot/other/error.h index 65c51cf9d8..aa4961e04e 100644 --- a/src/knot/other/error.h +++ b/src/knot/other/error.h @@ -63,8 +63,9 @@ enum knot_error_t { KNOTD_EMALF, /*!< \brief Malformed data. */ KNOTD_ESPACE, /*!< \brief Not enough space provided. */ KNOTD_EEXPIRED, /*!< \brief Resource is expired. */ + KNOTD_ENODIFF, /*!< \brief Cannot create zone diff. */ - KNOTD_ERROR_COUNT = 21 + KNOTD_ERROR_COUNT = 22 }; /*! \brief Table linking error messages to error codes. */ diff --git a/src/knot/server/zones.c b/src/knot/server/zones.c index 7dea81200b..81e1bf43c0 100644 --- a/src/knot/server/zones.c +++ b/src/knot/server/zones.c @@ -3209,8 +3209,10 @@ int zones_create_and_save_changesets(const knot_zone_t *old_zone, dbg_zones("zones: create_changesets: " "Could not create changesets. Reason: %s\n", knot_strerror(ret)); - if (ret == KNOT_EAGAIN) { - return KNOTD_EOK; + if (ret == KNOT_ERANGE) { + return KNOTD_ERANGE; + } else if (ret == KNOT_ENODIFF) { + return KNOTD_ENODIFF; } else { return KNOTD_ERROR; } diff --git a/src/libknot/util/error.h b/src/libknot/util/error.h index 4a6d4c718b..9b441e488c 100644 --- a/src/libknot/util/error.h +++ b/src/libknot/util/error.h @@ -69,7 +69,8 @@ enum knot_error { KNOT_ECONN, /*!< Connection reset. */ KNOT_EIXFRSPACE, /*!< IXFR reply did not fit in. */ KNOT_ECNAME, /*!< CNAME loop found in zone. */ - KNOT_ERROR_COUNT = 35 + KNOT_ENODIFF, /*!< No zone diff can be created. */ + KNOT_ERROR_COUNT = 36 }; /*! \brief Table linking error messages to error codes. */ diff --git a/src/libknot/util/libknot_error.c b/src/libknot/util/libknot_error.c index 30f1f21842..bba968a712 100644 --- a/src/libknot/util/libknot_error.c +++ b/src/libknot/util/libknot_error.c @@ -52,5 +52,6 @@ const error_table_t knot_error_msgs[KNOT_ERROR_COUNT] = { {KNOT_ECONN, "Connection reset."}, {KNOT_EIXFRSPACE, "IXFR reply did not fit in."}, {KNOT_ECNAME, "CNAME loop found in zone."}, + {KNOT_ENODIFF, "Cannot create zone diff."}, {KNOT_ERROR, 0} }; diff --git a/src/libknot/zone/zone-diff.c b/src/libknot/zone/zone-diff.c index db03f35cc2..07817d4eb9 100644 --- a/src/libknot/zone/zone-diff.c +++ b/src/libknot/zone/zone-diff.c @@ -21,6 +21,7 @@ #include "libknot/util/debug.h" #include "libknot/rdata.h" #include "zone-diff.h" +#include "libknot/nameserver/name-server.h" struct zone_diff_param { const knot_zone_contents_t *contents; @@ -29,6 +30,7 @@ struct zone_diff_param { int ret; }; +// forward declaration static int knot_zone_diff_rdata(const knot_rrset_t *rrset1, const knot_rrset_t *rrset2, knot_changeset_t *changeset); @@ -78,11 +80,18 @@ static int knot_zone_diff_load_soas(const knot_zone_contents_t *zone1, dbg_zonediff("zone_diff: load_soas: Got bad SOA.\n"); } - if (soa_serial1 >= soa_serial2) { + if (ns_serial_compare(soa_serial1, soa_serial2) == 0) { dbg_zonediff("zone_diff: " "second zone must have higher serial than the " "first one.\n"); - return KNOT_EAGAIN; + return KNOT_ENODIFF; + } + + if (ns_serial_compare(soa_serial1, soa_serial2) == 0) { + dbg_zonediff("zone_diff: " + "second zone must have higher serial than the " + "first one.\n"); + return KNOT_ERANGE; } /* We will not touch SOA later, now is the time to handle RRSIGs. */ -- GitLab