From 617bbe3725ebc29e493414f62a07eb6ac102eb3d Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Sun, 30 Mar 2014 16:44:46 +0200 Subject: [PATCH] xt_layer7: Remove all preprocessor if/else constructs for older kernels. --- net/netfilter/xt_layer7.c | 68 ++++----------------------------------- 1 file changed, 7 insertions(+), 61 deletions(-) diff --git a/net/netfilter/xt_layer7.c b/net/netfilter/xt_layer7.c index 42b46de45b1f..da61d485f086 100644 --- a/net/netfilter/xt_layer7.c +++ b/net/netfilter/xt_layer7.c @@ -25,10 +25,8 @@ #include #include #include -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) #include #include -#endif #include #include #include @@ -65,10 +63,6 @@ DEFINE_SPINLOCK(l7_lock); static int total_acct_packets(struct nf_conn *ct) { -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 26) - BUG_ON(ct == NULL); - return (ct->counters[IP_CT_DIR_ORIGINAL].packets + ct->counters[IP_CT_DIR_REPLY].packets); -#else struct nf_conn_counter *acct; BUG_ON(ct == NULL); @@ -76,7 +70,6 @@ static int total_acct_packets(struct nf_conn *ct) if (!acct) return 0; return (atomic64_read(&acct[IP_CT_DIR_ORIGINAL].packets) + atomic64_read(&acct[IP_CT_DIR_REPLY].packets)); -#endif } #ifdef CONFIG_IP_NF_MATCH_LAYER7_DEBUG @@ -414,31 +407,12 @@ static int layer7_write_proc(struct file* file, const char* buffer, return count; } -static bool -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35) -match(const struct sk_buff *skbin, struct xt_action_param *par) -#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28) -match(const struct sk_buff *skbin, const struct xt_match_param *par) -#else -match(const struct sk_buff *skbin, - const struct net_device *in, - const struct net_device *out, - const struct xt_match *match, - const void *matchinfo, - int offset, - unsigned int protoff, - bool *hotdrop) -#endif +static bool match(const struct sk_buff *skbin, struct xt_action_param *par) { /* sidestep const without getting a compiler warning... */ struct sk_buff * skb = (struct sk_buff *)skbin; - const struct xt_layer7_info * info = - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28) - par->matchinfo; - #else - matchinfo; - #endif + const struct xt_layer7_info * info = par->matchinfo; enum ip_conntrack_info master_ctinfo, ctinfo; struct nf_conn *master_conntrack, *conntrack; @@ -599,49 +573,21 @@ match(const struct sk_buff *skbin, } // load nf_conntrack_ipv4 -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35) -static int -#else -static bool -#endif -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28) -check(const struct xt_mtchk_param *par) +static int check(const struct xt_mtchk_param *par) { if (nf_ct_l3proto_try_module_get(par->match->family) < 0) { printk(KERN_WARNING "can't load conntrack support for " "proto=%d\n", par->match->family); -#else -check(const char *tablename, const void *inf, - const struct xt_match *match, void *matchinfo, - unsigned int hook_mask) -{ - if (nf_ct_l3proto_try_module_get(match->family) < 0) { - printk(KERN_WARNING "can't load conntrack support for " - "proto=%d\n", match->family); -#endif -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35) return -EINVAL; } return 0; -#else - return 0; - } - return 1; -#endif } -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28) - static void destroy(const struct xt_mtdtor_param *par) - { - nf_ct_l3proto_module_put(par->match->family); - } -#else - static void destroy(const struct xt_match *match, void *matchinfo) - { - nf_ct_l3proto_module_put(match->family); - } -#endif +static void destroy(const struct xt_mtdtor_param *par) +{ + nf_ct_l3proto_module_put(par->match->family); +} static struct xt_match xt_layer7_match[] __read_mostly = { { -- 2.47.3