5 * Bart De Schuymer <bdschuym@pandora.be>
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.
16 #include <linux/netfilter_bridge/ebtables.h>
17 #include <linux/netfilter_bridge/ebt_mark_t.h>
18 #include <linux/module.h>
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)
24 struct ebt_mark_t_info *info = (struct ebt_mark_t_info *)data;
25 int action = info->target & -16;
27 if (action == MARK_SET_VALUE)
28 (*pskb)->mark = info->mark;
29 else if (action == MARK_OR_VALUE)
30 (*pskb)->mark |= info->mark;
31 else if (action == MARK_AND_VALUE)
32 (*pskb)->mark &= info->mark;
34 (*pskb)->mark ^= info->mark;
36 return info->target | -16;
39 static int ebt_target_mark_check(const char *tablename, unsigned int hookmask,
40 const struct ebt_entry *e, void *data, unsigned int datalen)
42 struct ebt_mark_t_info *info = (struct ebt_mark_t_info *)data;
45 if (datalen != EBT_ALIGN(sizeof(struct ebt_mark_t_info)))
47 tmp = info->target | -16;
48 if (BASE_CHAIN && tmp == EBT_RETURN)
51 if (tmp < -NUM_STANDARD_TARGETS || tmp >= 0)
53 tmp = info->target & -16;
54 if (tmp != MARK_SET_VALUE && tmp != MARK_OR_VALUE &&
55 tmp != MARK_AND_VALUE && tmp != MARK_XOR_VALUE)
60 static struct ebt_target mark_target =
62 .name = EBT_MARK_TARGET,
63 .target = ebt_target_mark,
64 .check = ebt_target_mark_check,
68 static int __init ebt_mark_init(void)
70 return ebt_register_target(&mark_target);
73 static void __exit ebt_mark_fini(void)
75 ebt_unregister_target(&mark_target);
78 module_init(ebt_mark_init);
79 module_exit(ebt_mark_fini);
80 MODULE_LICENSE("GPL");