All of lore.kernel.org
 help / color / mirror / Atom feed
From: Patrick McHardy <kaber@trash.net>
To: Martin Josefsson <gandalf@wlug.westbo.se>
Cc: Netfilter-devel <netfilter-devel@lists.netfilter.org>
Subject: Re: [PATCH 2/2] Cleanup returnvalues of protocolhandlers
Date: Mon, 20 Sep 2004 10:11:41 +0200	[thread overview]
Message-ID: <414E90BD.6090005@trash.net> (raw)
In-Reply-To: <1095597972.8380.16.camel@tux.rsn.bth.se>

[-- Attachment #1: Type: text/plain, Size: 2190 bytes --]

Martin Josefsson wrote:

>Hi Patrick
>
>Here's the second of two patches based on Pablo Neiras patch.
>
>This adds new defines to be returned from conntrack protocol modules in
>order to make it clear what they want. Most importantly, they get rid of
>the confusing mixing of positive and negative returnvalues.
>

We also need this patch on top of the last one to avoid ip_conntrack_in
from returning CONNTRACK_CONT (-1) to nf_hook_slow.

Regards
Patrick

>diff -urNp -x '*.orig' linux-2.6.9-rc1-bk16.stats/net/ipv4/netfilter/ip_conntrack_core.c linux-2.6.9-rc1-bk16/net/ipv4/netfilter/ip_conntrack_core.c
>--- linux-2.6.9-rc1-bk16.stats/net/ipv4/netfilter/ip_conntrack_core.c	2004-09-11 13:28:41.000000000 +0200
>+++ linux-2.6.9-rc1-bk16/net/ipv4/netfilter/ip_conntrack_core.c	2004-09-11 13:43:12.000000000 +0200
>@@ -786,14 +786,14 @@ unsigned int ip_conntrack_in(unsigned in
> 
> 	proto = ip_ct_find_proto((*pskb)->nh.iph->protocol);
> 
>-	/* It may be an special packet, error, unclean...
>-	 * inverse of the return code tells to the netfilter
>-	 * core what to do with the packet. */
>-	if (proto->error != NULL 
>-	    && (ret = proto->error(*pskb, &ctinfo, hooknum)) <= 0) {
>-		CONNTRACK_STAT_INC(error);
>-		CONNTRACK_STAT_INC(invalid);
>-		return -ret;
>+	/* It may be an special packet, error, unclean... */
>+	if (proto->error != NULL) {
>+		ret = proto->error(*pskb, &ctinfo, hooknum);
>+		if (ret != CONNTRACK_CONT) {
>+			CONNTRACK_STAT_INC(error);
>+			CONNTRACK_STAT_INC(invalid);
>+			return ret;
>+		}
> 	}
> 
> 	if (!(ct = resolve_normal_ct(*pskb, proto,&set_reply,hooknum,&ctinfo))) {
>@@ -811,16 +811,14 @@ unsigned int ip_conntrack_in(unsigned in
> 	IP_NF_ASSERT((*pskb)->nfct);
> 
> 	ret = proto->packet(ct, *pskb, ctinfo);
>-	if (ret < 0) {
>-		/* Invalid: inverse of the return code tells
>-		 * the netfilter core what to do*/
>+	if (ret != CONNTRACK_CONT) {
> 		nf_conntrack_put((*pskb)->nfct);
> 		(*pskb)->nfct = NULL;
> 		CONNTRACK_STAT_INC(invalid);
>-		return -ret;
>+		return ret;
> 	}
> 
>-	if (ret != NF_DROP && ct->helper) {
>+	if (ct->helper != NULL) {
> 		ret = ct->helper->help(*pskb, ct, ctinfo);
> 		if (ret == -1) {
> 			/* Invalid */
>
>  
>


[-- Attachment #2: x --]
[-- Type: text/plain, Size: 880 bytes --]

# This is a BitKeeper generated diff -Nru style patch.
#
# ChangeSet
#   2004/09/20 10:05:19+02:00 kaber@coreworks.de 
#   [NETFILTER]: Fix invalid return values from ip_conntrack_in
#   
#   Signed-off-by: Patrick McHardy <kaber@trash.net>
# 
# net/ipv4/netfilter/ip_conntrack_core.c
#   2004/09/20 10:04:56+02:00 kaber@coreworks.de +1 -1
#   [NETFILTER]: Fix invalid return values from ip_conntrack_in
#   
#   Signed-off-by: Patrick McHardy <kaber@trash.net>
# 
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	2004-09-20 10:08:05 +02:00
+++ b/net/ipv4/netfilter/ip_conntrack_core.c	2004-09-20 10:08:05 +02:00
@@ -767,7 +767,7 @@
 	if (set_reply)
 		set_bit(IPS_SEEN_REPLY_BIT, &ct->status);
 
-	return ret;
+	return NF_ACCEPT;
 }
 
 int invert_tuplepr(struct ip_conntrack_tuple *inverse,

      parent reply	other threads:[~2004-09-20  8:11 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-09-19 12:46 [PATCH 2/2] Cleanup returnvalues of protocolhandlers Martin Josefsson
2004-09-19 20:41 ` Patrick McHardy
2004-09-19 20:42   ` Patrick McHardy
2004-09-20  9:11     ` Martin Josefsson
2004-09-20  8:11 ` Patrick McHardy [this message]

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=414E90BD.6090005@trash.net \
    --to=kaber@trash.net \
    --cc=gandalf@wlug.westbo.se \
    --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.