diff options
author | Bart De Schuymer <bdschuym@pandora.be> | 2006-10-02 19:12:52 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2006-10-04 03:30:57 -0400 |
commit | b18dfa90c008850e0f3bfd63638dd8fbe8e08701 (patch) | |
tree | 5d2683760ae0430f068f1d0f9ba686b3de029093 /net | |
parent | 9d02002d2dc2c7423e5891b97727fde4d667adf1 (diff) |
[NETFILTER]: ebt_mark: add or/and/xor action support to mark target
The following patch adds or/and/xor functionality for the mark target,
while staying backwards compatible.
Signed-off-by: Bart De Schuymer <bdschuym@pandora.be>
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/bridge/netfilter/ebt_mark.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/net/bridge/netfilter/ebt_mark.c b/net/bridge/netfilter/ebt_mark.c index 770c0df972a3..b54306a934e5 100644 --- a/net/bridge/netfilter/ebt_mark.c +++ b/net/bridge/netfilter/ebt_mark.c | |||
@@ -22,24 +22,37 @@ static int ebt_target_mark(struct sk_buff **pskb, unsigned int hooknr, | |||
22 | const void *data, unsigned int datalen) | 22 | const void *data, unsigned int datalen) |
23 | { | 23 | { |
24 | struct ebt_mark_t_info *info = (struct ebt_mark_t_info *)data; | 24 | struct ebt_mark_t_info *info = (struct ebt_mark_t_info *)data; |
25 | int action = info->target & -16; | ||
25 | 26 | ||
26 | if ((*pskb)->nfmark != info->mark) | 27 | if (action == MARK_SET_VALUE) |
27 | (*pskb)->nfmark = info->mark; | 28 | (*pskb)->nfmark = info->mark; |
29 | else if (action == MARK_OR_VALUE) | ||
30 | (*pskb)->nfmark |= info->mark; | ||
31 | else if (action == MARK_AND_VALUE) | ||
32 | (*pskb)->nfmark &= info->mark; | ||
33 | else | ||
34 | (*pskb)->nfmark ^= info->mark; | ||
28 | 35 | ||
29 | return info->target; | 36 | return info->target | -16; |
30 | } | 37 | } |
31 | 38 | ||
32 | static int ebt_target_mark_check(const char *tablename, unsigned int hookmask, | 39 | static int ebt_target_mark_check(const char *tablename, unsigned int hookmask, |
33 | const struct ebt_entry *e, void *data, unsigned int datalen) | 40 | const struct ebt_entry *e, void *data, unsigned int datalen) |
34 | { | 41 | { |
35 | struct ebt_mark_t_info *info = (struct ebt_mark_t_info *)data; | 42 | struct ebt_mark_t_info *info = (struct ebt_mark_t_info *)data; |
43 | int tmp; | ||
36 | 44 | ||
37 | if (datalen != EBT_ALIGN(sizeof(struct ebt_mark_t_info))) | 45 | if (datalen != EBT_ALIGN(sizeof(struct ebt_mark_t_info))) |
38 | return -EINVAL; | 46 | return -EINVAL; |
39 | if (BASE_CHAIN && info->target == EBT_RETURN) | 47 | tmp = info->target | -16; |
48 | if (BASE_CHAIN && tmp == EBT_RETURN) | ||
40 | return -EINVAL; | 49 | return -EINVAL; |
41 | CLEAR_BASE_CHAIN_BIT; | 50 | CLEAR_BASE_CHAIN_BIT; |
42 | if (INVALID_TARGET) | 51 | if (tmp < -NUM_STANDARD_TARGETS || tmp >= 0) |
52 | return -EINVAL; | ||
53 | tmp = info->target & -16; | ||
54 | if (tmp != MARK_SET_VALUE && tmp != MARK_OR_VALUE && | ||
55 | tmp != MARK_AND_VALUE && tmp != MARK_XOR_VALUE) | ||
43 | return -EINVAL; | 56 | return -EINVAL; |
44 | return 0; | 57 | return 0; |
45 | } | 58 | } |