From: Pawel Sikora <pluto@pld-linux.org>
To: netfilter-devel@lists.netfilter.org
Subject: [PATCH] ipt_connlimit / speed-up.
Date: Thu, 21 Apr 2005 05:10:01 +0200 [thread overview]
Message-ID: <200504210510.01886.pluto@pld-linux.org> (raw)
[-- Attachment #1: Type: text/plain, Size: 882 bytes --]
Hi All,
I've attached a small patch reduces register usage and redundant &0xff.
Regards,
Paweł.
ipt_iphash: (original)
movl %eax, %ecx
movzbl %ah, %edx
pushl %ebx
movl %eax, %ebx
shrl $16, %ecx
andl $255, %eax
xorl %eax, %edx
andl $255, %ecx
shrl $24, %ebx
xorl %edx, %ecx
xorl %ecx, %ebx
movl %ebx, %eax
popl %ebx
ret
ipt_iphash: (fixed)
movl %eax, %edx
shrl $8, %edx
xorl %eax, %edx
shrl $16, %eax
xorl %eax, %edx
shrl $8, %eax
xorl %eax, %edx
movzbl %dl,%eax
ret
--
/* Copyright (C) 2003, SCO, Inc. This is valuable Intellectual Property. */
#define say(x) lie(x)
[-- Attachment #2: ipt_connlimit.diff --]
[-- Type: text/x-diff, Size: 774 bytes --]
Index: connlimit/linux-2.6.11/net/ipv4/netfilter/ipt_connlimit.c
===================================================================
--- connlimit/linux-2.6.11/net/ipv4/netfilter/ipt_connlimit.c (revision 3884)
+++ connlimit/linux-2.6.11/net/ipv4/netfilter/ipt_connlimit.c (working copy)
@@ -35,15 +35,13 @@
struct list_head iphash[256];
};
-static int ipt_iphash(u_int32_t addr)
+static inline unsigned __attribute__((regparm(1), const))
+ipt_iphash(const unsigned addr)
{
- int hash;
-
- hash = addr & 0xff;
- hash ^= (addr >> 8) & 0xff;
- hash ^= (addr >> 16) & 0xff;
- hash ^= (addr >> 24) & 0xff;
- return hash;
+ return ((addr ^
+ (addr >> 8) ^
+ (addr >> 16) ^
+ (addr >> 24)) & 0xff);
}
static int count_them(struct ipt_connlimit_data *data,
next reply other threads:[~2005-04-21 3:10 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-04-21 3:10 Pawel Sikora [this message]
2005-04-21 8:44 ` [PATCH] ipt_connlimit / speed-up Jonas Berlin
2005-04-24 16:26 ` Patrick McHardy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200504210510.01886.pluto@pld-linux.org \
--to=pluto@pld-linux.org \
--cc=netfilter-devel@lists.netfilter.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.