Skip to contentSkip to conversation

netfilter updates for the net tree

PATCH In review [email protected] 2 participants 5 messages Oct 30, 2012 – Oct 31, 2012

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

cover netfilter updates for the net tree

From: Pablo Neira Ayuso <[email protected]>

Hi David,

The following patchset contains fixes for your net tree, two of them are due to relatively recent changes, one has been a longstanding bug, they are:

* Fix incorrect usage of rt_gateway in the H.323 helper, from Julian Anastasov.

* Skip re-route in nf_nat code for ICMP traffic. If CONFIG_XFRM is enabled, we waste cycles to look up for the route again. This problem seems to be there since really long time. From Ulrich Weber.

* Fix mismatching section in nf_conntrack_reasm, from Hein Tibosch.

You can pull this changes from:

git://1984.lsi.us.es/nf master

Thanks!

Hein Tibosch (1):
netfilter: nf_defrag_ipv6: solve section mismatch in nf_conntrack_reasm

Julian Anastasov (1):
netfilter: nf_conntrack: fix rt_gateway checks for H.323 helper

Ulrich Weber (1):
netfilter: nf_nat: don't check for port change on ICMP tuples

 net/ipv4/netfilter/iptable_nat.c        |    4 +++-
 net/ipv6/netfilter/ip6table_nat.c       |    4 +++-
 net/ipv6/netfilter/nf_conntrack_reasm.c |    4 ++--
 net/netfilter/nf_conntrack_h323_main.c  |    3 ++-
 4 files changed, 10 insertions(+), 5 deletions(-)
Signature · 1 line
1.7.10.4
author maintainer
#1 lore raw

PATCH 1/3 netfilter: nf_conntrack: fix rt_gateway checks for H.323 helper

From: Julian Anastasov <[email protected]>

After the change "Adjust semantics of rt->rt_gateway" (commit f8126f1d51) we should properly match the nexthop when destinations are directly connected because rt_gateway can be 0.

The rt_gateway checks in H.323 helper try to avoid the creation of an unnecessary expectation in this call-forwarding case:

http://people.netfilter.org/zhaojingmin/h323_conntrack_nat_helper/#_Toc133598073

However, the existing code fails to avoid that in many cases, see this thread:

http://marc.info/?l=linux-netdev&m=135043175028620&w=2

It seems it is not trivial to know from the kernel if two hosts have to go through the firewall to communicate each other, which is the main point of the call-forwarding filter code to avoid creating unnecessary expectations.

So this patch just gets things the way they were as before commit f8126f1d51.

---
 net/netfilter/nf_conntrack_h323_main.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/netfilter/nf_conntrack_h323_main.c +2 -1
index 1b30b0d..962795e 100644
@@ -753,7 +753,8 @@ static int callforward_do_filter(const union nf_inet_addr *src,
 				   flowi4_to_flowi(&fl1), false)) {
 			if (!afinfo->route(&init_net, (struct dst_entry **)&rt2,
 					   flowi4_to_flowi(&fl2), false)) {
-				if (rt1->rt_gateway == rt2->rt_gateway &&
+				if (rt_nexthop(rt1, fl1.daddr) ==
+				    rt_nexthop(rt2, fl2.daddr) &&
 				    rt1->dst.dev  == rt2->dst.dev)
 					ret = 1;
 				dst_release(&rt2->dst);
Signature · 1 line
1.7.10.4
author maintainer
#2 lore raw

PATCH 2/3 netfilter: nf_nat: don't check for port change on ICMP tuples

In reply to [email protected]

From: Ulrich Weber <[email protected]>

ICMP tuples have id in src and type/code in dst. So comparing src.u.all with dst.u.all will always fail here and ip_xfrm_me_harder() is called for every ICMP packet, even if there was no NAT.

---
 net/ipv4/netfilter/iptable_nat.c  |    4 +++-
 net/ipv6/netfilter/ip6table_nat.c |    4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)
net/ipv4/netfilter/iptable_nat.c +3 -1
index 9e0ffaf..a820472 100644
@@ -184,7 +184,8 @@ nf_nat_ipv4_out(unsigned int hooknum,
 
 		if ((ct->tuplehash[dir].tuple.src.u3.ip !=
 		     ct->tuplehash[!dir].tuple.dst.u3.ip) ||
-		    (ct->tuplehash[dir].tuple.src.u.all !=
+		    (ct->tuplehash[dir].tuple.dst.protonum != IPPROTO_ICMP &&
+		     ct->tuplehash[dir].tuple.src.u.all !=
 		     ct->tuplehash[!dir].tuple.dst.u.all))
 			if (nf_xfrm_me_harder(skb, AF_INET) < 0)
 				ret = NF_DROP;
@@ -221,6 +222,7 @@ nf_nat_ipv4_local_fn(unsigned int hooknum,
 		}
 #ifdef CONFIG_XFRM
 		else if (!(IPCB(skb)->flags & IPSKB_XFRM_TRANSFORMED) &&
+			 ct->tuplehash[dir].tuple.dst.protonum != IPPROTO_ICMP &&
 			 ct->tuplehash[dir].tuple.dst.u.all !=
 			 ct->tuplehash[!dir].tuple.src.u.all)
 			if (nf_xfrm_me_harder(skb, AF_INET) < 0)
net/ipv6/netfilter/ip6table_nat.c +3 -1
index e418bd6..d57dab1 100644
@@ -186,7 +186,8 @@ nf_nat_ipv6_out(unsigned int hooknum,
 
 		if (!nf_inet_addr_cmp(&ct->tuplehash[dir].tuple.src.u3,
 				      &ct->tuplehash[!dir].tuple.dst.u3) ||
-		    (ct->tuplehash[dir].tuple.src.u.all !=
+		    (ct->tuplehash[dir].tuple.dst.protonum != IPPROTO_ICMPV6 &&
+		     ct->tuplehash[dir].tuple.src.u.all !=
 		     ct->tuplehash[!dir].tuple.dst.u.all))
 			if (nf_xfrm_me_harder(skb, AF_INET6) < 0)
 				ret = NF_DROP;
@@ -222,6 +223,7 @@ nf_nat_ipv6_local_fn(unsigned int hooknum,
 		}
 #ifdef CONFIG_XFRM
 		else if (!(IP6CB(skb)->flags & IP6SKB_XFRM_TRANSFORMED) &&
+			 ct->tuplehash[dir].tuple.dst.protonum != IPPROTO_ICMPV6 &&
 			 ct->tuplehash[dir].tuple.dst.u.all !=
 			 ct->tuplehash[!dir].tuple.src.u.all)
 			if (nf_xfrm_me_harder(skb, AF_INET6))
Signature · 1 line
1.7.10.4
author maintainer
#3 lore raw

PATCH 3/3 netfilter: nf_defrag_ipv6: solve section mismatch in nf_conntrack_reasm

In reply to [email protected]

From: Hein Tibosch <[email protected]>

WARNING: net/ipv6/netfilter/nf_defrag_ipv6.o(.text+0xe0): Section mismatch in reference from the function nf_ct_net_init() to the function .init.text:nf_ct_frag6_sysctl_register()
The function nf_ct_net_init() references the function
__init nf_ct_frag6_sysctl_register().

In case nf_conntrack_ipv6 is compiled as a module, nf_ct_net_init could be called after the init code and data are unloaded. Therefore remove the "__net_init" annotation from nf_ct_frag6_sysctl_register().

---
 net/ipv6/netfilter/nf_conntrack_reasm.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/ipv6/netfilter/nf_conntrack_reasm.c +2 -2
index 18bd9bb..22c8ea9 100644
@@ -85,7 +85,7 @@ static struct ctl_table nf_ct_frag6_sysctl_table[] = {
 	{ }
 };
 
-static int __net_init nf_ct_frag6_sysctl_register(struct net *net)
+static int nf_ct_frag6_sysctl_register(struct net *net)
 {
 	struct ctl_table *table;
 	struct ctl_table_header *hdr;
@@ -127,7 +127,7 @@ static void __net_exit nf_ct_frags6_sysctl_unregister(struct net *net)
 }
 
 #else
-static int __net_init nf_ct_frag6_sysctl_register(struct net *net)
+static int nf_ct_frag6_sysctl_register(struct net *net)
 {
 	return 0;
 }
Signature · 1 line
1.7.10.4
maintainer
#4 lore raw
In reply to [email protected]

From: [email protected]
Date: Tue, 30 Oct 2012 11:19:17 +0100

Quoted 11 lines

The following patchset contains fixes for your net tree, two of them are due to relatively recent changes, one has been a longstanding bug, they are:

* Fix incorrect usage of rt_gateway in the H.323 helper, from Julian Anastasov.

* Skip re-route in nf_nat code for ICMP traffic. If CONFIG_XFRM is enabled, we waste cycles to look up for the route again. This problem seems to be there since really long time. From Ulrich Weber.

Quoted 5 lines

* Fix mismatching section in nf_conntrack_reasm, from Hein Tibosch.

You can pull this changes from:

git://1984.lsi.us.es/nf master

Pulled, thanks.