All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH]: Fix ip_conntrack_core arguments to macros
@ 2003-07-12 10:40 Patrick McHardy
  2003-07-14  8:12 ` Harald Welte
  0 siblings, 1 reply; 3+ messages in thread
From: Patrick McHardy @ 2003-07-12 10:40 UTC (permalink / raw)
  To: laforge; +Cc: netfilter-devel

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1565 bytes --]

Hi Harald,
this patch fixes some places in ip_conntrack where LIST_FIND and
LIST_DELETE are passed functions with their arguments (like
LIST_FIND(ip_conntrack_hash[hash_conntrack(...)], ...). The argument is
expanded twice, this leads to two calls to hash_conntrack.

Dump of assembler code for function __ip_conntrack_find:
0x000004c0 <__ip_conntrack_find+0>:     push   %ebp
0x000004c1 <__ip_conntrack_find+1>:     mov    %esp,%ebp
0x000004c3 <__ip_conntrack_find+3>:     push   %edi
0x000004c4 <__ip_conntrack_find+4>:     push   %esi
0x000004c5 <__ip_conntrack_find+5>:     mov    0xc(%ebp),%edi
0x000004c8 <__ip_conntrack_find+8>:     mov    0x8(%ebp),%esi
0x000004cb <__ip_conntrack_find+11>:    push   %ebx
0x000004cc <__ip_conntrack_find+12>:    push   %esi
0x000004cd <__ip_conntrack_find+13>:    call   0x80 <hash_conntrack>
0x000004d2 <__ip_conntrack_find+18>:    mov    0x0,%edx
0x000004d8 <__ip_conntrack_find+24>:    pop    %ecx
0x000004d9 <__ip_conntrack_find+25>:    lea    (%edx,%eax,8),%ebx
0x000004dc <__ip_conntrack_find+28>:    lea    0x0(%esi,1),%esi
0x000004e0 <__ip_conntrack_find+32>:    mov    (%ebx),%ebx
0x000004e2 <__ip_conntrack_find+34>:    push   %esi
0x000004e3 <__ip_conntrack_find+35>:    call   0x80 <hash_conntrack>
...

Best regards,
Patrick


BTW: nice talk yesterday, i've seen the slides before but it still was
alot more interesting to here it directly from you. Sorry i didn't showed
up anymore, i had to get some sleep fast after getting up at 7 in the
morning (and drinking too much beer) ;) Are you still at linuxtag ?

[-- Attachment #2: Type: TEXT/plain, Size: 2290 bytes --]

# This is a BitKeeper generated patch for the following project:
# Project Name: Linux kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher.
# This patch includes the following deltas:
#	           ChangeSet	1.1211  -> 1.1212 
#	net/ipv4/netfilter/ip_conntrack_core.c	1.19    -> 1.20   
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 03/07/12	kaber@trash.net		1.1212
# [NETFILTER]: Don't use hash_conntrack in macros.
# 
# Disassembly of __ip_conntrack_find shows hash_conntrack is called twice
# because the parameter to LIST_FIND is evaluated twice. Same goes for
# LIST_DELETE when CONFIG_NETFILTER_DEBUG is defined.
# --------------------------------------------
#
diff -Nru a/net/ipv4/netfilter/ip_conntrack_core.c b/net/ipv4/netfilter/ip_conntrack_core.c
--- a/net/ipv4/netfilter/ip_conntrack_core.c	Sat Jul 12 04:56:56 2003
+++ b/net/ipv4/netfilter/ip_conntrack_core.c	Sat Jul 12 04:56:56 2003
@@ -290,14 +290,15 @@
 static void
 clean_from_lists(struct ip_conntrack *ct)
 {
+	unsigned int ho, hr;
+	
 	DEBUGP("clean_from_lists(%p)\n", ct);
 	MUST_BE_WRITE_LOCKED(&ip_conntrack_lock);
-	LIST_DELETE(&ip_conntrack_hash
-		    [hash_conntrack(&ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple)],
-		    &ct->tuplehash[IP_CT_DIR_ORIGINAL]);
-	LIST_DELETE(&ip_conntrack_hash
-		    [hash_conntrack(&ct->tuplehash[IP_CT_DIR_REPLY].tuple)],
-		    &ct->tuplehash[IP_CT_DIR_REPLY]);
+
+	ho = hash_conntrack(&ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple);
+	hr = hash_conntrack(&ct->tuplehash[IP_CT_DIR_REPLY].tuple);
+	LIST_DELETE(&ip_conntrack_hash[ho], &ct->tuplehash[IP_CT_DIR_ORIGINAL]);
+	LIST_DELETE(&ip_conntrack_hash[hr], &ct->tuplehash[IP_CT_DIR_REPLY]);
 
 	/* Destroy all un-established, pending expectations */
 	remove_expectations(ct);
@@ -369,9 +370,10 @@
 		    const struct ip_conntrack *ignored_conntrack)
 {
 	struct ip_conntrack_tuple_hash *h;
+	unsigned int hash = hash_conntrack(tuple);
 
 	MUST_BE_READ_LOCKED(&ip_conntrack_lock);
-	h = LIST_FIND(&ip_conntrack_hash[hash_conntrack(tuple)],
+	h = LIST_FIND(&ip_conntrack_hash[hash],
 		      conntrack_tuple_cmp,
 		      struct ip_conntrack_tuple_hash *,
 		      tuple, ignored_conntrack);

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-07-17 12:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-07-12 10:40 [PATCH]: Fix ip_conntrack_core arguments to macros Patrick McHardy
2003-07-14  8:12 ` Harald Welte
2003-07-17 12:29   ` Patrick McHardy

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.