예제 #1
0
파일: tsig.c 프로젝트: execunix/vinos
/*
 * Find a few nodes to destroy if possible.
 */
static void
cleanup_ring(dns_tsig_keyring_t *ring)
{
	isc_result_t result;
	dns_rbtnodechain_t chain;
	dns_name_t foundname;
	dns_fixedname_t fixedorigin;
	dns_name_t *origin;
	isc_stdtime_t now;
	dns_rbtnode_t *node;
	dns_tsigkey_t *tkey;

	/*
	 * Start up a new iterator each time.
	 */
	isc_stdtime_get(&now);
	dns_name_init(&foundname, NULL);
	dns_fixedname_init(&fixedorigin);
	origin = dns_fixedname_name(&fixedorigin);

 again:
	dns_rbtnodechain_init(&chain, ring->mctx);
	result = dns_rbtnodechain_first(&chain, ring->keys, &foundname,
					origin);
	if (result != ISC_R_SUCCESS && result != DNS_R_NEWORIGIN) {
		dns_rbtnodechain_invalidate(&chain);
		return;
	}

	for (;;) {
		node = NULL;
		dns_rbtnodechain_current(&chain, &foundname, origin, &node);
		tkey = node->data;
		if (tkey != NULL) {
			if (tkey->generated
			    && isc_refcount_current(&tkey->refs) == 1
			    && tkey->inception != tkey->expire
			    && tkey->expire < now) {
				tsig_log(tkey, 2, "tsig expire: deleting");
				/* delete the key */
				dns_rbtnodechain_invalidate(&chain);
				remove_fromring(tkey);
				goto again;
			}
		}
		result = dns_rbtnodechain_next(&chain, &foundname,
					       origin);
		if (result != ISC_R_SUCCESS && result != DNS_R_NEWORIGIN) {
			dns_rbtnodechain_invalidate(&chain);
			return;
		}
	}
}
예제 #2
0
파일: view.c 프로젝트: enukane/netbsd-src
static inline void
destroy(dns_view_t *view) {
	dns_dns64_t *dns64;
	dns_dlzdb_t *dlzdb;

	REQUIRE(!ISC_LINK_LINKED(view, link));
	REQUIRE(isc_refcount_current(&view->references) == 0);
	REQUIRE(view->weakrefs == 0);
	REQUIRE(RESSHUTDOWN(view));
	REQUIRE(ADBSHUTDOWN(view));
	REQUIRE(REQSHUTDOWN(view));

	if (view->order != NULL)
		dns_order_detach(&view->order);
	if (view->peers != NULL)
		dns_peerlist_detach(&view->peers);

	if (view->dynamickeys != NULL) {
		isc_result_t result;
		char template[20];
예제 #3
0
/**
 * Get current MetaLDAP generation number.
 *
 * Generation numbers have to be compared using isc_serial_* functions.
 */
isc_uint32_t
mldap_cur_generation_get(mldapdb_t *mldap) {
	return (isc_uint32_t)isc_refcount_current(&mldap->generation);
}
예제 #4
0
void mldap_cur_generation_bump(mldapdb_t *mldap) {
	REQUIRE(mldap != NULL);

	isc_refcount_increment0(&mldap->generation, NULL);
}

/*
 * Verify that isc_refcount_t can be casted properly to isc_uint32_t
 * so isc_serial_* functions can be safely used for comparison.
 *
 * The spell 'typeof(isc_refcount_current((isc_refcount_t *)0))' walks through
 * isc_refcount_t abstractions and returns underlying type used for storing the
 * reference counter value.
 */
STATIC_ASSERT((isc_uint32_t)
		(typeof(isc_refcount_current((isc_refcount_t *)0)))
		-1
	      == 0xFFFFFFFF, \
	      "negative isc_refcount_t cannot be properly shortened to 32 bits");

STATIC_ASSERT((isc_uint32_t)
		(typeof(isc_refcount_current((isc_refcount_t *)0)))
		0x90ABCDEF12345678
	      == 0x12345678, \
	      "positive isc_refcount_t cannot be properly shortened to 32 bits");

/**
 * Get current MetaLDAP generation number.
 *
 * Generation numbers have to be compared using isc_serial_* functions.
 */