Blame view
net/sched/act_ipt.c
10.2 KB
1da177e4c Linux-2.6.12-rc2 |
1 |
/* |
0c6965dd3 sched: fix act fi... |
2 |
* net/sched/act_ipt.c iptables target interface |
1da177e4c Linux-2.6.12-rc2 |
3 4 5 6 7 8 9 10 |
* *TODO: Add other tables. For now we only support the ipv4 table targets * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version * 2 of the License, or (at your option) any later version. * |
0dcffd096 net_sched: act_ip... |
11 |
* Copyright: Jamal Hadi Salim (2002-13) |
1da177e4c Linux-2.6.12-rc2 |
12 |
*/ |
1da177e4c Linux-2.6.12-rc2 |
13 14 |
#include <linux/types.h> #include <linux/kernel.h> |
1da177e4c Linux-2.6.12-rc2 |
15 |
#include <linux/string.h> |
1da177e4c Linux-2.6.12-rc2 |
16 |
#include <linux/errno.h> |
1da177e4c Linux-2.6.12-rc2 |
17 18 19 20 |
#include <linux/skbuff.h> #include <linux/rtnetlink.h> #include <linux/module.h> #include <linux/init.h> |
5a0e3ad6a include cleanup: ... |
21 |
#include <linux/slab.h> |
dc5fc579b [NETLINK]: Use nl... |
22 |
#include <net/netlink.h> |
1da177e4c Linux-2.6.12-rc2 |
23 24 25 26 27 |
#include <net/pkt_sched.h> #include <linux/tc_act/tc_ipt.h> #include <net/tc_act/tc_ipt.h> #include <linux/netfilter_ipv4/ip_tables.h> |
1da177e4c Linux-2.6.12-rc2 |
28 |
|
c7d03a00b netns: make struc... |
29 |
static unsigned int ipt_net_id; |
a85a970af net_sched: move t... |
30 |
static struct tc_action_ops act_ipt_ops; |
ddf97ccdd net_sched: add ne... |
31 |
|
c7d03a00b netns: make struc... |
32 |
static unsigned int xt_net_id; |
a85a970af net_sched: move t... |
33 |
static struct tc_action_ops act_xt_ops; |
ddf97ccdd net_sched: add ne... |
34 |
|
ec0acb093 net: sched: set x... |
35 36 |
static int ipt_init_target(struct net *net, struct xt_entry_target *t, char *table, unsigned int hook) |
1da177e4c Linux-2.6.12-rc2 |
37 |
{ |
af5d6dc20 netfilter: xtable... |
38 |
struct xt_tgchk_param par; |
e60a13e03 [NETFILTER]: {ip,... |
39 |
struct xt_target *target; |
4f8a881ac net: sched: fix N... |
40 |
struct ipt_entry e = {}; |
1da177e4c Linux-2.6.12-rc2 |
41 |
int ret = 0; |
239a87c87 [NET_SCHED]: act_... |
42 43 |
target = xt_request_find_target(AF_INET, t->u.user.name, t->u.user.revision); |
d2a7b6bad netfilter: xtable... |
44 45 |
if (IS_ERR(target)) return PTR_ERR(target); |
1da177e4c Linux-2.6.12-rc2 |
46 |
|
1da177e4c Linux-2.6.12-rc2 |
47 |
t->u.kernel.target = target; |
96d970305 net: sched: set x... |
48 |
memset(&par, 0, sizeof(par)); |
ec0acb093 net: sched: set x... |
49 |
par.net = net; |
af5d6dc20 netfilter: xtable... |
50 |
par.table = table; |
4f8a881ac net: sched: fix N... |
51 |
par.entryinfo = &e; |
af5d6dc20 netfilter: xtable... |
52 53 54 |
par.target = target; par.targinfo = t->data; par.hook_mask = hook; |
916a917df netfilter: xtable... |
55 |
par.family = NFPROTO_IPV4; |
1da177e4c Linux-2.6.12-rc2 |
56 |
|
916a917df netfilter: xtable... |
57 |
ret = xt_check_target(&par, t->u.target_size - sizeof(*t), 0, false); |
367c67900 netfilter: xtable... |
58 |
if (ret < 0) { |
239a87c87 [NET_SCHED]: act_... |
59 |
module_put(t->u.kernel.target->me); |
18118cdbf [NETFILTER]: ipt ... |
60 |
return ret; |
239a87c87 [NET_SCHED]: act_... |
61 |
} |
367c67900 netfilter: xtable... |
62 |
return 0; |
1da177e4c Linux-2.6.12-rc2 |
63 |
} |
87a2e70db netfilter: xtable... |
64 |
static void ipt_destroy_target(struct xt_entry_target *t) |
1da177e4c Linux-2.6.12-rc2 |
65 |
{ |
a2df1648b netfilter: xtable... |
66 67 68 |
struct xt_tgdtor_param par = { .target = t->u.kernel.target, .targinfo = t->data, |
44ef548f4 net: sched: fix a... |
69 |
.family = NFPROTO_IPV4, |
a2df1648b netfilter: xtable... |
70 71 72 73 |
}; if (par.target->destroy != NULL) par.target->destroy(&par); module_put(par.target->me); |
1da177e4c Linux-2.6.12-rc2 |
74 |
} |
a5b5c958f net_sched: act: r... |
75 |
static void tcf_ipt_release(struct tc_action *a, int bind) |
1da177e4c Linux-2.6.12-rc2 |
76 |
{ |
86062033f net_sched: act: h... |
77 |
struct tcf_ipt *ipt = to_ipt(a); |
91314c273 net/sched: fix id... |
78 79 80 81 82 |
if (ipt->tcfi_t) { ipt_destroy_target(ipt->tcfi_t); kfree(ipt->tcfi_t); } |
a5b5c958f net_sched: act: r... |
83 |
kfree(ipt->tcfi_tname); |
1da177e4c Linux-2.6.12-rc2 |
84 |
} |
53b2bf3f8 [NET_SCHED]: Use ... |
85 86 87 88 |
static const struct nla_policy ipt_policy[TCA_IPT_MAX + 1] = { [TCA_IPT_TABLE] = { .type = NLA_STRING, .len = IFNAMSIZ }, [TCA_IPT_HOOK] = { .type = NLA_U32 }, [TCA_IPT_INDEX] = { .type = NLA_U32 }, |
87a2e70db netfilter: xtable... |
89 |
[TCA_IPT_TARG] = { .len = sizeof(struct xt_entry_target) }, |
53b2bf3f8 [NET_SCHED]: Use ... |
90 |
}; |
ec0acb093 net: sched: set x... |
91 |
static int __tcf_ipt_init(struct net *net, unsigned int id, struct nlattr *nla, |
a85a970af net_sched: move t... |
92 93 |
struct nlattr *est, struct tc_action **a, const struct tc_action_ops *ops, int ovr, int bind) |
1da177e4c Linux-2.6.12-rc2 |
94 |
{ |
ec0acb093 net: sched: set x... |
95 |
struct tc_action_net *tn = net_generic(net, id); |
7ba699c60 [NET_SCHED]: Conv... |
96 |
struct nlattr *tb[TCA_IPT_MAX + 1]; |
e9ce1cd3c [PKT_SCHED]: Kill... |
97 |
struct tcf_ipt *ipt; |
87a2e70db netfilter: xtable... |
98 |
struct xt_entry_target *td, *t; |
1da177e4c Linux-2.6.12-rc2 |
99 |
char *tname; |
b2313077e net_sched: make t... |
100 101 |
bool exists = false; int ret = 0, err; |
1da177e4c Linux-2.6.12-rc2 |
102 103 |
u32 hook = 0; u32 index = 0; |
cee63723b [NET_SCHED]: Prop... |
104 |
if (nla == NULL) |
1da177e4c Linux-2.6.12-rc2 |
105 |
return -EINVAL; |
fceb6435e netlink: pass ext... |
106 |
err = nla_parse_nested(tb, TCA_IPT_MAX, nla, ipt_policy, NULL); |
cee63723b [NET_SCHED]: Prop... |
107 108 |
if (err < 0) return err; |
a57f19d30 net sched: ipt ac... |
109 110 |
if (tb[TCA_IPT_INDEX] != NULL) index = nla_get_u32(tb[TCA_IPT_INDEX]); |
65a206c01 net/sched: Change... |
111 |
exists = tcf_idr_check(tn, index, a, bind); |
a57f19d30 net sched: ipt ac... |
112 113 114 115 116 |
if (exists && bind) return 0; if (tb[TCA_IPT_HOOK] == NULL || tb[TCA_IPT_TARG] == NULL) { if (exists) |
65a206c01 net/sched: Change... |
117 |
tcf_idr_release(*a, bind); |
1da177e4c Linux-2.6.12-rc2 |
118 |
return -EINVAL; |
a57f19d30 net sched: ipt ac... |
119 |
} |
53b2bf3f8 [NET_SCHED]: Use ... |
120 |
|
87a2e70db netfilter: xtable... |
121 |
td = (struct xt_entry_target *)nla_data(tb[TCA_IPT_TARG]); |
d15eccea6 act_ipt: fix a bi... |
122 123 |
if (nla_len(tb[TCA_IPT_TARG]) < td->u.target_size) { if (exists) |
65a206c01 net/sched: Change... |
124 |
tcf_idr_release(*a, bind); |
1da177e4c Linux-2.6.12-rc2 |
125 |
return -EINVAL; |
d15eccea6 act_ipt: fix a bi... |
126 |
} |
1da177e4c Linux-2.6.12-rc2 |
127 |
|
d15eccea6 act_ipt: fix a bi... |
128 |
if (!exists) { |
65a206c01 net/sched: Change... |
129 130 |
ret = tcf_idr_create(tn, index, est, a, ops, bind, false); |
86062033f net_sched: act: h... |
131 132 |
if (ret) return ret; |
1da177e4c Linux-2.6.12-rc2 |
133 134 |
ret = ACT_P_CREATED; } else { |
1a29321ed net_sched: act: D... |
135 136 |
if (bind)/* dont override defaults */ return 0; |
65a206c01 net/sched: Change... |
137 |
tcf_idr_release(*a, bind); |
1a29321ed net_sched: act: D... |
138 139 |
if (!ovr) |
1da177e4c Linux-2.6.12-rc2 |
140 |
return -EEXIST; |
1da177e4c Linux-2.6.12-rc2 |
141 |
} |
1587bac49 [NET_SCHED]: Use ... |
142 |
hook = nla_get_u32(tb[TCA_IPT_HOOK]); |
1da177e4c Linux-2.6.12-rc2 |
143 144 145 |
err = -ENOMEM; tname = kmalloc(IFNAMSIZ, GFP_KERNEL); |
e9ce1cd3c [PKT_SCHED]: Kill... |
146 |
if (unlikely(!tname)) |
1da177e4c Linux-2.6.12-rc2 |
147 |
goto err1; |
7ba699c60 [NET_SCHED]: Conv... |
148 149 |
if (tb[TCA_IPT_TABLE] == NULL || nla_strlcpy(tname, tb[TCA_IPT_TABLE], IFNAMSIZ) >= IFNAMSIZ) |
1da177e4c Linux-2.6.12-rc2 |
150 |
strcpy(tname, "mangle"); |
c7b1b2497 [SCHED]: Use kmem... |
151 |
t = kmemdup(td, td->u.target_size, GFP_KERNEL); |
e9ce1cd3c [PKT_SCHED]: Kill... |
152 |
if (unlikely(!t)) |
1da177e4c Linux-2.6.12-rc2 |
153 |
goto err2; |
1da177e4c Linux-2.6.12-rc2 |
154 |
|
ec0acb093 net: sched: set x... |
155 |
err = ipt_init_target(net, t, tname, hook); |
cc7ec456f net_sched: cleanups |
156 |
if (err < 0) |
1da177e4c Linux-2.6.12-rc2 |
157 |
goto err3; |
a85a970af net_sched: move t... |
158 |
ipt = to_ipt(*a); |
e9ce1cd3c [PKT_SCHED]: Kill... |
159 |
spin_lock_bh(&ipt->tcf_lock); |
1da177e4c Linux-2.6.12-rc2 |
160 |
if (ret != ACT_P_CREATED) { |
e9ce1cd3c [PKT_SCHED]: Kill... |
161 162 163 |
ipt_destroy_target(ipt->tcfi_t); kfree(ipt->tcfi_tname); kfree(ipt->tcfi_t); |
1da177e4c Linux-2.6.12-rc2 |
164 |
} |
e9ce1cd3c [PKT_SCHED]: Kill... |
165 166 167 168 |
ipt->tcfi_tname = tname; ipt->tcfi_t = t; ipt->tcfi_hook = hook; spin_unlock_bh(&ipt->tcf_lock); |
1da177e4c Linux-2.6.12-rc2 |
169 |
if (ret == ACT_P_CREATED) |
65a206c01 net/sched: Change... |
170 |
tcf_idr_insert(tn, *a); |
1da177e4c Linux-2.6.12-rc2 |
171 172 173 174 175 176 177 |
return ret; err3: kfree(t); err2: kfree(tname); err1: |
86062033f net_sched: act: h... |
178 |
if (ret == ACT_P_CREATED) |
91314c273 net/sched: fix id... |
179 |
tcf_idr_release(*a, bind); |
1da177e4c Linux-2.6.12-rc2 |
180 181 |
return err; } |
ddf97ccdd net_sched: add ne... |
182 |
static int tcf_ipt_init(struct net *net, struct nlattr *nla, |
a85a970af net_sched: move t... |
183 |
struct nlattr *est, struct tc_action **a, int ovr, |
ddf97ccdd net_sched: add ne... |
184 185 |
int bind) { |
ec0acb093 net: sched: set x... |
186 187 |
return __tcf_ipt_init(net, ipt_net_id, nla, est, a, &act_ipt_ops, ovr, bind); |
ddf97ccdd net_sched: add ne... |
188 189 190 |
} static int tcf_xt_init(struct net *net, struct nlattr *nla, |
a85a970af net_sched: move t... |
191 |
struct nlattr *est, struct tc_action **a, int ovr, |
ddf97ccdd net_sched: add ne... |
192 193 |
int bind) { |
ec0acb093 net: sched: set x... |
194 195 |
return __tcf_ipt_init(net, xt_net_id, nla, est, a, &act_xt_ops, ovr, bind); |
ddf97ccdd net_sched: add ne... |
196 |
} |
dc7f9f6e8 net: sched: const... |
197 |
static int tcf_ipt(struct sk_buff *skb, const struct tc_action *a, |
e9ce1cd3c [PKT_SCHED]: Kill... |
198 |
struct tcf_result *res) |
1da177e4c Linux-2.6.12-rc2 |
199 200 |
{ int ret = 0, result = 0; |
a85a970af net_sched: move t... |
201 |
struct tcf_ipt *ipt = to_ipt(a); |
4b560b447 netfilter: xtable... |
202 |
struct xt_action_param par; |
613dbd957 netfilter: x_tabl... |
203 204 205 206 207 208 |
struct nf_hook_state state = { .net = dev_net(skb->dev), .in = skb->dev, .hook = ipt->tcfi_hook, .pf = NFPROTO_IPV4, }; |
1da177e4c Linux-2.6.12-rc2 |
209 |
|
14bbd6a56 net: Add skb_uncl... |
210 211 |
if (skb_unclone(skb, GFP_ATOMIC)) return TC_ACT_UNSPEC; |
1da177e4c Linux-2.6.12-rc2 |
212 |
|
e9ce1cd3c [PKT_SCHED]: Kill... |
213 |
spin_lock(&ipt->tcf_lock); |
1da177e4c Linux-2.6.12-rc2 |
214 |
|
9c4a4e488 net sched: action... |
215 |
tcf_lastuse_update(&ipt->tcf_tm); |
bfe0d0298 net_sched: factor... |
216 |
bstats_update(&ipt->tcf_bstats, skb); |
1da177e4c Linux-2.6.12-rc2 |
217 218 |
/* yes, we have to worry about both in and out dev |
cc7ec456f net_sched: cleanups |
219 220 221 |
* worry later - danger - this API seems to have changed * from earlier kernels */ |
613dbd957 netfilter: x_tabl... |
222 |
par.state = &state; |
7eb355865 netfilter: xtable... |
223 224 225 |
par.target = ipt->tcfi_t->u.kernel.target; par.targinfo = ipt->tcfi_t->data; ret = par.target->target(skb, &par); |
1da177e4c Linux-2.6.12-rc2 |
226 227 228 229 230 231 |
switch (ret) { case NF_ACCEPT: result = TC_ACT_OK; break; case NF_DROP: result = TC_ACT_SHOT; |
e9ce1cd3c [PKT_SCHED]: Kill... |
232 |
ipt->tcf_qstats.drops++; |
1da177e4c Linux-2.6.12-rc2 |
233 |
break; |
243bf6e29 netfilter: xtable... |
234 |
case XT_CONTINUE: |
1da177e4c Linux-2.6.12-rc2 |
235 236 237 |
result = TC_ACT_PIPE; break; default: |
e87cc4728 net: Convert net_... |
238 239 240 |
net_notice_ratelimited("tc filter: Bogus netfilter code %d assume ACCEPT ", ret); |
95df1b160 net_sched: remove... |
241 |
result = TC_ACT_OK; |
1da177e4c Linux-2.6.12-rc2 |
242 243 |
break; } |
e9ce1cd3c [PKT_SCHED]: Kill... |
244 |
spin_unlock(&ipt->tcf_lock); |
1da177e4c Linux-2.6.12-rc2 |
245 246 247 |
return result; } |
0b0f43fe2 net sched: indent... |
248 249 |
static int tcf_ipt_dump(struct sk_buff *skb, struct tc_action *a, int bind, int ref) |
1da177e4c Linux-2.6.12-rc2 |
250 |
{ |
27a884dc3 [SK_BUFF]: Conver... |
251 |
unsigned char *b = skb_tail_pointer(skb); |
a85a970af net_sched: move t... |
252 |
struct tcf_ipt *ipt = to_ipt(a); |
87a2e70db netfilter: xtable... |
253 |
struct xt_entry_target *t; |
1da177e4c Linux-2.6.12-rc2 |
254 255 |
struct tcf_t tm; struct tc_cnt c; |
1da177e4c Linux-2.6.12-rc2 |
256 257 |
/* for simple targets kernel size == user size |
cc7ec456f net_sched: cleanups |
258 259 260 |
* user name = target name * for foolproof you need to not assume this */ |
1da177e4c Linux-2.6.12-rc2 |
261 |
|
c7b1b2497 [SCHED]: Use kmem... |
262 |
t = kmemdup(ipt->tcfi_t, ipt->tcfi_t->u.user.target_size, GFP_ATOMIC); |
e9ce1cd3c [PKT_SCHED]: Kill... |
263 |
if (unlikely(!t)) |
7ba699c60 [NET_SCHED]: Conv... |
264 |
goto nla_put_failure; |
1da177e4c Linux-2.6.12-rc2 |
265 |
|
e9ce1cd3c [PKT_SCHED]: Kill... |
266 267 |
c.bindcnt = ipt->tcf_bindcnt - bind; c.refcnt = ipt->tcf_refcnt - ref; |
e9ce1cd3c [PKT_SCHED]: Kill... |
268 |
strcpy(t->u.user.name, ipt->tcfi_t->u.kernel.target->name); |
1b34ec43c pkt_sched: Stop u... |
269 270 271 272 273 274 |
if (nla_put(skb, TCA_IPT_TARG, ipt->tcfi_t->u.user.target_size, t) || nla_put_u32(skb, TCA_IPT_INDEX, ipt->tcf_index) || nla_put_u32(skb, TCA_IPT_HOOK, ipt->tcfi_hook) || nla_put(skb, TCA_IPT_CNT, sizeof(struct tc_cnt), &c) || nla_put_string(skb, TCA_IPT_TABLE, ipt->tcfi_tname)) goto nla_put_failure; |
48d8ee169 net sched actions... |
275 276 |
tcf_tm_dump(&tm, &ipt->tcf_tm); |
9854518ea sched: align nlat... |
277 |
if (nla_put_64bit(skb, TCA_IPT_TM, sizeof(tm), &tm, TCA_IPT_PAD)) |
1b34ec43c pkt_sched: Stop u... |
278 |
goto nla_put_failure; |
48d8ee169 net sched actions... |
279 |
|
1da177e4c Linux-2.6.12-rc2 |
280 281 |
kfree(t); return skb->len; |
7ba699c60 [NET_SCHED]: Conv... |
282 |
nla_put_failure: |
dc5fc579b [NETLINK]: Use nl... |
283 |
nlmsg_trim(skb, b); |
1da177e4c Linux-2.6.12-rc2 |
284 285 286 |
kfree(t); return -1; } |
ddf97ccdd net_sched: add ne... |
287 288 |
static int tcf_ipt_walker(struct net *net, struct sk_buff *skb, struct netlink_callback *cb, int type, |
a85a970af net_sched: move t... |
289 |
const struct tc_action_ops *ops) |
ddf97ccdd net_sched: add ne... |
290 291 |
{ struct tc_action_net *tn = net_generic(net, ipt_net_id); |
a85a970af net_sched: move t... |
292 |
return tcf_generic_walker(tn, skb, cb, type, ops); |
ddf97ccdd net_sched: add ne... |
293 |
} |
a85a970af net_sched: move t... |
294 |
static int tcf_ipt_search(struct net *net, struct tc_action **a, u32 index) |
ddf97ccdd net_sched: add ne... |
295 296 |
{ struct tc_action_net *tn = net_generic(net, ipt_net_id); |
65a206c01 net/sched: Change... |
297 |
return tcf_idr_search(tn, a, index); |
ddf97ccdd net_sched: add ne... |
298 |
} |
1da177e4c Linux-2.6.12-rc2 |
299 300 301 |
static struct tc_action_ops act_ipt_ops = { .kind = "ipt", .type = TCA_ACT_IPT, |
1da177e4c Linux-2.6.12-rc2 |
302 303 304 |
.owner = THIS_MODULE, .act = tcf_ipt, .dump = tcf_ipt_dump, |
86062033f net_sched: act: h... |
305 |
.cleanup = tcf_ipt_release, |
1da177e4c Linux-2.6.12-rc2 |
306 |
.init = tcf_ipt_init, |
ddf97ccdd net_sched: add ne... |
307 308 |
.walk = tcf_ipt_walker, .lookup = tcf_ipt_search, |
a85a970af net_sched: move t... |
309 |
.size = sizeof(struct tcf_ipt), |
ddf97ccdd net_sched: add ne... |
310 311 312 313 314 |
}; static __net_init int ipt_init_net(struct net *net) { struct tc_action_net *tn = net_generic(net, ipt_net_id); |
c7e460ce5 Revert "net_sched... |
315 |
return tc_action_net_init(tn, &act_ipt_ops); |
ddf97ccdd net_sched: add ne... |
316 317 318 319 320 321 322 323 324 325 326 327 328 329 |
} static void __net_exit ipt_exit_net(struct net *net) { struct tc_action_net *tn = net_generic(net, ipt_net_id); tc_action_net_exit(tn); } static struct pernet_operations ipt_net_ops = { .init = ipt_init_net, .exit = ipt_exit_net, .id = &ipt_net_id, .size = sizeof(struct tc_action_net), |
1da177e4c Linux-2.6.12-rc2 |
330 |
}; |
ddf97ccdd net_sched: add ne... |
331 332 |
static int tcf_xt_walker(struct net *net, struct sk_buff *skb, struct netlink_callback *cb, int type, |
a85a970af net_sched: move t... |
333 |
const struct tc_action_ops *ops) |
ddf97ccdd net_sched: add ne... |
334 335 |
{ struct tc_action_net *tn = net_generic(net, xt_net_id); |
a85a970af net_sched: move t... |
336 |
return tcf_generic_walker(tn, skb, cb, type, ops); |
ddf97ccdd net_sched: add ne... |
337 |
} |
a85a970af net_sched: move t... |
338 |
static int tcf_xt_search(struct net *net, struct tc_action **a, u32 index) |
ddf97ccdd net_sched: add ne... |
339 340 |
{ struct tc_action_net *tn = net_generic(net, xt_net_id); |
65a206c01 net/sched: Change... |
341 |
return tcf_idr_search(tn, a, index); |
ddf97ccdd net_sched: add ne... |
342 |
} |
0dcffd096 net_sched: act_ip... |
343 344 |
static struct tc_action_ops act_xt_ops = { .kind = "xt", |
6c80563c2 net_sched: act: p... |
345 |
.type = TCA_ACT_XT, |
0dcffd096 net_sched: act_ip... |
346 347 348 |
.owner = THIS_MODULE, .act = tcf_ipt, .dump = tcf_ipt_dump, |
86062033f net_sched: act: h... |
349 |
.cleanup = tcf_ipt_release, |
ddf97ccdd net_sched: add ne... |
350 351 352 |
.init = tcf_xt_init, .walk = tcf_xt_walker, .lookup = tcf_xt_search, |
a85a970af net_sched: move t... |
353 |
.size = sizeof(struct tcf_ipt), |
ddf97ccdd net_sched: add ne... |
354 355 356 357 358 |
}; static __net_init int xt_init_net(struct net *net) { struct tc_action_net *tn = net_generic(net, xt_net_id); |
c7e460ce5 Revert "net_sched... |
359 |
return tc_action_net_init(tn, &act_xt_ops); |
ddf97ccdd net_sched: add ne... |
360 361 362 363 364 365 366 367 368 369 370 371 372 373 |
} static void __net_exit xt_exit_net(struct net *net) { struct tc_action_net *tn = net_generic(net, xt_net_id); tc_action_net_exit(tn); } static struct pernet_operations xt_net_ops = { .init = xt_init_net, .exit = xt_exit_net, .id = &xt_net_id, .size = sizeof(struct tc_action_net), |
0dcffd096 net_sched: act_ip... |
374 375 376 |
}; MODULE_AUTHOR("Jamal Hadi Salim(2002-13)"); |
1da177e4c Linux-2.6.12-rc2 |
377 378 |
MODULE_DESCRIPTION("Iptables target actions"); MODULE_LICENSE("GPL"); |
0dcffd096 net_sched: act_ip... |
379 |
MODULE_ALIAS("act_xt"); |
1da177e4c Linux-2.6.12-rc2 |
380 |
|
e9ce1cd3c [PKT_SCHED]: Kill... |
381 |
static int __init ipt_init_module(void) |
1da177e4c Linux-2.6.12-rc2 |
382 |
{ |
4f1e9d894 net_sched: act: m... |
383 |
int ret1, ret2; |
369ba5678 net_sched: init s... |
384 |
|
ddf97ccdd net_sched: add ne... |
385 |
ret1 = tcf_register_action(&act_xt_ops, &xt_net_ops); |
0dcffd096 net_sched: act_ip... |
386 |
if (ret1 < 0) |
ddf97ccdd net_sched: add ne... |
387 388 389 390 |
pr_err("Failed to load xt action "); ret2 = tcf_register_action(&act_ipt_ops, &ipt_net_ops); |
0dcffd096 net_sched: act_ip... |
391 |
if (ret2 < 0) |
ddf97ccdd net_sched: add ne... |
392 393 |
pr_err("Failed to load ipt action "); |
0dcffd096 net_sched: act_ip... |
394 |
|
369ba5678 net_sched: init s... |
395 |
if (ret1 < 0 && ret2 < 0) { |
0dcffd096 net_sched: act_ip... |
396 |
return ret1; |
369ba5678 net_sched: init s... |
397 |
} else |
0dcffd096 net_sched: act_ip... |
398 |
return 0; |
1da177e4c Linux-2.6.12-rc2 |
399 |
} |
e9ce1cd3c [PKT_SCHED]: Kill... |
400 |
static void __exit ipt_cleanup_module(void) |
1da177e4c Linux-2.6.12-rc2 |
401 |
{ |
ddf97ccdd net_sched: add ne... |
402 403 |
tcf_unregister_action(&act_ipt_ops, &ipt_net_ops); tcf_unregister_action(&act_xt_ops, &xt_net_ops); |
1da177e4c Linux-2.6.12-rc2 |
404 405 406 407 |
} module_init(ipt_init_module); module_exit(ipt_cleanup_module); |