aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2006-09-20 15:07:06 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2006-09-22 18:20:06 -0400
commit02c63cf777c331121bfb6e9c1440a9835ad2f2a8 (patch)
treeff1dd6d4bc9a84264bbddee6792c5b758194eb66 /net
parent7ce975b9da93b46dbf6ba70a1b4751bec211d079 (diff)
[NETFILTER]: xt_limit: add compat conversion functions
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/netfilter/xt_limit.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/net/netfilter/xt_limit.c b/net/netfilter/xt_limit.c
index 8bfcbdfa8783..fda7b7dec27d 100644
--- a/net/netfilter/xt_limit.c
+++ b/net/netfilter/xt_limit.c
@@ -135,6 +135,50 @@ ipt_limit_checkentry(const char *tablename,
135 return 1; 135 return 1;
136} 136}
137 137
138#ifdef CONFIG_COMPAT
139struct compat_xt_rateinfo {
140 u_int32_t avg;
141 u_int32_t burst;
142
143 compat_ulong_t prev;
144 u_int32_t credit;
145 u_int32_t credit_cap, cost;
146
147 u_int32_t master;
148};
149
150/* To keep the full "prev" timestamp, the upper 32 bits are stored in the
151 * master pointer, which does not need to be preserved. */
152static void compat_from_user(void *dst, void *src)
153{
154 struct compat_xt_rateinfo *cm = src;
155 struct xt_rateinfo m = {
156 .avg = cm->avg,
157 .burst = cm->burst,
158 .prev = cm->prev | (unsigned long)cm->master << 32,
159 .credit = cm->credit,
160 .credit_cap = cm->credit_cap,
161 .cost = cm->cost,
162 };
163 memcpy(dst, &m, sizeof(m));
164}
165
166static int compat_to_user(void __user *dst, void *src)
167{
168 struct xt_rateinfo *m = src;
169 struct compat_xt_rateinfo cm = {
170 .avg = m->avg,
171 .burst = m->burst,
172 .prev = m->prev,
173 .credit = m->credit,
174 .credit_cap = m->credit_cap,
175 .cost = m->cost,
176 .master = m->prev >> 32,
177 };
178 return copy_to_user(dst, &cm, sizeof(cm)) ? -EFAULT : 0;
179}
180#endif /* CONFIG_COMPAT */
181
138static struct xt_match xt_limit_match[] = { 182static struct xt_match xt_limit_match[] = {
139 { 183 {
140 .name = "limit", 184 .name = "limit",
@@ -142,6 +186,11 @@ static struct xt_match xt_limit_match[] = {
142 .checkentry = ipt_limit_checkentry, 186 .checkentry = ipt_limit_checkentry,
143 .match = ipt_limit_match, 187 .match = ipt_limit_match,
144 .matchsize = sizeof(struct xt_rateinfo), 188 .matchsize = sizeof(struct xt_rateinfo),
189#ifdef CONFIG_COMPAT
190 .compatsize = sizeof(struct compat_xt_rateinfo),
191 .compat_from_user = compat_from_user,
192 .compat_to_user = compat_to_user,
193#endif
145 .me = THIS_MODULE, 194 .me = THIS_MODULE,
146 }, 195 },
147 { 196 {