From 62a3d29539aa109fed1c8a20d63ef95948b13842 Mon Sep 17 00:00:00 2001 From: Jozsef Kadlecsik Date: Mon, 23 Aug 2010 16:48:14 +0200 Subject: Cleanup, compatibility - Use is_vmalloc_addr when freeing vmalloc or kmalloc-ed areas. Thus we can get rid of a flag and simplify some functions. - When checking "same" sets, ignore hash size, because resizing changes it. - 2.6.35 compatibility added. - Discuss backward/forward compatibilities in the README file. --- kernel/xt_set.c | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) (limited to 'kernel/xt_set.c') diff --git a/kernel/xt_set.c b/kernel/xt_set.c index 4734cc4..05bd84e 100644 --- a/kernel/xt_set.c +++ b/kernel/xt_set.c @@ -48,6 +48,14 @@ match_set(ip_set_id_t index, const struct sk_buff *skb, #error "Linux kernel version too old: must be >= 2.6.31" #endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35) +#define CHECK_OK 1 +#define CHECK_FAIL 0 +#else /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35) */ +#define CHECK_OK 0 +#define CHECK_FAIL -EINVAL +#endif + #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35) static bool set_match_v0(const struct sk_buff *skb, const struct xt_match_param *par) @@ -96,17 +104,17 @@ set_match_v0_checkentry(const struct xt_mtchk_param *par) if (index == IPSET_INVALID_ID) { pr_warning("Cannot find set indentified by id %u to match", info->match_set.index); - return 0; /* error */ + return CHECK_FAIL; /* error */ } if (info->match_set.u.flags[IPSET_DIM_MAX-1] != 0) { pr_warning("That's nasty!"); - return 0; /* error */ + return CHECK_FAIL; /* error */ } /* Fill out compatibility data */ compat_flags(&info->match_set); - return 1; + return CHECK_OK; } static void @@ -155,7 +163,7 @@ set_target_v0_checkentry(const struct xt_tgchk_param *par) if (index == IPSET_INVALID_ID) { pr_warning("cannot find add_set index %u as target", info->add_set.index); - return 0; /* error */ + return CHECK_FAIL; /* error */ } } @@ -164,20 +172,20 @@ set_target_v0_checkentry(const struct xt_tgchk_param *par) if (index == IPSET_INVALID_ID) { pr_warning("cannot find del_set index %u as target", info->del_set.index); - return 0; /* error */ + return CHECK_FAIL; /* error */ } } if (info->add_set.u.flags[IPSET_DIM_MAX-1] != 0 || info->del_set.u.flags[IPSET_DIM_MAX-1] != 0) { pr_warning("That's nasty!"); - return 0; /* error */ + return CHECK_FAIL; /* error */ } /* Fill out compatibility data */ compat_flags(&info->add_set); compat_flags(&info->del_set); - return 1; + return CHECK_OK; } static void @@ -225,14 +233,14 @@ set_match_checkentry(const struct xt_mtchk_param *par) if (index == IPSET_INVALID_ID) { pr_warning("Cannot find set indentified by id %u to match", info->match_set.index); - return 0; /* error */ + return CHECK_FAIL; /* error */ } if (info->match_set.dim > IPSET_DIM_MAX) { pr_warning("That's nasty!"); - return 0; /* error */ + return CHECK_FAIL; /* error */ } - return 1; + return CHECK_OK; } static void @@ -283,7 +291,7 @@ set_target_checkentry(const struct xt_tgchk_param *par) if (index == IPSET_INVALID_ID) { pr_warning("cannot find add_set index %u as target", info->add_set.index); - return 0; /* error */ + return CHECK_FAIL; /* error */ } } @@ -292,16 +300,16 @@ set_target_checkentry(const struct xt_tgchk_param *par) if (index == IPSET_INVALID_ID) { pr_warning("cannot find del_set index %u as target", info->del_set.index); - return 0; /* error */ + return CHECK_FAIL; /* error */ } } if (info->add_set.dim > IPSET_DIM_MAX || info->del_set.flags > IPSET_DIM_MAX) { pr_warning("That's nasty!"); - return 0; /* error */ + return CHECK_FAIL; /* error */ } - return 1; + return CHECK_OK; } static void -- cgit v1.2.3