Beispiel #1
0
static int
ipf_modunload(void)
{
	int error, i;

	if (fr_refcnt)
		return EBUSY;

	if (fr_running >= 0) {
		ipf_pfil_unhook();
		ipf_event_dereg();
		WRITE_ENTER(&ipf_global);
		error = ipfdetach();
		RWLOCK_EXIT(&ipf_global);
		if (error != 0)
			return error;
	} else
		error = 0;

	RW_DESTROY(&ipf_global);
	RW_DESTROY(&ipf_mutex);
	RW_DESTROY(&ipf_frcache);

	fr_running = -2;

	for (i = 0; ipf_devfiles[i]; i++) {
		if (ipf_devs[i] != NULL)
			destroy_dev(ipf_devs[i]);
	}

	printf("%s unloaded\n", ipfilter_version);

	return error;
}
Beispiel #2
0
static int
ipf_modload(void)
{
	char *defpass, *c, *str;
	int i, j, error;

	RWLOCK_INIT(&ipf_global, "ipf filter load/unload mutex");
	RWLOCK_INIT(&ipf_mutex, "ipf filter rwlock");
	RWLOCK_INIT(&ipf_frcache, "ipf cache rwlock");

	error = ipfattach();
	if (error) {
		RW_DESTROY(&ipf_global);
		RW_DESTROY(&ipf_mutex);
		RW_DESTROY(&ipf_frcache);
		return error;
	}

	for (i = 0; i < IPL_LOGSIZE; i++)
		ipf_devs[i] = NULL;

	for (i = 0; (str = ipf_devfiles[i]); i++) {
		c = NULL;
		for(j = strlen(str); j > 0; j--)
			if (str[j] == '/') {
				c = str + j + 1;
				break;
			}
		if (!c)
			c = str;
		ipf_devs[i] = make_dev(&ipl_cdevsw, i, 0, 0, 0600, c);
	}

	error = ipf_pfil_hook();
	if (error != 0)
		return error;
	ipf_event_reg();

	if (FR_ISPASS(fr_pass))
		defpass = "******";
	else if (FR_ISBLOCK(fr_pass))
		defpass = "******";
	else
		defpass = "******";

	printf("%s initialized.  Default = %s all, Logging = %s%s\n",
		ipfilter_version, defpass,
#ifdef IPFILTER_LOG
		"enabled",
#else
		"disabled",
#endif
#ifdef IPFILTER_COMPILED
		" (COMPILED)"
#else
		""
#endif
		);
	return 0;
}
Beispiel #3
0
int _fini(void)
{
	int status;

	status = mod_remove(&modlink1);
	if (status != 0)
		return status;
	RW_DESTROY(&ipf_mutex);
	RW_DESTROY(&ipf_global);
	return status;
}
Beispiel #4
0
void fr_scanunload()
{
	if (ipsc_inited == 1) {
		RW_DESTROY(&ipsc_rwlock);
		ipsc_inited = 0;
	}
}
Beispiel #5
0
int _init()
{
	int status;

	/*
	 * Initialize mutex's
	 */
	RWLOCK_INIT(&ipf_global, "ipf filter load/unload mutex");
	RWLOCK_INIT(&ipf_mutex, "ipf filter rwlock");
	status = mod_install(&modlink1);
	if (status != 0) {
		RW_DESTROY(&ipf_mutex);
		RW_DESTROY(&ipf_global);
	}
	return status;
}
Beispiel #6
0
/* ------------------------------------------------------------------------ */
void ip_lookup_unload()
{
	ip_pool_fini();
	fr_htable_unload();

	if (ip_lookup_inited == 1) {
		RW_DESTROY(&ip_poolrw);
		ip_lookup_inited = 0;
	}
}