2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* ebt_mark_m
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Bart De Schuymer <bdschuym@pandora.be>
|
|
|
|
*
|
|
|
|
* July, 2002
|
|
|
|
*
|
|
|
|
*/
|
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_m.h>
|
|
|
|
|
2008-10-08 09:35:15 +00:00
|
|
|
static bool
|
2008-10-08 09:35:18 +00:00
|
|
|
ebt_mark_mt(const struct sk_buff *skb, const struct xt_match_param *par)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2008-10-08 09:35:18 +00:00
|
|
|
const struct ebt_mark_m_info *info = par->matchinfo;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
if (info->bitmask & EBT_MARK_OR)
|
2008-10-08 09:35:13 +00:00
|
|
|
return !!(skb->mark & info->mask) ^ info->invert;
|
|
|
|
return ((skb->mark & info->mask) == info->mark) ^ info->invert;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2008-10-08 09:35:15 +00:00
|
|
|
static bool
|
|
|
|
ebt_mark_mt_check(const char *table, const void *e,
|
|
|
|
const struct xt_match *match, void *data,
|
|
|
|
unsigned int hook_mask)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2008-01-31 11:59:24 +00:00
|
|
|
const struct ebt_mark_m_info *info = data;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
if (info->bitmask & ~EBT_MARK_MASK)
|
2008-10-08 09:35:13 +00:00
|
|
|
return false;
|
2005-04-16 22:20:36 +00:00
|
|
|
if ((info->bitmask & EBT_MARK_OR) && (info->bitmask & EBT_MARK_AND))
|
2008-10-08 09:35:13 +00:00
|
|
|
return false;
|
2005-04-16 22:20:36 +00:00
|
|
|
if (!info->bitmask)
|
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_match ebt_mark_mt_reg __read_mostly = {
|
|
|
|
.name = "mark_m",
|
2008-10-08 09:35:14 +00:00
|
|
|
.revision = 0,
|
|
|
|
.family = NFPROTO_BRIDGE,
|
2008-10-08 09:35:15 +00:00
|
|
|
.match = ebt_mark_mt,
|
|
|
|
.checkentry = ebt_mark_mt_check,
|
2008-10-08 09:35:13 +00:00
|
|
|
.matchsize = XT_ALIGN(sizeof(struct ebt_mark_m_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_m_init(void)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2008-10-08 09:35:15 +00:00
|
|
|
return xt_register_match(&ebt_mark_mt_reg);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2006-03-29 00:37:06 +00:00
|
|
|
static void __exit ebt_mark_m_fini(void)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2008-10-08 09:35:15 +00:00
|
|
|
xt_unregister_match(&ebt_mark_mt_reg);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2006-03-29 00:37:06 +00:00
|
|
|
module_init(ebt_mark_m_init);
|
|
|
|
module_exit(ebt_mark_m_fini);
|
2008-01-31 12:00:30 +00:00
|
|
|
MODULE_DESCRIPTION("Ebtables: Packet mark match");
|
2005-04-16 22:20:36 +00:00
|
|
|
MODULE_LICENSE("GPL");
|