コード例 #1
0
int __init mipv6_initialize_bcache(__u32 size) 
{
	DEBUG_FUNC();

	if (size < 1) {
		DEBUG((DBG_ERROR, "Binding cache size must be at least 1"));
		return -1;
	}
		
	bcache = (struct mipv6_bcache *) 
		kmalloc(sizeof(struct mipv6_bcache), GFP_KERNEL);
	if (bcache == NULL) {
		DEBUG((DBG_ERROR, "Couldn't allocate memory for binding cache"));
		return -1;
	}

	init_timer(&bcache->callback_timer);
	bcache->callback_timer.data     = 0;
	bcache->callback_timer.function = timer_handler;

	bcache->size = size;
	bcache->lock = RW_LOCK_UNLOCKED;

	if ((bcache->entry_pool = mipv6_create_allocation_pool(
		size, sizeof(struct mipv6_bcache_entry), GFP_KERNEL)) == NULL)
	{
		DEBUG((DBG_ERROR, "mipv6_bcache_init(): Allocation pool creation failed"));
		kfree(bcache);
		return -1;
	}

	if ((bcache->entries = 
	     hashlist_create(size, MIPV6_BCACHE_HASHSIZE)) == NULL)
	{
		DEBUG((DBG_ERROR, "Failed to initialize hashlist"));
		mipv6_free_allocation_pool(bcache->entry_pool);
		kfree(bcache);
		return -1;
	}

#ifdef CONFIG_PROC_FS
	proc_net_create("mip6_bcache", 0, bcache_proc_info); 
#endif

	DEBUG((DBG_INFO, "Binding cache initialized"));
	return 0;
}
コード例 #2
0
int __init mipv6_initialize_halist(__u32 size)
{
	DEBUG_FUNC();

	if (size <= 0) {
		DEBUG((DBG_ERROR, "mipv6_initialize_halist: size must be at least 1"));
		return -1;
	}

	home_agents = (struct mipv6_halist *) 
		kmalloc(sizeof(struct mipv6_halist), GFP_KERNEL);
	if (home_agents == NULL) {
		DEBUG((DBG_ERROR, "Couldn't allocate memory for Home Agents List"));
		return -1;
	}

	init_timer(&home_agents->expire_timer);
	home_agents->expire_timer.data = 0;
	home_agents->expire_timer.function = mipv6_halist_expire;
	home_agents->lock = RW_LOCK_UNLOCKED;

	home_agents->entries = hashlist_create(size, 32);

	if (home_agents->entries == NULL) {
		DEBUG((DBG_ERROR, "Failed to initialize hashlist"));
		kfree(home_agents);
		return -1;
	}

#ifdef CONFIG_PROC_FS
	proc_net_create("mip6_home_agents", 0, halist_proc_info);
#endif /* CONFIG_PROC_FS */

	DEBUG((DBG_INFO, "Home Agents List initialized"));
	return 0;
}