diff options
-rw-r--r-- | include/linux/netfilter_bridge/ebt_mark_t.h | 12 | ||||
-rw-r--r-- | net/bridge/netfilter/ebt_mark.c | 21 |
2 files changed, 29 insertions, 4 deletions
diff --git a/include/linux/netfilter_bridge/ebt_mark_t.h b/include/linux/netfilter_bridge/ebt_mark_t.h index 110fec6a40a2..6270f6f33693 100644 --- a/include/linux/netfilter_bridge/ebt_mark_t.h +++ b/include/linux/netfilter_bridge/ebt_mark_t.h | |||
@@ -1,6 +1,18 @@ | |||
1 | #ifndef __LINUX_BRIDGE_EBT_MARK_T_H | 1 | #ifndef __LINUX_BRIDGE_EBT_MARK_T_H |
2 | #define __LINUX_BRIDGE_EBT_MARK_T_H | 2 | #define __LINUX_BRIDGE_EBT_MARK_T_H |
3 | 3 | ||
4 | /* The target member is reused for adding new actions, the | ||
5 | * value of the real target is -1 to -NUM_STANDARD_TARGETS. | ||
6 | * For backward compatibility, the 4 lsb (2 would be enough, | ||
7 | * but let's play it safe) are kept to designate this target. | ||
8 | * The remaining bits designate the action. By making the set | ||
9 | * action 0xfffffff0, the result will look ok for older | ||
10 | * versions. [September 2006] */ | ||
11 | #define MARK_SET_VALUE (0xfffffff0) | ||
12 | #define MARK_OR_VALUE (0xffffffe0) | ||
13 | #define MARK_AND_VALUE (0xffffffd0) | ||
14 | #define MARK_XOR_VALUE (0xffffffc0) | ||
15 | |||
4 | struct ebt_mark_t_info | 16 | struct ebt_mark_t_info |
5 | { | 17 | { |
6 | unsigned long mark; | 18 | unsigned long mark; |
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 | } |