]> git.ipfire.org Git - thirdparty/xtables-addons.git/commitdiff
psd: reduce size of struct host
authorFlorian Westphal <fw@strlen.de>
Thu, 14 Jun 2012 08:33:15 +0000 (10:33 +0200)
committerJan Engelhardt <jengelh@inai.de>
Fri, 15 Jun 2012 13:17:21 +0000 (15:17 +0200)
We can use u16, saving 8 bytes total (weight cannot exceed
PSD_MAX_RATE, 10000). Also re-format comments & struct initializers.

No functional changes.

extensions/libxt_psd.c
extensions/xt_psd.c

index e60178b4da9082fef6f67b1a9dbfdfc0a4a3b1e0..483c69abc3f85cdf56542bf1ece50288e2992cd6 100644 (file)
@@ -137,19 +137,19 @@ static void psd_mt_save(const void *ip, const struct xt_entry_match *match)
 }
 
 static struct xtables_match psd_mt_reg = {
-       .name                   = "psd",
-       .version                = XTABLES_VERSION,
-       .revision       = 1,
-       .family        = NFPROTO_IPV4,
-       .size                   = XT_ALIGN(sizeof(struct xt_psd_info)),
+       .name           = "psd",
+       .version        = XTABLES_VERSION,
+       .revision       = 1,
+       .family         = NFPROTO_IPV4,
+       .size           = XT_ALIGN(sizeof(struct xt_psd_info)),
        .userspacesize  = XT_ALIGN(sizeof(struct xt_psd_info)),
-       .help                   = psd_mt_help,
-       .init                   = psd_mt_init,
-       .parse                  = psd_mt_parse,
-       .final_check    = psd_mt_final_check,
-       .print                  = psd_mt_print,
-       .save                   = psd_mt_save,
-       .extra_opts             = psd_mt_opts,
+       .help           = psd_mt_help,
+       .init           = psd_mt_init,
+       .parse          = psd_mt_parse,
+       .final_check    = psd_mt_final_check,
+       .print          = psd_mt_print,
+       .save           = psd_mt_save,
+       .extra_opts     = psd_mt_opts,
 };
 
 static __attribute__((constructor)) void psd_mt_ldr(void)
index 5f193517ecf57c4165cce22e67fce237384ff563..f5fcca0e0c5d054829caf456de3ecd352ffb632f 100644 (file)
@@ -61,9 +61,9 @@ struct host {
        unsigned long timestamp;
        struct in_addr src_addr;
        struct in_addr dest_addr;
-       unsigned short src_port;
-       int count;
-       int weight;
+       __be16 src_port;
+       uint16_t count;
+       uint8_t weight;
        struct port ports[SCAN_MAX_COUNT-1];
 };
 
@@ -77,6 +77,7 @@ static struct {
        spinlock_t lock;
        struct host list[LIST_SIZE];
        struct host *hash[HASH_SIZE];
+       int index;
 } state;
 
 /*