@@ -24,10 +24,9 @@ MODULE_ALIAS("ip6t_SECMARK");
24
24
static u8 mode ;
25
25
26
26
static unsigned int
27
- secmark_tg (struct sk_buff * skb , const struct xt_action_param * par )
27
+ secmark_tg (struct sk_buff * skb , const struct xt_secmark_target_info_v1 * info )
28
28
{
29
29
u32 secmark = 0 ;
30
- const struct xt_secmark_target_info * info = par -> targinfo ;
31
30
32
31
switch (mode ) {
33
32
case SECMARK_MODE_SEL :
@@ -41,7 +40,7 @@ secmark_tg(struct sk_buff *skb, const struct xt_action_param *par)
41
40
return XT_CONTINUE ;
42
41
}
43
42
44
- static int checkentry_lsm (struct xt_secmark_target_info * info )
43
+ static int checkentry_lsm (struct xt_secmark_target_info_v1 * info )
45
44
{
46
45
int err ;
47
46
@@ -73,15 +72,15 @@ static int checkentry_lsm(struct xt_secmark_target_info *info)
73
72
return 0 ;
74
73
}
75
74
76
- static int secmark_tg_check (const struct xt_tgchk_param * par )
75
+ static int
76
+ secmark_tg_check (const char * table , struct xt_secmark_target_info_v1 * info )
77
77
{
78
- struct xt_secmark_target_info * info = par -> targinfo ;
79
78
int err ;
80
79
81
- if (strcmp (par -> table , "mangle" ) != 0 &&
82
- strcmp (par -> table , "security" ) != 0 ) {
80
+ if (strcmp (table , "mangle" ) != 0 &&
81
+ strcmp (table , "security" ) != 0 ) {
83
82
pr_info_ratelimited ("only valid in \'mangle\' or \'security\' table, not \'%s\'\n" ,
84
- par -> table );
83
+ table );
85
84
return - EINVAL ;
86
85
}
87
86
@@ -116,25 +115,76 @@ static void secmark_tg_destroy(const struct xt_tgdtor_param *par)
116
115
}
117
116
}
118
117
119
- static struct xt_target secmark_tg_reg __read_mostly = {
120
- .name = "SECMARK" ,
121
- .revision = 0 ,
122
- .family = NFPROTO_UNSPEC ,
123
- .checkentry = secmark_tg_check ,
124
- .destroy = secmark_tg_destroy ,
125
- .target = secmark_tg ,
126
- .targetsize = sizeof (struct xt_secmark_target_info ),
127
- .me = THIS_MODULE ,
118
+ static int secmark_tg_check_v0 (const struct xt_tgchk_param * par )
119
+ {
120
+ struct xt_secmark_target_info * info = par -> targinfo ;
121
+ struct xt_secmark_target_info_v1 newinfo = {
122
+ .mode = info -> mode ,
123
+ };
124
+ int ret ;
125
+
126
+ memcpy (newinfo .secctx , info -> secctx , SECMARK_SECCTX_MAX );
127
+
128
+ ret = secmark_tg_check (par -> table , & newinfo );
129
+ info -> secid = newinfo .secid ;
130
+
131
+ return ret ;
132
+ }
133
+
134
+ static unsigned int
135
+ secmark_tg_v0 (struct sk_buff * skb , const struct xt_action_param * par )
136
+ {
137
+ const struct xt_secmark_target_info * info = par -> targinfo ;
138
+ struct xt_secmark_target_info_v1 newinfo = {
139
+ .secid = info -> secid ,
140
+ };
141
+
142
+ return secmark_tg (skb , & newinfo );
143
+ }
144
+
145
+ static int secmark_tg_check_v1 (const struct xt_tgchk_param * par )
146
+ {
147
+ return secmark_tg_check (par -> table , par -> targinfo );
148
+ }
149
+
150
+ static unsigned int
151
+ secmark_tg_v1 (struct sk_buff * skb , const struct xt_action_param * par )
152
+ {
153
+ return secmark_tg (skb , par -> targinfo );
154
+ }
155
+
156
+ static struct xt_target secmark_tg_reg [] __read_mostly = {
157
+ {
158
+ .name = "SECMARK" ,
159
+ .revision = 0 ,
160
+ .family = NFPROTO_UNSPEC ,
161
+ .checkentry = secmark_tg_check_v0 ,
162
+ .destroy = secmark_tg_destroy ,
163
+ .target = secmark_tg_v0 ,
164
+ .targetsize = sizeof (struct xt_secmark_target_info ),
165
+ .me = THIS_MODULE ,
166
+ },
167
+ {
168
+ .name = "SECMARK" ,
169
+ .revision = 1 ,
170
+ .family = NFPROTO_UNSPEC ,
171
+ .checkentry = secmark_tg_check_v1 ,
172
+ .destroy = secmark_tg_destroy ,
173
+ .target = secmark_tg_v1 ,
174
+ .targetsize = sizeof (struct xt_secmark_target_info_v1 ),
175
+ .usersize = offsetof(struct xt_secmark_target_info_v1 , secid ),
176
+ .me = THIS_MODULE ,
177
+ },
128
178
};
129
179
130
180
static int __init secmark_tg_init (void )
131
181
{
132
- return xt_register_target ( & secmark_tg_reg );
182
+ return xt_register_targets ( secmark_tg_reg , ARRAY_SIZE ( secmark_tg_reg ) );
133
183
}
134
184
135
185
static void __exit secmark_tg_exit (void )
136
186
{
137
- xt_unregister_target ( & secmark_tg_reg );
187
+ xt_unregister_targets ( secmark_tg_reg , ARRAY_SIZE ( secmark_tg_reg ) );
138
188
}
139
189
140
190
module_init (secmark_tg_init );
0 commit comments