1 commit a796550d217a8fc06829cac7bad72ac1fe34f85d
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 ab5127c..477790e 100644
9 --- a/extensions/libxt_CLASSIFY.c
10 +++ b/extensions/libxt_CLASSIFY.c
11 @@ -16,11 +16,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 {.name = "set-class", .has_arg = true, .val = '1'},
22 + {.name = "add-mark", .has_arg = false, .val = '2'},
26 @@ -43,6 +45,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 @@ -54,6 +58,10 @@ CLASSIFY_parse(int c, char **argv, int invert, unsigned int *flags,
40 + clinfo->add_mark = 1;
46 @@ -84,6 +92,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 @@ -94,6 +105,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 39996d0..09e13ca 100644
68 --- a/extensions/libxt_MARK.c
69 +++ b/extensions/libxt_MARK.c
70 @@ -19,6 +19,7 @@ enum {
77 struct xt_mark_target_info_v1 {
78 @@ -36,13 +37,15 @@ static void MARK_help(void)
79 "MARK target options:\n"
80 " --set-mark value Set nfmark value\n"
81 " --and-mark value Binary AND the nfmark with value\n"
82 -" --or-mark value Binary OR the nfmark with value\n");
83 +" --or-mark value Binary OR the nfmark with value\n"
84 +" --copy-xid Set nfmark to be the connection xid (PlanetLab specific)\n");
87 static const struct option MARK_opts[] = {
88 {.name = "set-mark", .has_arg = true, .val = '1'},
89 {.name = "and-mark", .has_arg = true, .val = '2'},
90 {.name = "or-mark", .has_arg = true, .val = '3'},
91 + {.name = "copy-xid", .has_arg = true, .val = '4'},
95 @@ -52,6 +55,7 @@ static const struct option mark_tg_opts[] = {
96 {.name = "and-mark", .has_arg = true, .val = '&'},
97 {.name = "or-mark", .has_arg = true, .val = '|'},
98 {.name = "xor-mark", .has_arg = true, .val = '^'},
99 + {.name = "copy-xid", .has_arg = true, .val = '%'},
103 @@ -63,6 +67,7 @@ static void mark_tg_help(void)
104 " --set-mark value[/mask] Clear bits in mask and OR value into nfmark\n"
105 " --and-mark bits Binary AND the nfmark with bits\n"
106 " --or-mark bits Binary OR the nfmark with bits\n"
107 +" --copy-xid Set nfmark to be the connection xid (PlanetLab specific)\n"
108 " --xor-mask bits Binary XOR the nfmark with bits\n"
111 @@ -126,6 +131,9 @@ MARK_parse_v1(int c, char **argv, int invert, unsigned int *flags,
113 markinfo->mode = XT_MARK_OR;
116 + markinfo->mode = IPT_MARK_COPYXID;
121 @@ -194,6 +202,12 @@ static int mark_tg_parse(int c, char **argv, int invert, unsigned int *flags,
125 + case '%': /* --copy-xid */
126 + xtables_param_act(XTF_ONE_ACTION, "MARK", *flags & F_MARK);
127 + info->mark = ~0U; /* Consistency check */
134 @@ -206,7 +220,7 @@ static void mark_tg_check(unsigned int flags)
137 xtables_error(PARAMETER_PROBLEM, "MARK: One of the --set-xmark, "
138 - "--{and,or,xor,set}-mark options is required");
139 + "--{and,or,xor,set}-mark, or --copy-xid options is required");
143 @@ -249,6 +263,9 @@ static void MARK_print_v1(const void *ip, const struct xt_entry_target *target,
147 + case IPT_MARK_COPYXID:
148 + printf("MARK copyxid ");
151 print_mark(markinfo->mark);
153 @@ -258,7 +275,9 @@ static void mark_tg_print(const void *ip, const struct xt_entry_target *target,
155 const struct xt_mark_tginfo2 *info = (const void *)target->data;
157 - if (info->mark == 0)
158 + if (info->mark == ~0U)
159 + printf("MARK copy-xid");
160 + else if (info->mark == 0)
161 printf("MARK and 0x%x ", (unsigned int)(u_int32_t)~info->mask);
162 else if (info->mark == info->mask)
163 printf("MARK or 0x%x ", info->mark);
164 @@ -285,6 +304,9 @@ static void MARK_save_v1(const void *ip, const struct xt_entry_target *target)
166 printf("--or-mark ");
168 + case IPT_MARK_COPYXID:
169 + printf("--copy-xid ");
172 print_mark(markinfo->mark);
174 @@ -293,7 +315,10 @@ static void mark_tg_save(const void *ip, const struct xt_entry_target *target)
176 const struct xt_mark_tginfo2 *info = (const void *)target->data;
178 - printf("--set-xmark 0x%x/0x%x ", info->mark, info->mask);
179 + if (info->mark==~0U)
180 + printf("--copy-xid 0x0");
182 + printf("--set-xmark 0x%x/0x%x ", info->mark, info->mask);
185 static struct xtables_target mark_tg_reg[] = {
186 diff --git a/include/linux/netfilter/xt_CLASSIFY.h b/include/linux/netfilter/xt_CLASSIFY.h
187 index a813bf1..c5cec1d 100644
188 --- a/include/linux/netfilter/xt_CLASSIFY.h
189 +++ b/include/linux/netfilter/xt_CLASSIFY.h
192 struct xt_classify_target_info {
197 #endif /*_XT_CLASSIFY_H */