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
*skb
, unsigned int hooknr
,
21 const struct net_device
*in
, const struct net_device
*out
,
22 const void *data
, unsigned int datalen
)
24 const struct ebt_mark_t_info
*info
= data
;
25 int action
= info
->target
& -16;
27 if (action
== MARK_SET_VALUE
)
28 skb
->mark
= info
->mark
;
29 else if (action
== MARK_OR_VALUE
)
30 skb
->mark
|= info
->mark
;
31 else if (action
== MARK_AND_VALUE
)
32 skb
->mark
&= info
->mark
;
34 skb
->mark
^= info
->mark
;
36 return info
->target
| ~EBT_VERDICT_BITS
;
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 const struct ebt_mark_t_info
*info
= data
;
45 if (datalen
!= EBT_ALIGN(sizeof(struct ebt_mark_t_info
)))
47 tmp
= info
->target
| ~EBT_VERDICT_BITS
;
48 if (BASE_CHAIN
&& tmp
== EBT_RETURN
)
51 if (tmp
< -NUM_STANDARD_TARGETS
|| tmp
>= 0)
53 tmp
= info
->target
& ~EBT_VERDICT_BITS
;
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 __read_mostly
= {
61 .name
= EBT_MARK_TARGET
,
62 .target
= ebt_target_mark
,
63 .check
= ebt_target_mark_check
,
67 static int __init
ebt_mark_init(void)
69 return ebt_register_target(&mark_target
);
72 static void __exit
ebt_mark_fini(void)
74 ebt_unregister_target(&mark_target
);
77 module_init(ebt_mark_init
);
78 module_exit(ebt_mark_fini
);
79 MODULE_DESCRIPTION("Ebtables: Packet mark modification");
80 MODULE_LICENSE("GPL");