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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/netfilter_bridge/ebtables.h>
|
|
|
|
#include <linux/netfilter_bridge/ebt_mark_t.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
|
|
|
|
static int ebt_target_mark(struct sk_buff **pskb, unsigned int hooknr,
|
|
|
|
const struct net_device *in, const struct net_device *out,
|
|
|
|
const void *data, unsigned int datalen)
|
|
|
|
{
|
|
|
|
struct ebt_mark_t_info *info = (struct ebt_mark_t_info *)data;
|
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)
|
2006-11-09 23:19:14 +00:00
|
|
|
(*pskb)->mark = info->mark;
|
2006-10-02 23:12:52 +00:00
|
|
|
else if (action == MARK_OR_VALUE)
|
2006-11-09 23:19:14 +00:00
|
|
|
(*pskb)->mark |= info->mark;
|
2006-10-02 23:12:52 +00:00
|
|
|
else if (action == MARK_AND_VALUE)
|
2006-11-09 23:19:14 +00:00
|
|
|
(*pskb)->mark &= info->mark;
|
2006-10-02 23:12:52 +00:00
|
|
|
else
|
2006-11-09 23:19:14 +00:00
|
|
|
(*pskb)->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
|
|
|
}
|
|
|
|
|
|
|
|
static int ebt_target_mark_check(const char *tablename, unsigned int hookmask,
|
|
|
|
const struct ebt_entry *e, void *data, unsigned int datalen)
|
|
|
|
{
|
|
|
|
struct ebt_mark_t_info *info = (struct ebt_mark_t_info *)data;
|
2006-10-02 23:12:52 +00:00
|
|
|
int tmp;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
if (datalen != EBT_ALIGN(sizeof(struct ebt_mark_t_info)))
|
|
|
|
return -EINVAL;
|
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)
|
2005-04-16 22:20:36 +00:00
|
|
|
return -EINVAL;
|
|
|
|
CLEAR_BASE_CHAIN_BIT;
|
2006-10-02 23:12:52 +00:00
|
|
|
if (tmp < -NUM_STANDARD_TARGETS || tmp >= 0)
|
|
|
|
return -EINVAL;
|
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)
|
2005-04-16 22:20:36 +00:00
|
|
|
return -EINVAL;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct ebt_target mark_target =
|
|
|
|
{
|
|
|
|
.name = EBT_MARK_TARGET,
|
|
|
|
.target = ebt_target_mark,
|
|
|
|
.check = ebt_target_mark_check,
|
|
|
|
.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
|
|
|
{
|
|
|
|
return ebt_register_target(&mark_target);
|
|
|
|
}
|
|
|
|
|
2006-03-29 00:37:06 +00:00
|
|
|
static void __exit ebt_mark_fini(void)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
ebt_unregister_target(&mark_target);
|
|
|
|
}
|
|
|
|
|
2006-03-29 00:37:06 +00:00
|
|
|
module_init(ebt_mark_init);
|
|
|
|
module_exit(ebt_mark_fini);
|
2005-04-16 22:20:36 +00:00
|
|
|
MODULE_LICENSE("GPL");
|