diff options
author | Patrick McHardy <kaber@trash.net> | 2007-12-18 00:51:33 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-28 17:58:38 -0500 |
commit | 1fe5723773656a8ee7a981caf7fee9adb0ac6259 (patch) | |
tree | 18fee4c604f7c68ecb6b070af0dc512591fa47b6 | |
parent | 311af5cbeab8ce2b9252ce65272e427eeb8093b7 (diff) |
[NETFILTER]: xt_MARK: add compat support for revision 0
Old userspace doesn't support revision 1, especially for IPv6, which
is only available in the SVN snapshot.
Add compat support for revision 0.
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/netfilter/xt_MARK.c | 44 |
1 files changed, 38 insertions, 6 deletions
diff --git a/net/netfilter/xt_MARK.c b/net/netfilter/xt_MARK.c index 5bf912120f48..57c6d55e33d3 100644 --- a/net/netfilter/xt_MARK.c +++ b/net/netfilter/xt_MARK.c | |||
@@ -94,6 +94,28 @@ mark_tg_check(const char *tablename, const void *entry, | |||
94 | } | 94 | } |
95 | 95 | ||
96 | #ifdef CONFIG_COMPAT | 96 | #ifdef CONFIG_COMPAT |
97 | struct compat_xt_mark_target_info { | ||
98 | compat_ulong_t mark; | ||
99 | }; | ||
100 | |||
101 | static void mark_tg_compat_from_user(void *dst, void *src) | ||
102 | { | ||
103 | const struct compat_xt_mark_target_info *cm = src; | ||
104 | struct xt_mark_target_info m = { | ||
105 | .mark = cm->mark, | ||
106 | }; | ||
107 | memcpy(dst, &m, sizeof(m)); | ||
108 | } | ||
109 | |||
110 | static int mark_tg_compat_to_user(void __user *dst, void *src) | ||
111 | { | ||
112 | const struct xt_mark_target_info *m = src; | ||
113 | struct compat_xt_mark_target_info cm = { | ||
114 | .mark = m->mark, | ||
115 | }; | ||
116 | return copy_to_user(dst, &cm, sizeof(cm)) ? -EFAULT : 0; | ||
117 | } | ||
118 | |||
97 | struct compat_xt_mark_target_info_v1 { | 119 | struct compat_xt_mark_target_info_v1 { |
98 | compat_ulong_t mark; | 120 | compat_ulong_t mark; |
99 | u_int8_t mode; | 121 | u_int8_t mode; |
@@ -101,7 +123,7 @@ struct compat_xt_mark_target_info_v1 { | |||
101 | u_int16_t __pad2; | 123 | u_int16_t __pad2; |
102 | }; | 124 | }; |
103 | 125 | ||
104 | static void mark_tg_compat_from_user(void *dst, void *src) | 126 | static void mark_tg_compat_from_user_v1(void *dst, void *src) |
105 | { | 127 | { |
106 | const struct compat_xt_mark_target_info_v1 *cm = src; | 128 | const struct compat_xt_mark_target_info_v1 *cm = src; |
107 | struct xt_mark_target_info_v1 m = { | 129 | struct xt_mark_target_info_v1 m = { |
@@ -111,7 +133,7 @@ static void mark_tg_compat_from_user(void *dst, void *src) | |||
111 | memcpy(dst, &m, sizeof(m)); | 133 | memcpy(dst, &m, sizeof(m)); |
112 | } | 134 | } |
113 | 135 | ||
114 | static int mark_tg_compat_to_user(void __user *dst, void *src) | 136 | static int mark_tg_compat_to_user_v1(void __user *dst, void *src) |
115 | { | 137 | { |
116 | const struct xt_mark_target_info_v1 *m = src; | 138 | const struct xt_mark_target_info_v1 *m = src; |
117 | struct compat_xt_mark_target_info_v1 cm = { | 139 | struct compat_xt_mark_target_info_v1 cm = { |
@@ -130,6 +152,11 @@ static struct xt_target mark_tg_reg[] __read_mostly = { | |||
130 | .checkentry = mark_tg_check_v0, | 152 | .checkentry = mark_tg_check_v0, |
131 | .target = mark_tg_v0, | 153 | .target = mark_tg_v0, |
132 | .targetsize = sizeof(struct xt_mark_target_info), | 154 | .targetsize = sizeof(struct xt_mark_target_info), |
155 | #ifdef CONFIG_COMPAT | ||
156 | .compatsize = sizeof(struct compat_xt_mark_target_info), | ||
157 | .compat_from_user = mark_tg_compat_from_user, | ||
158 | .compat_to_user = mark_tg_compat_to_user, | ||
159 | #endif | ||
133 | .table = "mangle", | 160 | .table = "mangle", |
134 | .me = THIS_MODULE, | 161 | .me = THIS_MODULE, |
135 | }, | 162 | }, |
@@ -142,8 +169,8 @@ static struct xt_target mark_tg_reg[] __read_mostly = { | |||
142 | .targetsize = sizeof(struct xt_mark_target_info_v1), | 169 | .targetsize = sizeof(struct xt_mark_target_info_v1), |
143 | #ifdef CONFIG_COMPAT | 170 | #ifdef CONFIG_COMPAT |
144 | .compatsize = sizeof(struct compat_xt_mark_target_info_v1), | 171 | .compatsize = sizeof(struct compat_xt_mark_target_info_v1), |
145 | .compat_from_user = mark_tg_compat_from_user, | 172 | .compat_from_user = mark_tg_compat_from_user_v1, |
146 | .compat_to_user = mark_tg_compat_to_user, | 173 | .compat_to_user = mark_tg_compat_to_user_v1, |
147 | #endif | 174 | #endif |
148 | .table = "mangle", | 175 | .table = "mangle", |
149 | .me = THIS_MODULE, | 176 | .me = THIS_MODULE, |
@@ -155,6 +182,11 @@ static struct xt_target mark_tg_reg[] __read_mostly = { | |||
155 | .checkentry = mark_tg_check_v0, | 182 | .checkentry = mark_tg_check_v0, |
156 | .target = mark_tg_v0, | 183 | .target = mark_tg_v0, |
157 | .targetsize = sizeof(struct xt_mark_target_info), | 184 | .targetsize = sizeof(struct xt_mark_target_info), |
185 | #ifdef CONFIG_COMPAT | ||
186 | .compatsize = sizeof(struct compat_xt_mark_target_info), | ||
187 | .compat_from_user = mark_tg_compat_from_user, | ||
188 | .compat_to_user = mark_tg_compat_to_user, | ||
189 | #endif | ||
158 | .table = "mangle", | 190 | .table = "mangle", |
159 | .me = THIS_MODULE, | 191 | .me = THIS_MODULE, |
160 | }, | 192 | }, |
@@ -167,8 +199,8 @@ static struct xt_target mark_tg_reg[] __read_mostly = { | |||
167 | .targetsize = sizeof(struct xt_mark_target_info_v1), | 199 | .targetsize = sizeof(struct xt_mark_target_info_v1), |
168 | #ifdef CONFIG_COMPAT | 200 | #ifdef CONFIG_COMPAT |
169 | .compatsize = sizeof(struct compat_xt_mark_target_info_v1), | 201 | .compatsize = sizeof(struct compat_xt_mark_target_info_v1), |
170 | .compat_from_user = mark_tg_compat_from_user, | 202 | .compat_from_user = mark_tg_compat_from_user_v1, |
171 | .compat_to_user = mark_tg_compat_to_user, | 203 | .compat_to_user = mark_tg_compat_to_user_v1, |
172 | #endif | 204 | #endif |
173 | .table = "mangle", | 205 | .table = "mangle", |
174 | .me = THIS_MODULE, | 206 | .me = THIS_MODULE, |