-
Notifications
You must be signed in to change notification settings - Fork 2
/
module.c
59 lines (46 loc) · 1.11 KB
/
module.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include "module.h"
#include "sysfs.h"
#include "server.h"
static struct tlb_context g_context;
static int __init tlb_init(void)
{
int r;
pr_info("tlb: initing\n");
r = coroutine_init();
if (r)
goto fail;
r = tlb_server_cache_init();
if (r)
goto fail_coroutine_deinit;
r = tlb_server_init(&g_context.srv);
if (r)
goto fail_server_cache_deinit;
r = tlb_sysfs_init(&g_context.kobj_holder, fs_kobj, &tlb_ktype, "%s", "tlb");
if (r)
goto fail_server_deinit;
pr_info("tlb: inited r %d\n", r);
return r;
fail_server_deinit:
tlb_server_stop(&g_context.srv);
fail_server_cache_deinit:
tlb_server_cache_deinit();
fail_coroutine_deinit:
coroutine_deinit();
fail:
pr_err("tlb: inited r %d\n", r);
return r;
}
static void __exit tlb_exit(void)
{
pr_info("tlb: exiting\n");
tlb_sysfs_deinit(&g_context.kobj_holder);
tlb_server_stop(&g_context.srv);
tlb_server_cache_deinit();
coroutine_deinit();
pr_info("tlb: exited\n");
}
module_init(tlb_init)
module_exit(tlb_exit)
MODULE_AUTHOR("Andrey Smetanin <irqlevel@gmail.com>");
MODULE_DESCRIPTION("Tcp connection based load balancer");
MODULE_LICENSE("GPL");