From: Martin Josefsson Subject: Re: Fw: 2.4.20pre8aa2 failed assertions in ip_{conntrack,nat}_core.c Date: 10 Oct 2002 23:01:48 +0200 Sender: netfilter-devel-admin@lists.netfilter.org Message-ID: <1034283708.25146.25.camel@tux> References: <20021010.120720.39157107.davem@redhat.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-2RqmyzbIv4Mcpvtf2Hal" Cc: Netfilter-devel Return-path: To: Bernd Petrovitsch In-Reply-To: <20021010.120720.39157107.davem@redhat.com> Errors-To: netfilter-devel-admin@lists.netfilter.org List-Help: List-Post: List-Subscribe: , List-Unsubscribe: , List-Archive: List-Id: netfilter-devel.vger.kernel.org --=-2RqmyzbIv4Mcpvtf2Hal Content-Type: text/plain Content-Transfer-Encoding: 7bit > [2.] Full description of the problem/report: > I'm running 2.4.20pre8aa2 with all the firewalling stuff enabled > on a Pentium 75 and get occasionally > ---- snip (lines broken to keep it readable) ---- > Oct 10 20:00:04 fw kernel: ASSERT ip_conntrack_core.c:97 > &ip_conntrack_lock readlocked > Oct 10 20:00:04 fw kernel: ASSERT ip_conntrack_core.c:1067 > &ip_conntrack_lock not readlocked > Oct 10 20:00:04 fw kernel: ASSERT: ip_nat_core.c:841 > &ip_conntrack_lock not readlocked > Oct 10 20:00:04 fw kernel: ASSERT ip_conntrack_core.c:97 > &ip_conntrack_lock readlocked > Oct 10 20:00:04 fw kernel: ASSERT: ip_nat_core.c:841 > &ip_conntrack_lock not readlocked > ---- snip ---- > Otherwise everything is working fine. I've attached a small patch that fixes the ip_conntrack_core.c:97 and ip_nat_core.c:841 messages, These two messages aren't bugs in the locking, it's just the lock-debugging that can't handle "recursive" read-locks on the same lock and cpu correctly and thus reports an error even though everything is fine. (the patch is made against 2.4.20-pre8-ac2 but it should apply.) ASSERT ip_conntrack_core.c:1067 &ip_conntrack_lock not readlocked this might be a real locking-bug but it's only used in conntrack-handlers so unless you have two expectations happening at the same time on diffrent cpu's there's no problem. I'll look into it. > [6.] A small shell script or example program which triggers the > problem (if possible) > Simply http'ing or ftp'ing trigger it occasionally. The symptom is > that a particular (TCP-)connection "freezes". hmm, shouldn't happen. Can you describe it in more detail? -- /Martin Never argue with an idiot. They drag you down to their level, then beat you with experience. --=-2RqmyzbIv4Mcpvtf2Hal Content-Disposition: attachment; filename=exp_for_packet-lockpatch2 Content-Transfer-Encoding: quoted-printable Content-Type: text/x-patch; name=exp_for_packet-lockpatch2; charset=ISO-8859-15 diff -x '*.orig' -urN linux-2.4.20-pre8-ac3.orig/include/linux/netfilter_ip= v4/ip_conntrack_core.h linux-2.4.20-pre8-ac3/include/linux/netfilter_ipv4/i= p_conntrack_core.h --- linux-2.4.20-pre8-ac3.orig/include/linux/netfilter_ipv4/ip_conntrack_co= re.h 2002-10-10 15:41:55.000000000 +0200 +++ linux-2.4.20-pre8-ac3/include/linux/netfilter_ipv4/ip_conntrack_core.h = 2002-10-10 16:07:16.000000000 +0200 @@ -17,7 +17,7 @@ struct ip_conntrack_protocol; extern struct ip_conntrack_protocol *ip_ct_find_proto(u_int8_t protocol); /* Like above, but you already have conntrack read lock. */ -extern struct ip_conntrack_protocol *__find_proto(u_int8_t protocol); +extern struct ip_conntrack_protocol *__ip_ct_find_proto(u_int8_t protocol)= ; extern struct list_head protocol_list; =20 /* Returns conntrack if it dealt with ICMP, and filled in skb->nfct */ diff -x '*.orig' -urN linux-2.4.20-pre8-ac3.orig/net/ipv4/netfilter/ip_conn= track_core.c linux-2.4.20-pre8-ac3/net/ipv4/netfilter/ip_conntrack_core.c --- linux-2.4.20-pre8-ac3.orig/net/ipv4/netfilter/ip_conntrack_core.c 2002-= 10-10 15:41:57.000000000 +0200 +++ linux-2.4.20-pre8-ac3/net/ipv4/netfilter/ip_conntrack_core.c 2002-10-10= 16:07:16.000000000 +0200 @@ -74,7 +74,7 @@ return protocol =3D=3D curr->proto; } =20 -struct ip_conntrack_protocol *__find_proto(u_int8_t protocol) +struct ip_conntrack_protocol *__ip_ct_find_proto(u_int8_t protocol) { struct ip_conntrack_protocol *p; =20 @@ -92,7 +92,7 @@ struct ip_conntrack_protocol *p; =20 READ_LOCK(&ip_conntrack_lock); - p =3D __find_proto(protocol); + p =3D __ip_ct_find_proto(protocol); READ_UNLOCK(&ip_conntrack_lock); return p; } diff -x '*.orig' -urN linux-2.4.20-pre8-ac3.orig/net/ipv4/netfilter/ip_conn= track_standalone.c linux-2.4.20-pre8-ac3/net/ipv4/netfilter/ip_conntrack_st= andalone.c --- linux-2.4.20-pre8-ac3.orig/net/ipv4/netfilter/ip_conntrack_standalone.c= 2002-10-10 15:41:57.000000000 +0200 +++ linux-2.4.20-pre8-ac3/net/ipv4/netfilter/ip_conntrack_standalone.c 2002= -10-10 16:07:16.000000000 +0200 @@ -71,7 +71,7 @@ len +=3D sprintf(buffer + len, "use=3D%u proto=3D%u ", atomic_read(&expect->use), expect->tuple.dst.protonum); len +=3D print_tuple(buffer + len, &expect->tuple, - __find_proto(expect->tuple.dst.protonum)); + __ip_ct_find_proto(expect->tuple.dst.protonum)); len +=3D sprintf(buffer + len, "\n"); return len; } @@ -81,7 +81,7 @@ { unsigned int len; struct ip_conntrack_protocol *proto - =3D __find_proto(conntrack->tuplehash[IP_CT_DIR_ORIGINAL] + =3D __ip_ct_find_proto(conntrack->tuplehash[IP_CT_DIR_ORIGINAL] .tuple.dst.protonum); =20 len =3D sprintf(buffer, "%-8s %u %lu ", @@ -361,6 +361,7 @@ EXPORT_SYMBOL(ip_ct_selective_cleanup); EXPORT_SYMBOL(ip_ct_refresh); EXPORT_SYMBOL(ip_ct_find_proto); +EXPORT_SYMBOL(__ip_ct_find_proto); EXPORT_SYMBOL(ip_ct_find_helper); EXPORT_SYMBOL(ip_conntrack_expect_related); EXPORT_SYMBOL(ip_conntrack_change_expect); diff -x '*.orig' -urN linux-2.4.20-pre8-ac3.orig/net/ipv4/netfilter/ip_nat_= core.c linux-2.4.20-pre8-ac3/net/ipv4/netfilter/ip_nat_core.c --- linux-2.4.20-pre8-ac3.orig/net/ipv4/netfilter/ip_nat_core.c 2002-10-10 = 16:10:49.000000000 +0200 +++ linux-2.4.20-pre8-ac3/net/ipv4/netfilter/ip_nat_core.c 2002-10-10 16:10= :36.000000000 +0200 @@ -739,7 +739,7 @@ int ret =3D 1; =20 MUST_BE_READ_LOCKED(&ip_conntrack_lock); - proto =3D ip_ct_find_proto((*pskb)->nh.iph->protocol); + proto =3D __ip_ct_find_proto((*pskb)->nh.iph->protocol); if (proto->exp_matches_pkt) ret =3D proto->exp_matches_pkt(exp, pskb); =20 --=-2RqmyzbIv4Mcpvtf2Hal--