[NETFILTER]: ipt_hashlimit: add compat conversion functions
Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
02c63cf777
commit
127f15dd65
@@ -535,10 +535,39 @@ hashlimit_destroy(const struct xt_match *match, void *matchinfo)
|
|||||||
htable_put(r->hinfo);
|
htable_put(r->hinfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_COMPAT
|
||||||
|
struct compat_ipt_hashlimit_info {
|
||||||
|
char name[IFNAMSIZ];
|
||||||
|
struct hashlimit_cfg cfg;
|
||||||
|
compat_uptr_t hinfo;
|
||||||
|
compat_uptr_t master;
|
||||||
|
};
|
||||||
|
|
||||||
|
static void compat_from_user(void *dst, void *src)
|
||||||
|
{
|
||||||
|
int off = offsetof(struct compat_ipt_hashlimit_info, hinfo);
|
||||||
|
|
||||||
|
memcpy(dst, src, off);
|
||||||
|
memset(dst + off, 0, sizeof(struct compat_ipt_hashlimit_info) - off);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int compat_to_user(void __user *dst, void *src)
|
||||||
|
{
|
||||||
|
int off = offsetof(struct compat_ipt_hashlimit_info, hinfo);
|
||||||
|
|
||||||
|
return copy_to_user(dst, src, off) ? -EFAULT : 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static struct ipt_match ipt_hashlimit = {
|
static struct ipt_match ipt_hashlimit = {
|
||||||
.name = "hashlimit",
|
.name = "hashlimit",
|
||||||
.match = hashlimit_match,
|
.match = hashlimit_match,
|
||||||
.matchsize = sizeof(struct ipt_hashlimit_info),
|
.matchsize = sizeof(struct ipt_hashlimit_info),
|
||||||
|
#ifdef CONFIG_COMPAT
|
||||||
|
.compatsize = sizeof(struct compat_ipt_hashlimit_info),
|
||||||
|
.compat_from_user = compat_from_user,
|
||||||
|
.compat_to_user = compat_to_user,
|
||||||
|
#endif
|
||||||
.checkentry = hashlimit_checkentry,
|
.checkentry = hashlimit_checkentry,
|
||||||
.destroy = hashlimit_destroy,
|
.destroy = hashlimit_destroy,
|
||||||
.me = THIS_MODULE
|
.me = THIS_MODULE
|
||||||
|
Reference in New Issue
Block a user