1 commit 12aa2a62d05523e66b104b3f6840c592309d3a05
2 Author: S.Çağlar Onur <caglar@cs.princeton.edu>
3 Date: Sat Apr 3 01:17:41 2010 -0400
7 diff --git a/extensions/libxt_CLASSIFY.c b/extensions/libxt_CLASSIFY.c
8 index 82b8f4e..09c15c0 100644
9 --- a/extensions/libxt_CLASSIFY.c
10 +++ b/extensions/libxt_CLASSIFY.c
11 @@ -15,11 +15,13 @@ CLASSIFY_help(void)
14 "CLASSIFY target options:\n"
15 -"--set-class MAJOR:MINOR Set skb->priority value (always hexadecimal!)\n");
16 +"--set-class MAJOR:MINOR Set skb->priority value (always hexadecimal!)\n"
17 +" --add-mark Add value of skb->mark to skb->priority (PlanetLab specific)\n");
20 static const struct option CLASSIFY_opts[] = {
21 { "set-class", 1, NULL, '1' },
22 + { "add-mark", 0, 0, '2' },
26 @@ -42,6 +44,8 @@ CLASSIFY_parse(int c, char **argv, int invert, unsigned int *flags,
27 struct xt_classify_target_info *clinfo
28 = (struct xt_classify_target_info *)(*target)->data;
30 + clinfo->add_mark = 0;
34 if (CLASSIFY_string_to_priority(optarg, &clinfo->priority))
35 @@ -53,6 +57,10 @@ CLASSIFY_parse(int c, char **argv, int invert, unsigned int *flags,
40 + clinfo->add_mark = 1;
46 @@ -83,6 +91,9 @@ CLASSIFY_print(const void *ip,
47 (const struct xt_classify_target_info *)target->data;
48 printf("CLASSIFY set ");
49 CLASSIFY_print_class(clinfo->priority, numeric);
51 + if (clinfo->add_mark)
52 + printf ("add-mark ");
56 @@ -93,6 +104,9 @@ CLASSIFY_save(const void *ip, const struct xt_entry_target *target)
58 printf("--set-class %.4x:%.4x ",
59 TC_H_MAJ(clinfo->priority)>>16, TC_H_MIN(clinfo->priority));
61 + if (clinfo->add_mark)
62 + printf("--add-mark ");
65 static struct xtables_target classify_target = {
66 diff --git a/extensions/libxt_MARK.c b/extensions/libxt_MARK.c
67 index dbfc7c0..db58a1b 100644
68 --- a/extensions/libxt_MARK.c
69 +++ b/extensions/libxt_MARK.c
70 @@ -36,13 +37,15 @@ static void MARK_help(void)
71 "MARK target options:\n"
72 " --set-mark value Set nfmark value\n"
73 " --and-mark value Binary AND the nfmark with value\n"
74 -" --or-mark value Binary OR the nfmark with value\n");
75 +" --or-mark value Binary OR the nfmark with value\n"
76 +" --copy-xid Set nfmark to be the connection xid (PlanetLab specific)\n");
79 static const struct option MARK_opts[] = {
80 { "set-mark", 1, NULL, '1' },
81 { "and-mark", 1, NULL, '2' },
82 { "or-mark", 1, NULL, '3' },
83 + { "copy-xid", 1, 0, '4' },
87 @@ -52,6 +55,7 @@ static const struct option mark_tg_opts[] = {
88 {.name = "and-mark", .has_arg = true, .val = '&'},
89 {.name = "or-mark", .has_arg = true, .val = '|'},
90 {.name = "xor-mark", .has_arg = true, .val = '^'},
91 + {.name = "copy-xid", .has_arg = true, .val = '%'},
95 @@ -63,6 +67,7 @@ static void mark_tg_help(void)
96 " --set-mark value[/mask] Clear bits in mask and OR value into nfmark\n"
97 " --and-mark bits Binary AND the nfmark with bits\n"
98 " --or-mark bits Binary OR the nfmark with bits\n"
99 +" --copy-xid Set nfmark to be the connection xid (PlanetLab specific)\n"
100 " --xor-mask bits Binary XOR the nfmark with bits\n"
103 @@ -194,6 +202,12 @@ static int mark_tg_parse(int c, char **argv, int invert, unsigned int *flags,
107 + case '%': /* --copy-xid */
108 + xtables_param_act(XTF_ONE_ACTION, "MARK", *flags & F_MARK);
109 + info->mark = ~0U; /* Consistency check */
116 @@ -206,7 +220,7 @@ static void mark_tg_check(unsigned int flags)
119 xtables_error(PARAMETER_PROBLEM, "MARK: One of the --set-xmark, "
120 - "--{and,or,xor,set}-mark options is required");
121 + "--{and,or,xor,set}-mark, or --copy-xid options is required");
125 @@ -258,7 +275,9 @@ static void mark_tg_print(const void *ip, const struct xt_entry_target *target,
127 const struct xt_mark_tginfo2 *info = (const void *)target->data;
129 - if (info->mark == 0)
130 + if (info->mark == ~0U)
131 + printf("MARK copy-xid");
132 + else if (info->mark == 0)
133 printf("MARK and 0x%x ", (unsigned int)(u_int32_t)~info->mask);
134 else if (info->mark == info->mask)
135 printf("MARK or 0x%x ", info->mark);
136 @@ -293,7 +315,10 @@ static void mark_tg_save(const void *ip, const struct xt_entry_target *target)
138 const struct xt_mark_tginfo2 *info = (const void *)target->data;
140 - printf("--set-xmark 0x%x/0x%x ", info->mark, info->mask);
141 + if (info->mark==~0U)
142 + printf("--copy-xid 0x0");
144 + printf("--set-xmark 0x%x/0x%x ", info->mark, info->mask);
147 static struct xtables_target mark_tg_reg[] = {
148 diff --git a/include/linux/netfilter/xt_CLASSIFY.h b/include/linux/netfilter/xt_CLASSIFY.h
149 index a813bf1..c5cec1d 100644
150 --- a/include/linux/netfilter/xt_CLASSIFY.h
151 +++ b/include/linux/netfilter/xt_CLASSIFY.h
154 struct xt_classify_target_info {
159 #endif /*_XT_CLASSIFY_H */