-
Notifications
You must be signed in to change notification settings - Fork 11
/
COLO-library_for_iptables-1.4.21.patch
202 lines (199 loc) · 5.15 KB
/
COLO-library_for_iptables-1.4.21.patch
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
From 8efcddaf13a2ac4b72ca8989a19a7e76adb18c86 Mon Sep 17 00:00:00 2001
From: Gao feng <gaofeng@cn.fujitsu.com>
Date: Thu, 17 Jul 2014 15:21:09 +0800
Subject: [PATCH] add COLO library for iptables
Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
---
extensions/libxt_PMYCOLO.c | 76 +++++++++++++++++++++++++++++++++++++++
extensions/libxt_SECCOLO.c | 71 ++++++++++++++++++++++++++++++++++++
include/linux/netfilter/xt_COLO.h | 19 ++++++++++
3 files changed, 166 insertions(+)
create mode 100644 extensions/libxt_PMYCOLO.c
create mode 100644 extensions/libxt_SECCOLO.c
create mode 100644 include/linux/netfilter/xt_COLO.h
diff --git a/extensions/libxt_PMYCOLO.c b/extensions/libxt_PMYCOLO.c
new file mode 100644
index 0000000..3ea1570
--- /dev/null
+++ b/extensions/libxt_PMYCOLO.c
@@ -0,0 +1,76 @@
+/* Shared library add-on to iptables to add TRACE target support. */
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <getopt.h>
+
+#include <xtables.h>
+#include <linux/netfilter/x_tables.h>
+#include <linux/netfilter/xt_COLO.h>
+
+
+#define s struct xt_colo_primary_info
+static const struct xt_option_entry colo_opts[] = {
+ {.name = "index", .id = 0, .type = XTTYPE_UINT32,
+ .flags = XTOPT_PUT, XTOPT_POINTER(s, index),
+ .excl = 1},
+ XTOPT_TABLEEND,
+};
+#undef s
+
+
+static void colo_parse(struct xt_option_call *cb)
+{
+ struct xt_colo_primary_info *einfo = cb->data;
+
+ xtables_option_parse(cb);
+ einfo->index = cb->val.u32;
+}
+
+
+static void colo_print(const void *ip, const struct xt_entry_target *target,
+ int numeric)
+{
+ const struct xt_colo_primary_info *einfo =
+ (const struct xt_colo_primary_info *)target->data;
+
+ printf("PMYCOLO");
+
+ printf("index %d", einfo->index);
+}
+
+static void colo_save(const void *ip, const struct xt_entry_target *target)
+{
+ const struct xt_colo_primary_info *einfo =
+ (const struct xt_colo_primary_info *)target->data;
+
+ printf("--index %d", einfo->index);
+}
+/*
+static void colo_primary_init(struct xt_entry_target *target)
+{
+ struct xt_colo_primary_info *info = (void *)target->data;
+
+ info->index = 33;
+}
+*/
+static struct xtables_target colo_target = {
+ .family = NFPROTO_UNSPEC,
+ .name = "PMYCOLO",
+ .version = XTABLES_VERSION,
+ .size = XT_ALIGN(sizeof(struct xt_colo_primary_info)),
+ //.size = 0,
+ .userspacesize = offsetof(struct xt_colo_primary_info, colo),
+ //.userspacesize = XT_ALIGN(sizeof(struct xt_COLO_info)),
+ .save = colo_save,
+ .print = colo_print,
+ .x6_parse = colo_parse,
+ .x6_options = colo_opts,
+ //.init = colo_primary_init,
+};
+
+
+void _init(void)
+{
+ xtables_register_target(&colo_target);
+}
diff --git a/extensions/libxt_SECCOLO.c b/extensions/libxt_SECCOLO.c
new file mode 100644
index 0000000..de01323
--- /dev/null
+++ b/extensions/libxt_SECCOLO.c
@@ -0,0 +1,71 @@
+/* Shared library add-on to iptables to add TRACE target support. */
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <getopt.h>
+
+#include <xtables.h>
+#include <linux/netfilter/x_tables.h>
+#include <linux/netfilter/xt_COLO.h>
+
+#define s struct xt_colo_secondary_info
+static const struct xt_option_entry colo_opts[] = {
+ {.name = "index", .id = 0, .type = XTTYPE_UINT32,
+ .flags = XTOPT_PUT, XTOPT_POINTER(s, index),
+ .excl = 1},
+ XTOPT_TABLEEND,
+};
+#undef s
+
+static void colo_parse(struct xt_option_call *cb)
+{
+ struct xt_colo_secondary_info *einfo = cb->data;
+
+ xtables_option_parse(cb);
+ einfo->index = cb->val.u32;
+}
+
+static void colo_print(const void *ip, const struct xt_entry_target *target,
+ int numeric)
+{
+ const struct xt_colo_secondary_info *einfo =
+ (const struct xt_colo_secondary_info *)target->data;
+
+ printf("SECCOLO");
+
+ printf("index %d", einfo->index);
+}
+
+static void colo_save(const void *ip, const struct xt_entry_target *target)
+{
+ const struct xt_colo_secondary_info *einfo =
+ (const struct xt_colo_secondary_info *)target->data;
+
+ printf("--index %d", einfo->index);
+}
+/*
+static void colo_primary_init(struct xt_entry_target *target)
+{
+ struct xt_colo_primary_info *info = (void *)target->data;
+
+ info->index = 33;
+}
+*/
+static struct xtables_target colo_target = {
+ .family = NFPROTO_UNSPEC,
+ .name = "SECCOLO",
+ .version = XTABLES_VERSION,
+ .size = XT_ALIGN(sizeof(struct xt_colo_secondary_info)),
+ .userspacesize = offsetof(struct xt_colo_secondary_info, colo),
+ .save = colo_save,
+ .print = colo_print,
+ .x6_parse = colo_parse,
+ .x6_options = colo_opts,
+ //.init = colo_primary_init,
+};
+
+
+void _init(void)
+{
+ xtables_register_target(&colo_target);
+}
diff --git a/include/linux/netfilter/xt_COLO.h b/include/linux/netfilter/xt_COLO.h
new file mode 100644
index 0000000..45431ef
--- /dev/null
+++ b/include/linux/netfilter/xt_COLO.h
@@ -0,0 +1,19 @@
+#ifndef _XT_COLO_TARGET_H
+#define _XT_COLO_TARGET_H
+
+#include <linux/types.h>
+
+struct xt_colo_primary_info {
+ __u32 index;
+
+ /* for kernel module internal use only */
+ struct colo_primary *colo __attribute__((aligned(8)));
+};
+
+struct xt_colo_secondary_info {
+ __u32 index;
+
+ /* for kernel module internal use only */
+ struct colo_secondary *colo __attribute__((aligned(8)));
+};
+#endif
--
2.1.0