From: Mukund Sivaraman Date: Tue, 17 Apr 2012 13:33:52 +0000 (+0530) Subject: [1790] After successful zone transfers, send b10-auth loadzone if necessary X-Git-Tag: trac2351_base~226^2~144 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9dc2c2ee14162ff74a1509ce620daa28fdf29261;p=thirdparty%2Fkea.git [1790] After successful zone transfers, send b10-auth loadzone if necessary --- diff --git a/src/bin/xfrin/xfrin.py.in b/src/bin/xfrin/xfrin.py.in index 27b91a99de..7551c987bd 100755 --- a/src/bin/xfrin/xfrin.py.in +++ b/src/bin/xfrin/xfrin.py.in @@ -66,6 +66,7 @@ else: SPECFILE_LOCATION = SPECFILE_PATH + "/xfrin.spec" AUTH_SPECFILE_LOCATION = AUTH_SPECFILE_PATH + "/auth.spec" +AUTH_MODULE_NAME = 'Auth' XFROUT_MODULE_NAME = 'Xfrout' ZONE_MANAGER_MODULE_NAME = 'Zonemgr' REFRESH_FROM_ZONEMGR = 'refresh_from_zonemgr' @@ -1529,7 +1530,7 @@ class Xfrin: def _set_db_file(self): db_file, is_default =\ - self._module_cc.get_remote_config_value("Auth", "database_file") + self._module_cc.get_remote_config_value(AUTH_MODULE_NAME, "database_file") if is_default and "B10_FROM_BUILD" in os.environ: # override the local database setting if it is default and we # are running from the source tree @@ -1539,7 +1540,41 @@ class Xfrin: "bind10_zones.sqlite3" self._db_file = db_file - def publish_xfrin_news(self, zone_name, zone_class, xfr_result): + def _do_auth_loadzone(self, zone_name, zone_class): + # On a successful zone transfer, if the zone is served by + # b10-auth in the in-memory data source using sqlite3 as a + # backend, send the "loadzone" command for the zone to auth. + datasources, is_default =\ + self._module_cc.get_remote_config_value(AUTH_MODULE_NAME, "datasources") + if is_default: + return + for d in datasources: + if d.has_key("class"): + dclass = d["class"] + else: + dclass = "IN" + if d["type"].lower() == "memory" and dclass.lower() == zone_class.lower(): + for zone in d["zones"]: + if zone["filetype"].lower() == "sqlite3" and\ + zone["origin"].lower() == zone_name.lower(): + param = {"origin": zone_name.to_text(), + "class": zone_class.to_text(), + "datasrc": d["type"]} + logger.debug(XFRIN_AUTH_LOADZONE, + param["origin"], param["class"], param["datasrc"]) + + msg = create_command("loadzone", param) + # catch the exception, in case msgq has been killed. + try: + seq = self._send_cc_session.group_sendmsg(msg, AUTH_MODULE_NAME) + try: + answer, env = self._send_cc_session.group_recvmsg(False, seq) + except isc.cc.session.SessionTimeout: + pass # for now we just ignore the failure + except socket.error as err: + logger.error(XFRIN_MSGQ_SEND_ERROR_AUTH, AUTH_MODULE_NAME) + + def publish_xfrin_news(self, zone_name, zone_class, xfr_result): '''Send command to xfrout/zone manager module. If xfrin has finished successfully for one zone, tell the good news(command: zone_new_data_ready) to zone manager and xfrout. @@ -1566,6 +1601,9 @@ class Xfrin: pass # for now we just ignore the failure except socket.error as err: logger.error(XFRIN_MSGQ_SEND_ERROR, XFROUT_MODULE_NAME, ZONE_MANAGER_MODULE_NAME) + + self._do_auth_loadzone(zone_name, zone_class) + else: msg = create_command(ZONE_XFRIN_FAILED, param) # catch the exception, in case msgq has been killed. diff --git a/src/bin/xfrin/xfrin_messages.mes b/src/bin/xfrin/xfrin_messages.mes index 25a1fc1c06..42a313ba19 100644 --- a/src/bin/xfrin/xfrin_messages.mes +++ b/src/bin/xfrin/xfrin_messages.mes @@ -117,6 +117,15 @@ was killed. There was a problem sending a message to the zone manager. This most likely means that the msgq daemon has quit or was killed. +% XFRIN_MSGQ_SEND_ERROR_AUTH error while contacting %1 +There was a problem sending a message to b10-auth. This most likely +means that the msgq daemon has quit or was killed. + +% XFRIN_AUTH_LOADZONE sending Auth loadzone for origin=%1, class=%2, datasrc=%3 +There was a successful zone transfer, and the zone is served by b10-auth +in the in-memory data source using sqlite3 as a backend. We send the +"loadzone" command for the zone to b10-auth. + % XFRIN_NOTIFY_UNKNOWN_MASTER got notification to retransfer zone %1 from %2, expected %3 The system received a notify for the given zone, but the address it came from does not match the master address in the Xfrin configuration. The notify