2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* ebt_mark
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Bart De Schuymer <bdschuym@pandora.be>
|
|
|
|
*
|
|
|
|
* July, 2002
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* The mark target can be used in any chain,
|
|
|
|
* I believe adding a mangle table just for marking is total overkill.
|
|
|
|
* Marking a frame doesn't really change anything in the frame anyway.
|
|
|
|
*/
|
|
|
|
|
2008-10-08 09:35:13 +00:00
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/netfilter/x_tables.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <linux/netfilter_bridge/ebtables.h>
|
|
|
|
#include <linux/netfilter_bridge/ebt_mark_t.h>
|
|
|
|
|
2008-10-08 09:35:15 +00:00
|
|
|
static unsigned int
|
2008-10-08 09:35:19 +00:00
|
|
|
ebt_mark_tg(struct sk_buff *skb, const struct xt_target_param *par)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2008-10-08 09:35:19 +00:00
|
|
|
const struct ebt_mark_t_info *info = par->targinfo;
|
2006-10-02 23:12:52 +00:00
|
|
|
int action = info->target & -16;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2006-10-02 23:12:52 +00:00
|
|
|
if (action == MARK_SET_VALUE)
|
2007-10-15 07:53:15 +00:00
|
|
|
skb->mark = info->mark;
|
2006-10-02 23:12:52 +00:00
|
|
|
else if (action == MARK_OR_VALUE)
|
2007-10-15 07:53:15 +00:00
|
|
|
skb->mark |= info->mark;
|
2006-10-02 23:12:52 +00:00
|
|
|
else if (action == MARK_AND_VALUE)
|
2007-10-15 07:53:15 +00:00
|
|
|
skb->mark &= info->mark;
|
2006-10-02 23:12:52 +00:00
|
|
|
else
|
2007-10-15 07:53:15 +00:00
|
|
|
skb->mark ^= info->mark;
|
2005-08-10 02:24:19 +00:00
|
|
|
|
2006-11-29 01:35:40 +00:00
|
|
|
return info->target | ~EBT_VERDICT_BITS;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2008-10-08 09:35:15 +00:00
|
|
|
static bool
|
|
|
|
ebt_mark_tg_check(const char *table, const void *e,
|
|
|
|
const struct xt_target *target, void *data,
|
|
|
|
unsigned int hookmask)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2008-01-31 11:59:24 +00:00
|
|
|
const struct ebt_mark_t_info *info = data;
|
2006-10-02 23:12:52 +00:00
|
|
|
int tmp;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2006-11-29 01:35:40 +00:00
|
|
|
tmp = info->target | ~EBT_VERDICT_BITS;
|
2006-10-02 23:12:52 +00:00
|
|
|
if (BASE_CHAIN && tmp == EBT_RETURN)
|
2008-10-08 09:35:13 +00:00
|
|
|
return false;
|
2005-04-16 22:20:36 +00:00
|
|
|
CLEAR_BASE_CHAIN_BIT;
|
2006-10-02 23:12:52 +00:00
|
|
|
if (tmp < -NUM_STANDARD_TARGETS || tmp >= 0)
|
2008-10-08 09:35:13 +00:00
|
|
|
return false;
|
2006-11-29 01:35:40 +00:00
|
|
|
tmp = info->target & ~EBT_VERDICT_BITS;
|
2006-10-02 23:12:52 +00:00
|
|
|
if (tmp != MARK_SET_VALUE && tmp != MARK_OR_VALUE &&
|
|
|
|
tmp != MARK_AND_VALUE && tmp != MARK_XOR_VALUE)
|
2008-10-08 09:35:13 +00:00
|
|
|
return false;
|
|
|
|
return true;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2008-10-08 09:35:15 +00:00
|
|
|
static struct xt_target ebt_mark_tg_reg __read_mostly = {
|
|
|
|
.name = "mark",
|
2008-10-08 09:35:14 +00:00
|
|
|
.revision = 0,
|
|
|
|
.family = NFPROTO_BRIDGE,
|
2008-10-08 09:35:15 +00:00
|
|
|
.target = ebt_mark_tg,
|
|
|
|
.checkentry = ebt_mark_tg_check,
|
2008-10-08 09:35:13 +00:00
|
|
|
.targetsize = XT_ALIGN(sizeof(struct ebt_mark_t_info)),
|
2005-04-16 22:20:36 +00:00
|
|
|
.me = THIS_MODULE,
|
|
|
|
};
|
|
|
|
|
2006-03-29 00:37:06 +00:00
|
|
|
static int __init ebt_mark_init(void)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2008-10-08 09:35:15 +00:00
|
|
|
return xt_register_target(&ebt_mark_tg_reg);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2006-03-29 00:37:06 +00:00
|
|
|
static void __exit ebt_mark_fini(void)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2008-10-08 09:35:15 +00:00
|
|
|
xt_unregister_target(&ebt_mark_tg_reg);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2006-03-29 00:37:06 +00:00
|
|
|
module_init(ebt_mark_init);
|
|
|
|
module_exit(ebt_mark_fini);
|
2008-01-31 12:00:30 +00:00
|
|
|
MODULE_DESCRIPTION("Ebtables: Packet mark modification");
|
2005-04-16 22:20:36 +00:00
|
|
|
MODULE_LICENSE("GPL");
|