All of lore.kernel.org
 help / color / mirror / Atom feed
From: Patrick McHardy <kaber@trash.net>
To: davem@davemloft.net
Cc: netfilter-devel@lists.netfilter.org, Patrick McHardy <kaber@trash.net>
Subject: [NETFILTER 15/17]: H.323 helper: replace internal_net_addr parameter by routing-based heuristic
Date: Tue, 30 May 2006 00:34:33 +0200 (MEST)	[thread overview]
Message-ID: <20060529223433.24834.80475.sendpatchset@localhost.localdomain> (raw)
In-Reply-To: <20060529223404.24834.30808.sendpatchset@localhost.localdomain>

[NETFILTER]: H.323 helper: replace internal_net_addr parameter by routing-based heuristic

Call Forwarding doesn't need to create an expectation if both peers can
reach each other without our help. The internal_net_addr parameter
lets the user explicitly specify a single network where this is true,
but is not very flexible and even fails in the common case that calls
will both be forwarded to outside parties and inside parties. Use an
optional heuristic based on routing instead, the assumption is that
if bpth the outgoing device and the gateway are equal, both peers can
reach each other directly.

Signed-off-by: Patrick McHardy <kaber@trash.net>

---
commit 4f26e484683957dde7142a135a8938efe9b69f5f
tree 02b20ac59b8a16cede8e2d4d590bc759ffc0c2de
parent cf55d393a491b6d441f36a68117e9bdfc8940a47
author Patrick McHardy <kaber@trash.net> Tue, 30 May 2006 00:08:45 +0200
committer Patrick McHardy <kaber@trash.net> Tue, 30 May 2006 00:08:45 +0200

 net/ipv4/netfilter/ip_conntrack_helper_h323.c |   57 ++++++++++++-------------
 1 files changed, 27 insertions(+), 30 deletions(-)

diff --git a/net/ipv4/netfilter/ip_conntrack_helper_h323.c b/net/ipv4/netfilter/ip_conntrack_helper_h323.c
index 3052468..0665674 100644
--- a/net/ipv4/netfilter/ip_conntrack_helper_h323.c
+++ b/net/ipv4/netfilter/ip_conntrack_helper_h323.c
@@ -40,12 +40,11 @@ static int gkrouted_only = 1;
 module_param(gkrouted_only, int, 0600);
 MODULE_PARM_DESC(gkrouted_only, "only accept calls from gatekeeper");
 
-static char *internal_net = NULL;
-static u_int32_t internal_net_addr = 0;
-static u_int32_t internal_net_mask = 0;
-module_param(internal_net, charp, 0600);
-MODULE_PARM_DESC(internal_net, "specify your internal network using format "
-		 "address/mask. this is used by call forwarding support");
+static int callforward_filter = 1;
+module_param(callforward_filter, bool, 0600);
+MODULE_PARM_DESC(callforward_filter, "only create call forwarding expectations "
+		                     "if both endpoints are on different sides "
+				     "(determined by routing information)");
 
 /* Hooks for NAT */
 int (*set_h245_addr_hook) (struct sk_buff ** pskb,
@@ -721,12 +720,28 @@ static int expect_callforwarding(struct 
 
 	/* If the calling party is on the same side of the forward-to party,
 	 * we don't need to track the second call */
-	if (internal_net &&
-	    ((ip & internal_net_mask) == internal_net_addr) ==
-	    ((ct->tuplehash[!dir].tuple.src.ip & internal_net_mask) ==
-	     internal_net_addr)) {
-		DEBUGP("ip_ct_q931: Call Forwarding not tracked\n");
-		return 0;
+	if (callforward_filter) {
+		struct rtable *rt1, *rt2;
+		struct flowi fl1 = {
+			.fl4_dst = ip,
+		};
+		struct flowi fl2 = {
+			.fl4_dst = ct->tuplehash[!dir].tuple.src.ip,
+		};
+
+		if (ip_route_output_key(&rt1, &fl1) == 0) {
+			if (ip_route_output_key(&rt2, &fl2) == 0) {
+				if (rt1->rt_gateway == rt2->rt_gateway &&
+				    rt1->u.dst.dev  == rt2->u.dst.dev)
+					ret = 1;
+				dst_release(&rt2->u.dst);
+			}
+			dst_release(&rt1->u.dst);
+		}
+		if (ret) {
+			DEBUGP("ip_ct_q931: Call Forwarding not tracked\n");
+			return 0;
+		}
 	}
 
 	/* Create expect for the second call leg */
@@ -1762,7 +1777,6 @@ static void fini(void)
 static int __init init(void)
 {
 	int ret;
-	char *p;
 
 	h323_buffer = kmalloc(65536, GFP_KERNEL);
 	if (!h323_buffer)
@@ -1772,23 +1786,6 @@ static int __init init(void)
 		fini();
 		return ret;
 	}
-
-	if (internal_net) {
-		if ((p = strchr(internal_net, '/')))
-			*p++ = 0;
-		if (isdigit(internal_net[0])) {
-			internal_net_addr = in_aton(internal_net);
-			if (p && isdigit(p[0]))
-				internal_net_mask = in_aton(p);
-			else
-				internal_net_mask = 0xffffffff;
-			internal_net_addr &= internal_net_mask;
-		}
-		DEBUGP("ip_ct_h323: internal_net = %u.%u.%u.%u/%u.%u.%u.%u\n",
-		       NIPQUAD(internal_net_addr),
-		       NIPQUAD(internal_net_mask));
-	}
-
 	DEBUGP("ip_ct_h323: init success\n");
 	return 0;
 }

  parent reply	other threads:[~2006-05-29 22:34 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-05-29 22:34 [NETFILTER 00/17]: Netfilter update for 2.6.18 Patrick McHardy
2006-05-29 22:34 ` [NETFILTER 01/17]: x_tables: remove some unnecessary casts Patrick McHardy
2006-05-29 22:34 ` [NETFILTER 02/17]: x_tables: add SCTP/DCCP support where missing Patrick McHardy
2006-05-29 22:34 ` [NETFILTER 03/17]: x_tables: add quota match Patrick McHardy
2006-05-29 22:34 ` [NETFILTER 04/17]: x_tables: add statistic match Patrick McHardy
2006-05-29 22:34 ` [NETFILTER 05/17]: recent match: replace by rewritten version Patrick McHardy
2006-05-30 13:11   ` Stephen Frost
2006-05-30 13:16     ` Patrick McHardy
2006-05-30 18:10       ` Stephen Frost
2006-05-31  0:48         ` Patrick McHardy
2006-05-29 22:34 ` [NETFILTER 06/17]: conntrack: don't call helpers for related ICMP messages Patrick McHardy
2006-05-29 22:34 ` [NETFILTER 07/17]: conntrack: add sysctl to disable checksumming Patrick McHardy
2006-05-29 22:34 ` [NETFILTER 08/17]: conntrack: add fixed timeout flag in connection tracking Patrick McHardy
2006-05-29 22:34 ` [NETFILTER 09/17]: ctnetlink: fix NAT configuration Patrick McHardy
2006-05-29 22:34 ` [NETFILTER 10/17]: ctnetlink: change table dumping not to require an unique ID Patrick McHardy
2006-05-29 22:34 ` [NETFILTER 11/17]: SNMP helper: fix debug module param type Patrick McHardy
2006-05-29 22:34 ` [NETFILTER 12/17]: FTP helper: search optimization Patrick McHardy
2006-05-29 22:34 ` [NETFILTER 13/17]: amanda helper: convert to textsearch infrastructure Patrick McHardy
2006-05-29 22:34 ` [NETFILTER 14/17]: H.323 helper: Add support for Call Forwarding Patrick McHardy
2006-05-29 22:34 ` Patrick McHardy [this message]
2006-05-29 22:34 ` [NETFILTER 16/17]: Add SIP connection tracking helper Patrick McHardy
2006-05-29 22:34 ` [NETFILTER 17/17]: PPTP helper: fixup gre_keymap_lookup() return type Patrick McHardy
2006-05-30  1:27 ` [NETFILTER 00/17]: Netfilter update for 2.6.18 David Miller

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=20060529223433.24834.80475.sendpatchset@localhost.localdomain \
    --to=kaber@trash.net \
    --cc=davem@davemloft.net \
    --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.