]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * ebt_mark | |
3 | * | |
4 | * Authors: | |
5 | * Bart De Schuymer <bdschuym@pandora.be> | |
6 | * | |
7 | * July, 2002 | |
8 | * | |
9 | */ | |
10 | ||
11 | /* The mark target can be used in any chain, | |
12 | * I believe adding a mangle table just for marking is total overkill. | |
13 | * Marking a frame doesn't really change anything in the frame anyway. | |
14 | */ | |
15 | ||
16 | #include <linux/netfilter_bridge/ebtables.h> | |
17 | #include <linux/netfilter_bridge/ebt_mark_t.h> | |
18 | #include <linux/module.h> | |
19 | ||
20 | static int ebt_target_mark(struct sk_buff **pskb, unsigned int hooknr, | |
21 | const struct net_device *in, const struct net_device *out, | |
22 | const void *data, unsigned int datalen) | |
23 | { | |
24 | struct ebt_mark_t_info *info = (struct ebt_mark_t_info *)data; | |
25 | ||
6869c4d8 | 26 | if ((*pskb)->nfmark != info->mark) |
1da177e4 | 27 | (*pskb)->nfmark = info->mark; |
6869c4d8 | 28 | |
1da177e4 LT |
29 | return info->target; |
30 | } | |
31 | ||
32 | static int ebt_target_mark_check(const char *tablename, unsigned int hookmask, | |
33 | const struct ebt_entry *e, void *data, unsigned int datalen) | |
34 | { | |
35 | struct ebt_mark_t_info *info = (struct ebt_mark_t_info *)data; | |
36 | ||
37 | if (datalen != EBT_ALIGN(sizeof(struct ebt_mark_t_info))) | |
38 | return -EINVAL; | |
39 | if (BASE_CHAIN && info->target == EBT_RETURN) | |
40 | return -EINVAL; | |
41 | CLEAR_BASE_CHAIN_BIT; | |
42 | if (INVALID_TARGET) | |
43 | return -EINVAL; | |
44 | return 0; | |
45 | } | |
46 | ||
47 | static struct ebt_target mark_target = | |
48 | { | |
49 | .name = EBT_MARK_TARGET, | |
50 | .target = ebt_target_mark, | |
51 | .check = ebt_target_mark_check, | |
52 | .me = THIS_MODULE, | |
53 | }; | |
54 | ||
55 | static int __init init(void) | |
56 | { | |
57 | return ebt_register_target(&mark_target); | |
58 | } | |
59 | ||
60 | static void __exit fini(void) | |
61 | { | |
62 | ebt_unregister_target(&mark_target); | |
63 | } | |
64 | ||
65 | module_init(init); | |
66 | module_exit(fini); | |
67 | MODULE_LICENSE("GPL"); |