netfilter: xtables: change hotdrop pointer to direct modification
authorJan Engelhardt <jengelh@medozas.de>
Tue, 7 Jul 2009 18:54:30 +0000 (20:54 +0200)
committerJan Engelhardt <jengelh@medozas.de>
Tue, 11 May 2010 16:35:27 +0000 (18:35 +0200)
Since xt_action_param is writable, let's use it. The pointer to
'bool hotdrop' always worried (8 bytes (64-bit) to write 1 byte!).
Surprisingly results in a reduction in size:

   text    data     bss filename
5457066  692730  357892 vmlinux.o-prev
5456554  692730  357892 vmlinux.o

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
22 files changed:
include/linux/netfilter/x_tables.h
net/bridge/netfilter/ebtables.c
net/ipv4/netfilter/arp_tables.c
net/ipv4/netfilter/ip_tables.c
net/ipv4/netfilter/ipt_ah.c
net/ipv4/netfilter/ipt_ecn.c
net/ipv6/netfilter/ip6_tables.c
net/ipv6/netfilter/ip6t_ah.c
net/ipv6/netfilter/ip6t_eui64.c
net/ipv6/netfilter/ip6t_frag.c
net/ipv6/netfilter/ip6t_hbh.c
net/ipv6/netfilter/ip6t_mh.c
net/ipv6/netfilter/ip6t_rt.c
net/netfilter/xt_connlimit.c
net/netfilter/xt_dccp.c
net/netfilter/xt_esp.c
net/netfilter/xt_hashlimit.c
net/netfilter/xt_multiport.c
net/netfilter/xt_recent.c
net/netfilter/xt_sctp.c
net/netfilter/xt_tcpmss.c
net/netfilter/xt_tcpudp.c

index 40c6a8d2a9eaef319fcc513d6011c2f2bcba6c35..c2ee5d8550cf13bc84ac69fde5733b3ddf631577 100644 (file)
@@ -196,6 +196,9 @@ struct xt_counters_info {
  * @hook:      hook number given packet came from
  * @family:    Actual NFPROTO_* through which the function is invoked
  *             (helpful when match->family == NFPROTO_UNSPEC)
+ *
+ * Fields written to by extensions:
+ *
  * @hotdrop:   drop packet if we had inspection problems
  * Network namespace obtainable using dev_net(in/out)
  */
@@ -212,7 +215,7 @@ struct xt_action_param {
        unsigned int thoff;
        unsigned int hooknum;
        u_int8_t family;
-       bool *hotdrop;
+       bool hotdrop;
 };
 
 /**
index 290d43541d46c32c04ab01e959cd98fcc1111b4d..59ca00e40dec2401b483bad4a7799775766e9f0d 100644 (file)
@@ -186,13 +186,12 @@ unsigned int ebt_do_table (unsigned int hook, struct sk_buff *skb,
        struct ebt_entries *chaininfo;
        const char *base;
        const struct ebt_table_info *private;
-       bool hotdrop = false;
        struct xt_action_param acpar;
 
        acpar.family  = NFPROTO_BRIDGE;
        acpar.in      = in;
        acpar.out     = out;
-       acpar.hotdrop = &hotdrop;
+       acpar.hotdrop = false;
        acpar.hooknum = hook;
 
        read_lock_bh(&table->lock);
@@ -216,7 +215,7 @@ unsigned int ebt_do_table (unsigned int hook, struct sk_buff *skb,
 
                if (EBT_MATCH_ITERATE(point, ebt_do_match, skb, &acpar) != 0)
                        goto letscontinue;
-               if (hotdrop) {
+               if (acpar.hotdrop) {
                        read_unlock_bh(&table->lock);
                        return NF_DROP;
                }
index 9e7d089f168abfdaeb4f3df1eb6f3d43d655a7a4..8cc56d26e93796f0a0a048df0122fea5963f1ca7 100644 (file)
@@ -260,7 +260,6 @@ unsigned int arpt_do_table(struct sk_buff *skb,
        static const char nulldevname[IFNAMSIZ] __attribute__((aligned(sizeof(long))));
        unsigned int verdict = NF_DROP;
        const struct arphdr *arp;
-       bool hotdrop = false;
        struct arpt_entry *e, *back;
        const char *indev, *outdev;
        void *table_base;
@@ -284,6 +283,7 @@ unsigned int arpt_do_table(struct sk_buff *skb,
        acpar.out     = out;
        acpar.hooknum = hook;
        acpar.family  = NFPROTO_ARP;
+       acpar.hotdrop = false;
 
        arp = arp_hdr(skb);
        do {
@@ -345,10 +345,10 @@ unsigned int arpt_do_table(struct sk_buff *skb,
                else
                        /* Verdict */
                        break;
-       } while (!hotdrop);
+       } while (!acpar.hotdrop);
        xt_info_rdunlock_bh();
 
-       if (hotdrop)
+       if (acpar.hotdrop)
                return NF_DROP;
        else
                return verdict;
index 4e674f2824a76d223cceb50e6c48f1329cc411bb..607f89f16b76214e7ca851ffd3b8b6b817fd0384 100644 (file)
@@ -308,7 +308,6 @@ ipt_do_table(struct sk_buff *skb,
 {
        static const char nulldevname[IFNAMSIZ] __attribute__((aligned(sizeof(long))));
        const struct iphdr *ip;
-       bool hotdrop = false;
        /* Initializing verdict to NF_DROP keeps gcc happy. */
        unsigned int verdict = NF_DROP;
        const char *indev, *outdev;
@@ -330,7 +329,7 @@ ipt_do_table(struct sk_buff *skb,
         * match it. */
        acpar.fragoff = ntohs(ip->frag_off) & IP_OFFSET;
        acpar.thoff   = ip_hdrlen(skb);
-       acpar.hotdrop = &hotdrop;
+       acpar.hotdrop = false;
        acpar.in      = in;
        acpar.out     = out;
        acpar.family  = NFPROTO_IPV4;
@@ -432,7 +431,7 @@ ipt_do_table(struct sk_buff *skb,
                else
                        /* Verdict */
                        break;
-       } while (!hotdrop);
+       } while (!acpar.hotdrop);
        xt_info_rdunlock_bh();
        pr_debug("Exiting %s; resetting sp from %u to %u\n",
                 __func__, *stackptr, origptr);
@@ -440,7 +439,7 @@ ipt_do_table(struct sk_buff *skb,
 #ifdef DEBUG_ALLOW_ALL
        return NF_ACCEPT;
 #else
-       if (hotdrop)
+       if (acpar.hotdrop)
                return NF_DROP;
        else return verdict;
 #endif
@@ -2154,7 +2153,7 @@ icmp_match(const struct sk_buff *skb, struct xt_action_param *par)
                 * can't.  Hence, no choice but to drop.
                 */
                duprintf("Dropping evil ICMP tinygram.\n");
-               *par->hotdrop = true;
+               par->hotdrop = true;
                return false;
        }
 
index c9d83dc2d6fa5650ee68295c46080bdbe05a0d1e..14a2aa8b8a142502095e4da8a034eae6e78a8313 100644 (file)
@@ -46,7 +46,7 @@ static bool ah_mt(const struct sk_buff *skb, struct xt_action_param *par)
                 * can't.  Hence, no choice but to drop.
                 */
                pr_debug("Dropping evil AH tinygram.\n");
-               *par->hotdrop = true;
+               par->hotdrop = true;
                return 0;
        }
 
index b79dddc9edd6236ed900bb02ad546d223e51805c..af6e9c778345ff802916cc7fa0078cbd79735c81 100644 (file)
@@ -78,7 +78,7 @@ static bool ecn_mt(const struct sk_buff *skb, struct xt_action_param *par)
        if (info->operation & (IPT_ECN_OP_MATCH_ECE|IPT_ECN_OP_MATCH_CWR)) {
                if (ip_hdr(skb)->protocol != IPPROTO_TCP)
                        return false;
-               if (!match_tcp(skb, info, par->hotdrop))
+               if (!match_tcp(skb, info, &par->hotdrop))
                        return false;
        }
 
index 4549f8d6f88fdfcf3d7079ad8f58efb873e1cfa8..557fac9689c06efaff3d88e269948ade4253ef6c 100644 (file)
@@ -337,7 +337,6 @@ ip6t_do_table(struct sk_buff *skb,
              struct xt_table *table)
 {
        static const char nulldevname[IFNAMSIZ] __attribute__((aligned(sizeof(long))));
-       bool hotdrop = false;
        /* Initializing verdict to NF_DROP keeps gcc happy. */
        unsigned int verdict = NF_DROP;
        const char *indev, *outdev;
@@ -356,7 +355,7 @@ ip6t_do_table(struct sk_buff *skb,
         * things we don't know, ie. tcp syn flag or ports).  If the
         * rule is also a fragment-specific rule, non-fragments won't
         * match it. */
-       acpar.hotdrop = &hotdrop;
+       acpar.hotdrop = false;
        acpar.in      = in;
        acpar.out     = out;
        acpar.family  = NFPROTO_IPV6;
@@ -380,7 +379,7 @@ ip6t_do_table(struct sk_buff *skb,
 
                IP_NF_ASSERT(e);
                if (!ip6_packet_match(skb, indev, outdev, &e->ipv6,
-                   &acpar.thoff, &acpar.fragoff, &hotdrop)) {
+                   &acpar.thoff, &acpar.fragoff, &acpar.hotdrop)) {
  no_match:
                        e = ip6t_next_entry(e);
                        continue;
@@ -447,7 +446,7 @@ ip6t_do_table(struct sk_buff *skb,
                else
                        /* Verdict */
                        break;
-       } while (!hotdrop);
+       } while (!acpar.hotdrop);
 
        xt_info_rdunlock_bh();
        *stackptr = origptr;
@@ -455,7 +454,7 @@ ip6t_do_table(struct sk_buff *skb,
 #ifdef DEBUG_ALLOW_ALL
        return NF_ACCEPT;
 #else
-       if (hotdrop)
+       if (acpar.hotdrop)
                return NF_DROP;
        else return verdict;
 #endif
@@ -2170,7 +2169,7 @@ icmp6_match(const struct sk_buff *skb, struct xt_action_param *par)
                 * can't.  Hence, no choice but to drop.
                 */
                duprintf("Dropping evil ICMP tinygram.\n");
-               *par->hotdrop = true;
+               par->hotdrop = true;
                return false;
        }
 
index c89887f35a46f522689a6bfe10e3f7269c7db00e..89cccc5a9c929a1912a400858e322d09bb829279 100644 (file)
@@ -48,13 +48,13 @@ static bool ah_mt6(const struct sk_buff *skb, struct xt_action_param *par)
        err = ipv6_find_hdr(skb, &ptr, NEXTHDR_AUTH, NULL);
        if (err < 0) {
                if (err != -ENOENT)
-                       *par->hotdrop = true;
+                       par->hotdrop = true;
                return false;
        }
 
        ah = skb_header_pointer(skb, ptr, sizeof(_ah), &_ah);
        if (ah == NULL) {
-               *par->hotdrop = true;
+               par->hotdrop = true;
                return false;
        }
 
index f32fce34145a6413ec98da1f709d6f79027b628c..aab0706908c5491fc4405468232dfdd440f23c4d 100644 (file)
@@ -27,7 +27,7 @@ eui64_mt6(const struct sk_buff *skb, struct xt_action_param *par)
        if (!(skb_mac_header(skb) >= skb->head &&
              skb_mac_header(skb) + ETH_HLEN <= skb->data) &&
            par->fragoff != 0) {
-               *par->hotdrop = true;
+               par->hotdrop = true;
                return false;
        }
 
index fcc8c72f218eaaa47694b46f766749f58bc00d9a..eda898fda6ca0615ec5a314f47b1f86be9c1a280 100644 (file)
@@ -46,13 +46,13 @@ frag_mt6(const struct sk_buff *skb, struct xt_action_param *par)
        err = ipv6_find_hdr(skb, &ptr, NEXTHDR_FRAGMENT, NULL);
        if (err < 0) {
                if (err != -ENOENT)
-                       *par->hotdrop = true;
+                       par->hotdrop = true;
                return false;
        }
 
        fh = skb_header_pointer(skb, ptr, sizeof(_frag), &_frag);
        if (fh == NULL) {
-               *par->hotdrop = true;
+               par->hotdrop = true;
                return false;
        }
 
index f8aebc098d71ae4cab50b02375ea306adc766a6e..59df051eaef636cc7f665a2cfb5dc2d21b30b33f 100644 (file)
@@ -65,13 +65,13 @@ hbh_mt6(const struct sk_buff *skb, struct xt_action_param *par)
                            NEXTHDR_HOP : NEXTHDR_DEST, NULL);
        if (err < 0) {
                if (err != -ENOENT)
-                       *par->hotdrop = true;
+                       par->hotdrop = true;
                return false;
        }
 
        oh = skb_header_pointer(skb, ptr, sizeof(_optsh), &_optsh);
        if (oh == NULL) {
-               *par->hotdrop = true;
+               par->hotdrop = true;
                return false;
        }
 
index eb1c3d65271ae93ebbbbcbc55250a998833fd374..0c90c66b199257dfd6123c1cc6a2ec904aa0053a 100644 (file)
@@ -47,14 +47,14 @@ static bool mh_mt6(const struct sk_buff *skb, struct xt_action_param *par)
                /* We've been asked to examine this packet, and we
                   can't.  Hence, no choice but to drop. */
                pr_debug("Dropping evil MH tinygram.\n");
-               *par->hotdrop = true;
+               par->hotdrop = true;
                return false;
        }
 
        if (mh->ip6mh_proto != IPPROTO_NONE) {
                pr_debug("Dropping invalid MH Payload Proto: %u\n",
                         mh->ip6mh_proto);
-               *par->hotdrop = true;
+               par->hotdrop = true;
                return false;
        }
 
index ee584693ee35343c5be31d3030ebb2011be05b13..d8488c50a8e0292e3b59515ec0c8ea6d7bf79f66 100644 (file)
@@ -52,13 +52,13 @@ static bool rt_mt6(const struct sk_buff *skb, struct xt_action_param *par)
        err = ipv6_find_hdr(skb, &ptr, NEXTHDR_ROUTING, NULL);
        if (err < 0) {
                if (err != -ENOENT)
-                       *par->hotdrop = true;
+                       par->hotdrop = true;
                return false;
        }
 
        rh = skb_header_pointer(skb, ptr, sizeof(_route), &_route);
        if (rh == NULL) {
-               *par->hotdrop = true;
+               par->hotdrop = true;
                return false;
        }
 
index f130fd9817bee0373daa9034d595e732ff97adbb..5c5b6b921b845b2fe1ba438ef9c13a2161e5b0ea 100644 (file)
@@ -206,14 +206,14 @@ connlimit_mt(const struct sk_buff *skb, struct xt_action_param *par)
 
        if (connections < 0) {
                /* kmalloc failed, drop it entirely */
-               *par->hotdrop = true;
+               par->hotdrop = true;
                return false;
        }
 
        return (connections > info->limit) ^ info->inverse;
 
  hotdrop:
-       *par->hotdrop = true;
+       par->hotdrop = true;
        return false;
 }
 
index cc2c2919439f0781e2a03ef9c19bb2f55ffdb8a1..b63d2a3d80ba5f6a601b23a031f7a4889978dd01 100644 (file)
@@ -107,7 +107,7 @@ dccp_mt(const struct sk_buff *skb, struct xt_action_param *par)
 
        dh = skb_header_pointer(skb, par->thoff, sizeof(_dh), &_dh);
        if (dh == NULL) {
-               *par->hotdrop = true;
+               par->hotdrop = true;
                return false;
        }
 
@@ -120,7 +120,7 @@ dccp_mt(const struct sk_buff *skb, struct xt_action_param *par)
                && DCCHECK(match_types(dh, info->typemask),
                           XT_DCCP_TYPE, info->flags, info->invflags)
                && DCCHECK(match_option(info->option, skb, par->thoff, dh,
-                                       par->hotdrop),
+                                       &par->hotdrop),
                           XT_DCCP_OPTION, info->flags, info->invflags);
 }
 
index 7c2d80020554426c8b10da7a964727c861f975c0..171ba82b5902095202d72705fd0ec00906e241b8 100644 (file)
@@ -52,7 +52,7 @@ static bool esp_mt(const struct sk_buff *skb, struct xt_action_param *par)
                 * can't.  Hence, no choice but to drop.
                 */
                pr_debug("Dropping evil ESP tinygram.\n");
-               *par->hotdrop = true;
+               par->hotdrop = true;
                return false;
        }
 
index 25a6e548ec2796fc9ebec2283d30cf1d09d83d27..b46a8390896d012dc4524e220a14d817d378dfd7 100644 (file)
@@ -562,7 +562,7 @@ hashlimit_mt(const struct sk_buff *skb, struct xt_action_param *par)
        return info->cfg.mode & XT_HASHLIMIT_INVERT;
 
  hotdrop:
-       *par->hotdrop = true;
+       par->hotdrop = true;
        return false;
 }
 
index 52beb68256c8961b265b32cdb2091604723a125d..ac1d3c3d09e72dbbfbf49f4dcdad6fc7600dcded 100644 (file)
@@ -87,7 +87,7 @@ multiport_mt(const struct sk_buff *skb, struct xt_action_param *par)
                 * can't.  Hence, no choice but to drop.
                 */
                pr_debug("Dropping evil offset=0 tinygram.\n");
-               *par->hotdrop = true;
+               par->hotdrop = true;
                return false;
        }
 
index 2808a7e33947f8ecc27e238f977f0e869c256a72..76aec6a44762df7de9a371ea61bab9925c933be8 100644 (file)
@@ -268,7 +268,7 @@ recent_mt(const struct sk_buff *skb, struct xt_action_param *par)
                        goto out;
                e = recent_entry_init(t, &addr, par->family, ttl);
                if (e == NULL)
-                       *par->hotdrop = true;
+                       par->hotdrop = true;
                ret = !ret;
                goto out;
        }
index 94d8b5deb2d004c2f97d6e925e49c54268a8afa2..c04fcf385c591875ec45f2f50812b9c564657869 100644 (file)
@@ -128,7 +128,7 @@ sctp_mt(const struct sk_buff *skb, struct xt_action_param *par)
        sh = skb_header_pointer(skb, par->thoff, sizeof(_sh), &_sh);
        if (sh == NULL) {
                pr_debug("Dropping evil TCP offset=0 tinygram.\n");
-               *par->hotdrop = true;
+               par->hotdrop = true;
                return false;
        }
        pr_debug("spt: %d\tdpt: %d\n", ntohs(sh->source), ntohs(sh->dest));
@@ -140,7 +140,7 @@ sctp_mt(const struct sk_buff *skb, struct xt_action_param *par)
                        && ntohs(sh->dest) <= info->dpts[1],
                        XT_SCTP_DEST_PORTS, info->flags, info->invflags)
                && SCCHECK(match_packet(skb, par->thoff + sizeof(sctp_sctphdr_t),
-                                       info, par->hotdrop),
+                                       info, &par->hotdrop),
                           XT_SCTP_CHUNK_TYPES, info->flags, info->invflags);
 }
 
index f90728f6b8a4c41e374d428fd798fef1fa3d2063..c53d4d18eadf7176754dbcd6e99cea8f12639786 100644 (file)
@@ -73,7 +73,7 @@ out:
        return info->invert;
 
 dropit:
-       *par->hotdrop = true;
+       par->hotdrop = true;
        return false;
 }
 
index dedde33c9db6786654259b81ef5c09228f218962..c14d4645daa3525d3ce45548344e4973763cd599 100644 (file)
@@ -77,7 +77,7 @@ static bool tcp_mt(const struct sk_buff *skb, struct xt_action_param *par)
                */
                if (par->fragoff == 1) {
                        pr_debug("Dropping evil TCP offset=1 frag.\n");
-                       *par->hotdrop = true;
+                       par->hotdrop = true;
                }
                /* Must not be a fragment. */
                return false;
@@ -90,7 +90,7 @@ static bool tcp_mt(const struct sk_buff *skb, struct xt_action_param *par)
                /* We've been asked to examine this packet, and we
                   can't.  Hence, no choice but to drop. */
                pr_debug("Dropping evil TCP offset=0 tinygram.\n");
-               *par->hotdrop = true;
+               par->hotdrop = true;
                return false;
        }
 
@@ -108,13 +108,13 @@ static bool tcp_mt(const struct sk_buff *skb, struct xt_action_param *par)
                return false;
        if (tcpinfo->option) {
                if (th->doff * 4 < sizeof(_tcph)) {
-                       *par->hotdrop = true;
+                       par->hotdrop = true;
                        return false;
                }
                if (!tcp_find_option(tcpinfo->option, skb, par->thoff,
                                     th->doff*4 - sizeof(_tcph),
                                     tcpinfo->invflags & XT_TCP_INV_OPTION,
-                                    par->hotdrop))
+                                    &par->hotdrop))
                        return false;
        }
        return true;
@@ -143,7 +143,7 @@ static bool udp_mt(const struct sk_buff *skb, struct xt_action_param *par)
                /* We've been asked to examine this packet, and we
                   can't.  Hence, no choice but to drop. */
                pr_debug("Dropping evil UDP tinygram.\n");
-               *par->hotdrop = true;
+               par->hotdrop = true;
                return false;
        }