Patchwork libiptc: fix retry path in TC_INIT

login
register
mail settings
Submitter Miguel GAIO
Date April 17, 2012, 8:29 a.m.
Message ID <1334651363.10712.6.camel@mgo-thinkpad>
Download mbox | patch
Permalink /patch/153073/
State Superseded
Headers show

Comments

Miguel GAIO - April 17, 2012, 8:29 a.m.
Hi,

There is an issue on TC_INIT retry path:
In error case, TC_FREE is called and close sockfd.
The retry does not reopen then always fail.

The proposing patch reopen sockfd in retry patch.


Miguel
Pablo Neira - April 18, 2012, 11:12 p.m.
Hi Miguel,

On Tue, Apr 17, 2012 at 10:29:23AM +0200, Miguel GAIO wrote:
> Hi,
> 
> There is an issue on TC_INIT retry path:
> In error case, TC_FREE is called and close sockfd.
> The retry does not reopen then always fail.
> 
> The proposing patch reopen sockfd in retry patch.
> 
> 
> Miguel
>
> From 6dbb1a9f16c70a60c06559b31eac7ab3af789fa1 Mon Sep 17 00:00:00 2001
> From: Miguel GAIO <miguel.gaio@efixo.com>
> Date: Tue, 17 Apr 2012 10:16:28 +0200
> Subject: [PATCH 2008/2008]  libiptc: TC_INIT fix retry
> 
> ---
>  libiptc/libiptc.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libiptc/libiptc.c b/libiptc/libiptc.c
> index 63965e7..cd2ad9d 100644
> --- a/libiptc/libiptc.c
> +++ b/libiptc/libiptc.c
> @@ -1314,6 +1314,7 @@ TC_INIT(const char *tablename)
>  		return NULL;
>  	}
>  
> +retry:

Still iptc_fn is set to TC_FREE. We have to move up to the beginning
of TC_INIT.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

From 6dbb1a9f16c70a60c06559b31eac7ab3af789fa1 Mon Sep 17 00:00:00 2001
From: Miguel GAIO <miguel.gaio@efixo.com>
Date: Tue, 17 Apr 2012 10:16:28 +0200
Subject: [PATCH 2008/2008]  libiptc: TC_INIT fix retry

---
 libiptc/libiptc.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libiptc/libiptc.c b/libiptc/libiptc.c
index 63965e7..cd2ad9d 100644
--- a/libiptc/libiptc.c
+++ b/libiptc/libiptc.c
@@ -1314,6 +1314,7 @@  TC_INIT(const char *tablename)
 		return NULL;
 	}
 
+retry:
 	sockfd = socket(TC_AF, SOCK_RAW, IPPROTO_RAW);
 	if (sockfd < 0)
 		return NULL;
@@ -1324,7 +1325,6 @@  TC_INIT(const char *tablename)
 		abort();
 	}
 
-retry:
 	s = sizeof(info);
 
 	strcpy(info.name, tablename);
-- 
1.7.9.5