All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ctnetlink: Fix NAT info setting.
@ 2005-12-01 12:39 Marcus Sundberg
  2005-12-01 13:22 ` Pablo Neira Ayuso
  0 siblings, 1 reply; 4+ messages in thread
From: Marcus Sundberg @ 2005-12-01 12:39 UTC (permalink / raw)
  To: Harald Welte; +Cc: Netfilter Development Mailinglist

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

Hi,

this patch fixes a latent bug with the NAT info setting in ctnetlink.
(Currently I believe it's never triggered, as NAT info can not be
 changed on existing conntracks)

//Marcus
-- 
---------------------------------------+--------------------------
  Marcus Sundberg <marcus@ingate.com>  | Firewalls with SIP & NAT
 Software Developer, Ingate Systems AB |  http://www.ingate.com/

[-- Attachment #2: ctnetlink-nat.diff --]
[-- Type: text/x-patch, Size: 1583 bytes --]

[NETFILTER] ctnetlink: Fix NAT info setting.

ip_nat_initialized() takes enum ip_nat_manip_type as it's second
argument, not a hook number. The current code was not only ugly,
but also broken as IP_NAT_MANIP_SRC != NF_IP_POST_ROUTING.

Signed-off-by: Marcus Sundberg <marcus@ingate.com>

--- linux-2.6.15-rc4/net/ipv4/netfilter/ip_conntrack_netlink.c	2005/12/01 12:25:50	1.1
+++ linux/net/ipv4/netfilter/ip_conntrack_netlink.c	2005/12/01 12:25:54
@@ -855,6 +855,7 @@ ctnetlink_change_status(struct ip_conntr
 		return -EINVAL;
 #else
 		unsigned int hooknum;
+		enum ip_nat_manip_type manip;
 		struct ip_nat_range range;
 
 		if (ctnetlink_parse_nat(cda, ct, &range) < 0)
@@ -867,17 +868,19 @@ ctnetlink_change_status(struct ip_conntr
 		/* This is tricky but it works. ip_nat_setup_info needs the
 		 * hook number as parameter, so let's do the correct 
 		 * conversion and run away */
-		if (status & IPS_SRC_NAT_DONE)
-			hooknum = NF_IP_POST_ROUTING; /* IP_NAT_MANIP_SRC */
-		else if (status & IPS_DST_NAT_DONE)
-			hooknum = NF_IP_PRE_ROUTING;  /* IP_NAT_MANIP_DST */
-		else 
+		if (status & IPS_SRC_NAT_DONE) {
+			hooknum = NF_IP_POST_ROUTING;
+			manip = IP_NAT_MANIP_SRC;
+		} else if (status & IPS_DST_NAT_DONE) {
+			hooknum = NF_IP_PRE_ROUTING;
+			manip = IP_NAT_MANIP_DST;
+		} else 
 			return -EINVAL; /* Missing NAT flags */
 
 		DEBUGP("NAT status: %lu\n", 
 		       status & (IPS_NAT_MASK | IPS_NAT_DONE_MASK));
 		
-		if (ip_nat_initialized(ct, hooknum))
+		if (ip_nat_initialized(ct, manip))
 			return -EEXIST;
 		ip_nat_setup_info(ct, &range, hooknum);
 

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

end of thread, other threads:[~2005-12-04 15:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-12-01 12:39 [PATCH] ctnetlink: Fix NAT info setting Marcus Sundberg
2005-12-01 13:22 ` Pablo Neira Ayuso
2005-12-01 13:38   ` Marcus Sundberg
2005-12-04 15:36   ` 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.