netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* `conntrack -L --src-nat --dst-nat` doesn't work with version 0.9.14
       [not found] <228485269.150241276129581116.JavaMail.root@tahiti.vyatta.com>
@ 2010-06-10  0:30 ` Mohit Mehta
  2010-06-10 12:43   ` Pablo Neira Ayuso
  0 siblings, 1 reply; 3+ messages in thread
From: Mohit Mehta @ 2010-06-10  0:30 UTC (permalink / raw)
  To: Pablo Neira Ayuso; +Cc: netfilter-devel

Hi Everyone,

With previous versions of conntrack [for eg. version 0.9.6]; you could list conntrack entries and have them filtered for both source and destination NAT. This was great for looking at all NAT entries at the same time.

However, it seems that in the current version that doesn't work i.e. you cannot filter entries for both source and destination NAT together. Filtering on either of the two types still works fine. I'm not quite sure about the history of this if any; so can someone point out whether this change was intentional or an oversight?

Thanks,
Mohit

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

* Re: `conntrack -L --src-nat --dst-nat` doesn't work with version 0.9.14
  2010-06-10  0:30 ` Mohit Mehta
@ 2010-06-10 12:43   ` Pablo Neira Ayuso
  0 siblings, 0 replies; 3+ messages in thread
From: Pablo Neira Ayuso @ 2010-06-10 12:43 UTC (permalink / raw)
  To: Mohit Mehta; +Cc: netfilter-devel

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

Mohit Mehta wrote:
> Hi Everyone,
> 
> With previous versions of conntrack [for eg. version 0.9.6]; you could list conntrack entries and have them filtered for both source and destination NAT. This was great for looking at all NAT entries at the same time.
> 
> However, it seems that in the current version that doesn't work i.e. you cannot filter entries for both source and destination NAT together. Filtering on either of the two types still works fine. I'm not quite sure about the history of this if any; so can someone point out whether this change was intentional or an oversight?

Could you test if this patch helps?

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

conntrack: fix `-L --src-nat --dst-nat'

From: Pablo Neira Ayuso <pablo@netfilter.org>

Since > 0.9.6, the conntrack listing with the options --src-nat
and --dst-nat does not work. This patch fixes the problem.

Reported-by: Mohit Mehta <mohit.mehta@vyatta.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
 src/conntrack.c |   22 +++++++++-------------
 1 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/src/conntrack.c b/src/conntrack.c
index eec3868..7d413c7 100644
--- a/src/conntrack.c
+++ b/src/conntrack.c
@@ -635,27 +635,23 @@ filter_nat(const struct nf_conntrack *obj, const struct nf_conntrack *ct)
 	uint32_t ip;
 
 	if (options & CT_OPT_SRC_NAT) {
-		if (!nfct_getobjopt(ct, NFCT_GOPT_IS_SNAT))
-		  	return 1;
-
 		if (nfct_attr_is_set(obj, ATTR_SNAT_IPV4)) {
 			ip = nfct_get_attr_u32(obj, ATTR_SNAT_IPV4);
-			if (ip != nfct_get_attr_u32(ct, ATTR_REPL_IPV4_DST))
-				return 1;
-		}
+			if (ip == nfct_get_attr_u32(ct, ATTR_REPL_IPV4_DST))
+				return 0;
+		} else if (nfct_getobjopt(ct, NFCT_GOPT_IS_SNAT))
+		  	return 0;
 	}
 	if (options & CT_OPT_DST_NAT) {
-		if (!nfct_getobjopt(ct, NFCT_GOPT_IS_DNAT))
-			return 1;
-
 		if (nfct_attr_is_set(obj, ATTR_DNAT_IPV4)) {
 			ip = nfct_get_attr_u32(obj, ATTR_DNAT_IPV4);
-			if (ip != nfct_get_attr_u32(ct, ATTR_REPL_IPV4_SRC))
-				return 1;
-		}
+			if (ip == nfct_get_attr_u32(ct, ATTR_REPL_IPV4_SRC))
+				return 0;
+		} else if (nfct_getobjopt(ct, NFCT_GOPT_IS_DNAT))
+			return 0;
 	}
 
-	return 0;
+	return 1;
 }
 
 static int counter;

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

* Re: `conntrack -L --src-nat --dst-nat` doesn't work with version 0.9.14
       [not found] <1746650726.153891276193083932.JavaMail.root@tahiti.vyatta.com>
@ 2010-06-10 18:04 ` Mohit Mehta
  0 siblings, 0 replies; 3+ messages in thread
From: Mohit Mehta @ 2010-06-10 18:04 UTC (permalink / raw)
  To: Pablo Neira Ayuso; +Cc: netfilter-devel

----- "Pablo Neira Ayuso" <pablo@netfilter.org> wrote:

> Mohit Mehta wrote:
> > Hi Everyone,
> > 
> > With previous versions of conntrack [for eg. version 0.9.6]; you
> could list conntrack entries and have them filtered for both source
> and destination NAT. This was great for looking at all NAT entries at
> the same time.
> > 
> > However, it seems that in the current version that doesn't work i.e.
> you cannot filter entries for both source and destination NAT
> together. Filtering on either of the two types still works fine. I'm
> not quite sure about the history of this if any; so can someone point
> out whether this change was intentional or an oversight?
> 
> Could you test if this patch helps?

Works Great! 

Thanks Pablo.

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

end of thread, other threads:[~2010-06-10 18:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <1746650726.153891276193083932.JavaMail.root@tahiti.vyatta.com>
2010-06-10 18:04 ` `conntrack -L --src-nat --dst-nat` doesn't work with version 0.9.14 Mohit Mehta
     [not found] <228485269.150241276129581116.JavaMail.root@tahiti.vyatta.com>
2010-06-10  0:30 ` Mohit Mehta
2010-06-10 12:43   ` Pablo Neira Ayuso

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).