Skip to contentSkip to conversation

IPv6 conntrack support for neighbour discovery

PATCH In review Marek Szuba 6 participants 26 messages Oct 30, 2008 – Jan 27, 2009 5 messages not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hello everyone,

Following a suggestion I was given at the kernel Bugzilla I am forwarding this here.

It has come to my attention lately that the only two ICMPv6 packet types which IPv6 conntrack allows at present to initiate new connections are "echo request" and "node information query"; all other types appearing in this context are considered invalid. In particular, this includes two neighbour-discovery types specified in RFC 2461:
"router solicitation" and "neighbour solicitation" - meaning that if a server drops all INVALID packets early in its INPUT or OUTPUT chain of IPv6 netfilter's filter table, neither of the two can be received from clients. Given that router solicitation is used for stateless network autoconfiguration and neighbour solicitation is an IPv6 equivalent of ARP requests, having these two dropped can be quite bad - especially the latter, as it pretty much kills IPv6 over Ethernet.

Steps to reproduce:

1. Obtain an IPv6 address assigned to an Ethernet interface of host A (link-local will do);
2. If necesssary, flush all ip6tables filter chains on host A and set their policies to ACCEPT;
3. From host B on the same Ethernet network, ping6 the aforementioned IP address to verify that everything works;
4. On host A, run something like "ip6tables -I INPUT 1 -m state --state INVALID -j DROP";
5. Try to repeat step 3. This time the ping should fail and counters associated with the aforementioned rule should increment;
6. Repeat all the above using OUTPUT instead of INPUT, with the same final result.

BTW. This problem was discovered and (hopefully) fixed collaboratively by Łukasz Stelmach <[email protected]> and myself, please attribute both of us should the patch make it into code repositories.

Attaching a proposed solution to the problem - the enclosed patch adds "router solicitation" and "neighbour solicitation" to the list of ICMPv6 types IPv6 conntrack considers allowed to initiate new connections. Note that in principle "router advertisement" ICMPv6 packets could also be considered valid-new, as e.g. radvd periodically advertises its presence to the local network - as however it is not necessary to let this through as new to have things work (plus we aren't that big on broadcasting, even on supposedly-secure networks), the patch only adds solicitations to the list.

Best regards,

Signature · 1 line
MS
net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c +2 -0
@@ -108,6 +108,8 @@
 {
 	static const u_int8_t valid_new[] = {
 		[ICMPV6_ECHO_REQUEST - 128] = 1,
+		[NDISC_ROUTER_SOLICITATION - 128] = 1,
+		[NDISC_NEIGHBOUR_SOLICITATION - 128] = 1,
 		[ICMPV6_NI_QUERY - 128] = 1
 	};
 	int type = ct->tuplehash[0].tuple.dst.u.icmp.type - 128;
#1 lore raw
Quoted 37 lines · Marek Szuba

Hello everyone,

Following a suggestion I was given at the kernel Bugzilla I am forwarding this here.

It has come to my attention lately that the only two ICMPv6 packet types which IPv6 conntrack allows at present to initiate new connections are "echo request" and "node information query"; all other types appearing in this context are considered invalid. In particular, this includes two neighbour-discovery types specified in RFC 2461:
"router solicitation" and "neighbour solicitation" - meaning that if a server drops all INVALID packets early in its INPUT or OUTPUT chain of IPv6 netfilter's filter table, neither of the two can be received from clients. Given that router solicitation is used for stateless network autoconfiguration and neighbour solicitation is an IPv6 equivalent of ARP requests, having these two dropped can be quite bad - especially the latter, as it pretty much kills IPv6 over Ethernet.

Steps to reproduce:

1. Obtain an IPv6 address assigned to an Ethernet interface of host A (link-local will do);
2. If necesssary, flush all ip6tables filter chains on host A and set their policies to ACCEPT;
3. From host B on the same Ethernet network, ping6 the aforementioned IP address to verify that everything works;
4. On host A, run something like "ip6tables -I INPUT 1 -m state --state INVALID -j DROP";
5. Try to repeat step 3. This time the ping should fail and counters associated with the aforementioned rule should increment;
6. Repeat all the above using OUTPUT instead of INPUT, with the same final result.

BTW. This problem was discovered and (hopefully) fixed collaboratively by Łukasz Stelmach <[email protected]> and myself, please attribute both of us should the patch make it into code repositories.

Quoted 9 lines

Attaching a proposed solution to the problem - the enclosed patch adds "router solicitation" and "neighbour solicitation" to the list of ICMPv6 types IPv6 conntrack considers allowed to initiate new connections. Note that in principle "router advertisement" ICMPv6 packets could also be considered valid-new, as e.g. radvd periodically advertises its presence to the local network - as however it is not necessary to let this through as new to have things work (plus we aren't that big on broadcasting, even on supposedly-secure networks), the patch only adds solicitations to the list.

This patch seems fine to me. Yasuyuki, what do you think?

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#2 lore raw
Quoted 2 lines

This patch seems fine to me. Yasuyuki, what do you think?

In short: nf_conntrack_proto_icmpv6.c does not help for protocols using their messages. conntrack helper is better.

In detail:

A solicitation and advertisement does not construct 'connection' in most cases. Because the destination of solicitation is typically multicast address, and the source address of advertisement for replying is typically unicast address.

In the first place, static configuration is better for their messages.

Even if you add their ICMPv6 types to nf_coonntrack_proto_icmpv6.c, you will need to configure rules to allow IPv6 stack to receive Router/Neighbor Solicitation/Advertisement with all-node or solicited multicast address.

For example, IPv6 node sends neighbor solicitation to solicited multicast address to resolve L2 address. If you block it on your node, then other nodes (including routers) cannot resolve L2 address of your node. Also Duplicated Address Detection (DAD) does not work.

What threat you want to avoid ? If it is spoofed router advertisement to all-nodes multicast address, conntrack helper is better.
It would expect advertisement with the specific destination address (all-node multicast address or the link-local/global unicast address on your node), only when your node sends router solicitation (with the all-node multicast address or the unicast address of router as destination address).

But I don't recommend to block unsolicited router advertisement. If many hosts block it on a link, that results in increasing traffic on the link by solicitation. And hosts would not be able to know the change of configuration on router in short time.

FYI: IIRC SEcure Neighbor Discovery (SEND) is the current solution from IETF guys, but I don't know the implementation for Linux.

-- Yasuyuki Kozakai

From: Patrick McHardy <[email protected]>
Date: Tue, 04 Nov 2008 15:06:55 +0100

Quoted 48 lines
Quoted 37 lines · Marek Szuba

Hello everyone,

Following a suggestion I was given at the kernel Bugzilla I am forwarding this here.

It has come to my attention lately that the only two ICMPv6 packet types which IPv6 conntrack allows at present to initiate new connections are "echo request" and "node information query"; all other types appearing in this context are considered invalid. In particular, this includes two neighbour-discovery types specified in RFC 2461:
"router solicitation" and "neighbour solicitation" - meaning that if a server drops all INVALID packets early in its INPUT or OUTPUT chain of IPv6 netfilter's filter table, neither of the two can be received from clients. Given that router solicitation is used for stateless network autoconfiguration and neighbour solicitation is an IPv6 equivalent of ARP requests, having these two dropped can be quite bad - especially the latter, as it pretty much kills IPv6 over Ethernet.

Steps to reproduce:

1. Obtain an IPv6 address assigned to an Ethernet interface of host A (link-local will do);
2. If necesssary, flush all ip6tables filter chains on host A and set their policies to ACCEPT;
3. From host B on the same Ethernet network, ping6 the aforementioned IP address to verify that everything works;
4. On host A, run something like "ip6tables -I INPUT 1 -m state --state INVALID -j DROP";
5. Try to repeat step 3. This time the ping should fail and counters associated with the aforementioned rule should increment;
6. Repeat all the above using OUTPUT instead of INPUT, with the same final result.

BTW. This problem was discovered and (hopefully) fixed collaboratively by Łukasz Stelmach <[email protected]> and myself, please attribute both of us should the patch make it into code repositories.

Quoted 9 lines

Attaching a proposed solution to the problem - the enclosed patch adds "router solicitation" and "neighbour solicitation" to the list of ICMPv6 types IPv6 conntrack considers allowed to initiate new connections. Note that in principle "router advertisement" ICMPv6 packets could also be considered valid-new, as e.g. radvd periodically advertises its presence to the local network - as however it is not necessary to let this through as new to have things work (plus we aren't that big on broadcasting, even on supposedly-secure networks), the patch only adds solicitations to the list.

Quoted 7 lines

This patch seems fine to me. Yasuyuki, what do you think?

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): [email protected]

#4 lore raw
Quoted 33 lines · Yasuyuki KOZAKAI
Quoted 1 line

This patch seems fine to me. Yasuyuki, what do you think?

In short: nf_conntrack_proto_icmpv6.c does not help for protocols using their messages. conntrack helper is better.

In detail:

A solicitation and advertisement does not construct 'connection' in most cases. Because the destination of solicitation is typically multicast address, and the source address of advertisement for replying is typically unicast address.

In the first place, static configuration is better for their messages.

Even if you add their ICMPv6 types to nf_coonntrack_proto_icmpv6.c, you will need to configure rules to allow IPv6 stack to receive Router/Neighbor Solicitation/Advertisement with all-node or solicited multicast address.

For example, IPv6 node sends neighbor solicitation to solicited multicast address to resolve L2 address. If you block it on your node, then other nodes (including routers) cannot resolve L2 address of your node. Also Duplicated Address Detection (DAD) does not work.

What threat you want to avoid ? If it is spoofed router advertisement to all-nodes multicast address, conntrack helper is better.
It would expect advertisement with the specific destination address (all-node multicast address or the link-local/global unicast address on your node), only when your node sends router solicitation (with the all-node multicast address or the unicast address of router as destination address).

Quoted 7 lines

But I don't recommend to block unsolicited router advertisement. If many hosts block it on a link, that results in increasing traffic on the link by solicitation. And hosts would not be able to know the change of configuration on router in short time.

FYI: IIRC SEcure Neighbor Discovery (SEND) is the current solution from IETF guys, but I don't know the implementation for Linux.

Thanks for the detailed explanation.

Marek, could you close the bugzilla report with a link to Yasuyuki's explanation please? Thanks!

#5 lore raw
Quoted 2 lines · On Wed, 05 Nov 2008 10:50:29 +0100 Patrick McHardy <[email protected]> wrote:

Marek, could you close the bugzilla report with a link to Yasuyuki's explanation please? Thanks!

What resolution should I specify? I believe we've got the following
options: CODE_FIX, WILL_NOT_FIX (which rejects the bug) and WILL_FIX_LATER (which defers the bug).

Signature · 1 line
MS
#6 lore raw
Quoted 8 lines · Marek Szuba
Quoted 2 lines · On Wed, 05 Nov 2008 10:50:29 +0100 Patrick McHardy <[email protected]> wrote:

Marek, could you close the bugzilla report with a link to Yasuyuki's explanation please? Thanks!

What resolution should I specify? I believe we've got the following
options: CODE_FIX, WILL_NOT_FIX (which rejects the bug) and WILL_FIX_LATER (which defers the bug).

I'd suggest WILL_NOT_FIX with an appropriate comment.

#7 lore raw
In reply to Marek Szuba

From: Marek Szuba <[email protected]>
Date: Wed, 5 Nov 2008 13:40:21 +0100

Quoted 8 lines
Quoted 2 lines · On Wed, 05 Nov 2008 10:50:29 +0100 Patrick McHardy <[email protected]> wrote:

Marek, could you close the bugzilla report with a link to Yasuyuki's explanation please? Thanks!

What resolution should I specify? I believe we've got the following
options: CODE_FIX, WILL_NOT_FIX (which rejects the bug) and WILL_FIX_LATER (which defers the bug).

WILL_NOT_FIX. That is not bug of connection tracking.

Your patch cannot support protocols using their ICMPv6 messages as I explained. Please feel free to implement my suggestion or propose better way.

-- Yasuyuki Kozakai

A message that is not in the archive (sent off-list or not yet received): [email protected]

#9 lore raw
Quoted 2 lines · On Wed, 05 Nov 2008 13:44:05 +0900 (JST) Yasuyuki KOZAKAI…

In short: nf_conntrack_proto_icmpv6.c does not help for protocols using their messages. conntrack helper is better.

So what you are suggesting is, someone needs to write such a helper module. Correct?

Quoted 1 line

In the first place, static configuration is better for their messages.

Do you mean pre-filling neighbour-discovery cache? If so, I agree with you on this as far as router discovery is concerned but I don't think such an approach is viable with neighbour discovery, except possibly on very small and centrally-managed LANs - any addition or removal of hosts and/or addresses on the network would require propagating the change to all machines on it.

Quoted 4 lines

Even if you add their ICMPv6 types to nf_coonntrack_proto_icmpv6.c, you will need to configure rules to allow IPv6 stack to receive Router/Neighbor Solicitation/Advertisement with all-node or solicited multicast address.

True. To be honest, some no-nonsense documentation of what data an IPv6 host must receive/return on what address in order to actually exist on the network is clearly in order here... I've been working with setting up IPv6 on various networks for quite a while and it takes much more work here than with IPv4 to set up a "what isn't explicitly allowed is forbidden" policy.

Quoted 4 lines

For example, IPv6 node sends neighbor solicitation to solicited multicast address to resolve L2 address. If you block it on your node, then other nodes (including routers) cannot resolve L2 address of your node.

This is precisely the problem I have encountered here.

Quoted 2 lines

What threat you want to avoid ? If it is spoofed router advertisement to all-nodes multicast address, conntrack helper is better.

I wasn't trying to avoid any specific threat here, it's just that my iptables rules always contain a rule which kills packets with state INVALID and in case of IPv6 on a LAN this breaks resolving of L2 addresses.

Quoted 4 lines

But I don't recommend to block unsolicited router advertisement. If many hosts block it on a link, that results in increasing traffic on the link by solicitation. And hosts would not be able to know the change of configuration on router in short time.

Fair enough.

Quoted 2 lines

FYI: IIRC SEcure Neighbor Discovery (SEND) is the current solution from IETF guys, but I don't know the implementation for Linux.

I haven't seen any such implementations yet, then again this doesn't mean there are none of course.

Signature · 1 line
MS
#10 lore raw

cover IPv6 conntrack support for neighbour discovery

Hi,

Quoted 7 lines · Marek Szuba
Quoted 2 lines · On Wed, 05 Nov 2008 13:44:05 +0900 (JST) Yasuyuki KOZAKAI…

In short: nf_conntrack_proto_icmpv6.c does not help for protocols using their messages. conntrack helper is better.

So what you are suggesting is, someone needs to write such a helper module. Correct?

I'm reopening this thread because Victor Stinner (in CC) has opened a similar bug in bugzilla:
http://bugzilla.netfilter.org/show_bug.cgi?id=567
Pablo has then pointed out this discussion.

I don't think that we have to handle these part of ICMPv6 protocol with a connection tracking helper. For example, here's the trace of the exchange which are needed to obtain a "public" IPv6 address on my setup:

15:14:42.377744 IP6 fe80::a00:27ff:feb3:e26c > ff02::2: ICMP6, router solicitation, length 16
15:14:42.405725 IP6 fe80::207:cbff:fe90:f8d1 > ff02::1: ICMP6, router advertisement, length 104 15:14:43.401395 IP6 :: > ff02::1:ffb3:e26c: ICMP6, neighbor solicitation, who has 2a01:e35:1394:5bd0:a00:27ff:feb3:e26c, length 24 15:14:46.628300 IP6 fe80::a00:27ff:feb3:e26c > ff02::16: HBH ICMP6, multicast listener report v2, 1 group record(s), length 28

If we only analyse the first two, we see we can't easily invert the tuple of the connection: we don't know which address will answer and the destination address of the packet are changing. But as pointed by Yasuyuki the main point is not here, we need to accept the router advertisement to be able to detect changes in the routing. In fact, theses protocols are stateless and should be considered as such.

IMHO, the main issue here is to tag the packets as INVALID. They are valid even we can't track them. I thus propose a patchset which adds the capability to avoid connection tracking the packets of these protocols. A sysctl flag can be set to activate this feature.

With this patchset, the concerned packet don't get blocked by the INVALID rule and are not seen by the conntrack. They can be cleanly filtered in the ruleset.

Patchset statistics:

 net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c |   35 +++++++++++++++++++++++-
 1 files changed, 34 insertions(+), 1 deletions(-)

BR,

Signature · 3 lines
Eric Leblond <[email protected]>
INL: http://www.inl.fr/
NuFW: http://www.nufw.org/
#11 lore raw

PATCH 1/2 netfilter: use sysctl to choose icmpv6 autoconf behaviour.

This patches adds a sysctl flag to decide wheither or not detect icmpv6 autoconfiguration packet as INVALID.

---
 net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c +8 -0
index 0dbac72..4aa80ba 100644
@@ -27,6 +27,7 @@
 #include <net/netfilter/nf_log.h>
 
 static unsigned long nf_ct_icmpv6_timeout __read_mostly = 30*HZ;
+static unsigned long nf_ct_icmpv6_autoconf __read_mostly = 0;
 
 static bool icmpv6_pkt_to_tuple(const struct sk_buff *skb,
 				unsigned int dataoff,
@@ -259,6 +260,13 @@ static struct ctl_table icmpv6_sysctl_table[] = {
 		.proc_handler	= proc_dointvec_jiffies,
 	},
 	{
+		.procname	= "nf_conntrack_icmpv6_autoconf",
+		.data		= &nf_ct_icmpv6_autoconf,
+		.maxlen		= sizeof(unsigned int),
+		.mode		= 0644,
+		.proc_handler	= proc_dointvec_jiffies,
+	},
+	{
 		.ctl_name	= 0
 	}
 };
Signature · 1 line
1.5.6.3
#12 lore raw

PATCH 2/2 netfilter: don't track ICMPv6 negotiation message.

In reply to Eric Leblond

This patch removes connection tracking handling for ICMPv6 messages related to autoconfiguration. They can be tracked because they are massively using multicast (on pre-defined address). But they are not invalid.

---
 net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c |   27 +++++++++++++++++++++++-
 1 files changed, 26 insertions(+), 1 deletions(-)
net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c +26 -1
index 4aa80ba..34548c3 100644
@@ -54,12 +54,25 @@ static const u_int8_t invmap[] = {
 	[ICMPV6_NI_REPLY - 128]		= ICMPV6_NI_QUERY +1
 };
 
+static const u_int8_t noct_valid_new[] = {
+	[ICMPV6_MGM_QUERY - 130] = 1,
+	[ICMPV6_MGM_REPORT -130] = 1,
+	[ICMPV6_MGM_REDUCTION - 130] = 1,
+	[NDISC_ROUTER_SOLICITATION - 130] = 1,
+	[NDISC_ROUTER_ADVERTISEMENT - 130] = 1,
+	[NDISC_NEIGHBOUR_SOLICITATION - 130] = 1,
+	[NDISC_NEIGHBOUR_ADVERTISEMENT - 130] = 1,
+	[ICMPV6_MLD2_REPORT - 130] = 1
+};
+
 static bool icmpv6_invert_tuple(struct nf_conntrack_tuple *tuple,
 				const struct nf_conntrack_tuple *orig)
 {
 	int type = orig->dst.u.icmp.type - 128;
-	if (type < 0 || type >= sizeof(invmap) || !invmap[type])
+
+	if (type < 0 || type >= sizeof(invmap) || !invmap[type]) {
 		return false;
+	}
 
 	tuple->src.u.icmp.id   = orig->src.u.icmp.id;
 	tuple->dst.u.icmp.type = invmap[type] - 1;
@@ -109,6 +122,7 @@ static bool icmpv6_new(struct nf_conn *ct, const struct sk_buff *skb,
 		[ICMPV6_ECHO_REQUEST - 128] = 1,
 		[ICMPV6_NI_QUERY - 128] = 1
 	};
+
 	int type = ct->tuplehash[0].tuple.dst.u.icmp.type - 128;
 
 	if (type < 0 || type >= sizeof(valid_new) || !valid_new[type]) {
@@ -198,6 +212,17 @@ icmpv6_error(struct net *net, struct sk_buff *skb, unsigned int dataoff,
 		return -NF_ACCEPT;
 	}
 
+	/* autoconf message handling */
+	if (nf_ct_icmpv6_autoconf) {
+		int type = icmp6h->icmp6_type - 130;
+		if (type >= 0 && type < sizeof(noct_valid_new)
+		    && noct_valid_new[type]) {
+			skb->nfct = &nf_conntrack_untracked.ct_general;
+			skb->nfctinfo = IP_CT_NEW;
+			nf_conntrack_get(skb->nfct);
+			return -NF_ACCEPT;
+		}
+	}
 	/* is not error message ? */
 	if (icmp6h->icmp6_type >= 128)
 		return NF_ACCEPT;
Signature · 1 line
1.5.6.3
#13 lore raw

Re: [PATCH 2/2] netfilter: don't track ICMPv6 negotiation message.

Hi,

Oups, sorry, this patch is not clean (indentation change and spacing). I send an other one in reply to this mail.

Quoted 67 lines · Eric Leblond

This patch removes connection tracking handling for ICMPv6 messages related to autoconfiguration. They can be tracked because they are massively using multicast (on pre-defined address). But they are not invalid.

---
 net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c |   27 +++++++++++++++++++++++-
 1 files changed, 26 insertions(+), 1 deletions(-)
net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c +26 -1
index 4aa80ba..34548c3 100644
@@ -54,12 +54,25 @@ static const u_int8_t invmap[] = {
 	[ICMPV6_NI_REPLY - 128]		= ICMPV6_NI_QUERY +1
 };
 
+static const u_int8_t noct_valid_new[] = {
+	[ICMPV6_MGM_QUERY - 130] = 1,
+	[ICMPV6_MGM_REPORT -130] = 1,
+	[ICMPV6_MGM_REDUCTION - 130] = 1,
+	[NDISC_ROUTER_SOLICITATION - 130] = 1,
+	[NDISC_ROUTER_ADVERTISEMENT - 130] = 1,
+	[NDISC_NEIGHBOUR_SOLICITATION - 130] = 1,
+	[NDISC_NEIGHBOUR_ADVERTISEMENT - 130] = 1,
+	[ICMPV6_MLD2_REPORT - 130] = 1
+};
+
 static bool icmpv6_invert_tuple(struct nf_conntrack_tuple *tuple,
 				const struct nf_conntrack_tuple *orig)
 {
 	int type = orig->dst.u.icmp.type - 128;
-	if (type < 0 || type >= sizeof(invmap) || !invmap[type])
+
+	if (type < 0 || type >= sizeof(invmap) || !invmap[type]) {
 		return false;
+	}
 
 	tuple->src.u.icmp.id   = orig->src.u.icmp.id;
 	tuple->dst.u.icmp.type = invmap[type] - 1;
@@ -109,6 +122,7 @@ static bool icmpv6_new(struct nf_conn *ct, const struct sk_buff *skb,
 		[ICMPV6_ECHO_REQUEST - 128] = 1,
 		[ICMPV6_NI_QUERY - 128] = 1
 	};
+
 	int type = ct->tuplehash[0].tuple.dst.u.icmp.type - 128;
 
 	if (type < 0 || type >= sizeof(valid_new) || !valid_new[type]) {
@@ -198,6 +212,17 @@ icmpv6_error(struct net *net, struct sk_buff *skb, unsigned int dataoff,
 		return -NF_ACCEPT;
 	}
 
+	/* autoconf message handling */
+	if (nf_ct_icmpv6_autoconf) {
+		int type = icmp6h->icmp6_type - 130;
+		if (type >= 0 && type < sizeof(noct_valid_new)
+		    && noct_valid_new[type]) {
+			skb->nfct = &nf_conntrack_untracked.ct_general;
+			skb->nfctinfo = IP_CT_NEW;
+			nf_conntrack_get(skb->nfct);
+			return -NF_ACCEPT;
+		}
+	}
 	/* is not error message ? */
 	if (icmp6h->icmp6_type >= 128)
 		return NF_ACCEPT;
Signature · 3 lines
Eric Leblond <[email protected]>
INL: http://www.inl.fr/
NuFW: http://www.nufw.org/
#14 lore raw

PATCH RESEND 2/2 netfilter: don't track ICMPv6 negotiation message.

This patch removes connection tracking handling for ICMPv6 messages related to autoconfiguration. They can be tracked because they are massively using multicast (on pre-defined address). But they are not invalid.

---
 net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)
net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c +22 -0
index 4aa80ba..a178270 100644
@@ -54,6 +54,17 @@ static const u_int8_t invmap[] = {
 	[ICMPV6_NI_REPLY - 128]		= ICMPV6_NI_QUERY +1
 };
 
+static const u_int8_t noct_valid_new[] = {
+	[ICMPV6_MGM_QUERY - 130] = 1,
+	[ICMPV6_MGM_REPORT -130] = 1,
+	[ICMPV6_MGM_REDUCTION - 130] = 1,
+	[NDISC_ROUTER_SOLICITATION - 130] = 1,
+	[NDISC_ROUTER_ADVERTISEMENT - 130] = 1,
+	[NDISC_NEIGHBOUR_SOLICITATION - 130] = 1,
+	[NDISC_NEIGHBOUR_ADVERTISEMENT - 130] = 1,
+	[ICMPV6_MLD2_REPORT - 130] = 1
+};
+
 static bool icmpv6_invert_tuple(struct nf_conntrack_tuple *tuple,
 				const struct nf_conntrack_tuple *orig)
 {
@@ -198,6 +209,17 @@ icmpv6_error(struct net *net, struct sk_buff *skb, unsigned int dataoff,
 		return -NF_ACCEPT;
 	}
 
+	/* autoconf message handling */
+	if (nf_ct_icmpv6_autoconf) {
+		int type = icmp6h->icmp6_type - 130;
+		if (type >= 0 && type < sizeof(noct_valid_new)
+		    && noct_valid_new[type]) {
+			skb->nfct = &nf_conntrack_untracked.ct_general;
+			skb->nfctinfo = IP_CT_NEW;
+			nf_conntrack_get(skb->nfct);
+			return -NF_ACCEPT;
+		}
+	}
 	/* is not error message ? */
 	if (icmp6h->icmp6_type >= 128)
 		return NF_ACCEPT;
Signature · 1 line
1.5.6.3
#15 lore raw
In reply to Eric Leblond

Hi, Eric,

How about just using NOTRACK target ?

-- Yasuyuki Kozakai

From: Eric Leblond <[email protected]>
Date: Thu, 22 Jan 2009 00:41:27 +0100

Quoted 37 lines

Hi,

Quoted 7 lines · Marek Szuba
Quoted 2 lines · On Wed, 05 Nov 2008 13:44:05 +0900 (JST) Yasuyuki KOZAKAI…

In short: nf_conntrack_proto_icmpv6.c does not help for protocols using their messages. conntrack helper is better.

So what you are suggesting is, someone needs to write such a helper module. Correct?

I'm reopening this thread because Victor Stinner (in CC) has opened a similar bug in bugzilla:
http://bugzilla.netfilter.org/show_bug.cgi?id=567
Pablo has then pointed out this discussion.

I don't think that we have to handle these part of ICMPv6 protocol with a connection tracking helper. For example, here's the trace of the exchange which are needed to obtain a "public" IPv6 address on my setup:

15:14:42.377744 IP6 fe80::a00:27ff:feb3:e26c > ff02::2: ICMP6, router solicitation, length 16
15:14:42.405725 IP6 fe80::207:cbff:fe90:f8d1 > ff02::1: ICMP6, router advertisement, length 104 15:14:43.401395 IP6 :: > ff02::1:ffb3:e26c: ICMP6, neighbor solicitation, who has 2a01:e35:1394:5bd0:a00:27ff:feb3:e26c, length 24 15:14:46.628300 IP6 fe80::a00:27ff:feb3:e26c > ff02::16: HBH ICMP6, multicast listener report v2, 1 group record(s), length 28

If we only analyse the first two, we see we can't easily invert the tuple of the connection: we don't know which address will answer and the destination address of the packet are changing. But as pointed by Yasuyuki the main point is not here, we need to accept the router advertisement to be able to detect changes in the routing. In fact, theses protocols are stateless and should be considered as such.

IMHO, the main issue here is to tag the packets as INVALID. They are valid even we can't track them. I thus propose a patchset which adds the capability to avoid connection tracking the packets of these protocols. A sysctl flag can be set to activate this feature.

Quoted 7 lines

With this patchset, the concerned packet don't get blocked by the INVALID rule and are not seen by the conntrack. They can be cleanly filtered in the ruleset.

Patchset statistics:

 net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c |   35 +++++++++++++++++++++++-
 1 files changed, 34 insertions(+), 1 deletions(-)

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#16 lore raw

Hi,

Quoted 3 lines · Yasuyuki KOZAKAI

Hi, Eric,

How about just using NOTRACK target ?

This is a possible solution but you will then have to be a Netfilter Jedi to build a correct IPv6 filtering ruleset. I think even Padawan have no clue about the existence of the NOTRACK target.

Seriously speaking, the NOTRACK target is tagged "NETFILTER_ADVANCED" and IPv6 is becoming more and more frequent. I don't think we should use such a complicated solution for simply obtaining an IPv6 address. We will loose quit a bunch of users on this.

BR,
--
Eric

Quoted 54 lines

-- Yasuyuki Kozakai

From: Eric Leblond <[email protected]>
Date: Thu, 22 Jan 2009 00:41:27 +0100

Quoted 37 lines

Hi,

Quoted 7 lines · Marek Szuba
Quoted 2 lines · On Wed, 05 Nov 2008 13:44:05 +0900 (JST) Yasuyuki KOZAKAI…

In short: nf_conntrack_proto_icmpv6.c does not help for protocols using their messages. conntrack helper is better.

So what you are suggesting is, someone needs to write such a helper module. Correct?

I'm reopening this thread because Victor Stinner (in CC) has opened a similar bug in bugzilla:
http://bugzilla.netfilter.org/show_bug.cgi?id=567
Pablo has then pointed out this discussion.

I don't think that we have to handle these part of ICMPv6 protocol with a connection tracking helper. For example, here's the trace of the exchange which are needed to obtain a "public" IPv6 address on my setup:

15:14:42.377744 IP6 fe80::a00:27ff:feb3:e26c > ff02::2: ICMP6, router solicitation, length 16
15:14:42.405725 IP6 fe80::207:cbff:fe90:f8d1 > ff02::1: ICMP6, router advertisement, length 104 15:14:43.401395 IP6 :: > ff02::1:ffb3:e26c: ICMP6, neighbor solicitation, who has 2a01:e35:1394:5bd0:a00:27ff:feb3:e26c, length 24 15:14:46.628300 IP6 fe80::a00:27ff:feb3:e26c > ff02::16: HBH ICMP6, multicast listener report v2, 1 group record(s), length 28

If we only analyse the first two, we see we can't easily invert the tuple of the connection: we don't know which address will answer and the destination address of the packet are changing. But as pointed by Yasuyuki the main point is not here, we need to accept the router advertisement to be able to detect changes in the routing. In fact, theses protocols are stateless and should be considered as such.

IMHO, the main issue here is to tag the packets as INVALID. They are valid even we can't track them. I thus propose a patchset which adds the capability to avoid connection tracking the packets of these protocols. A sysctl flag can be set to activate this feature.

Quoted 7 lines

With this patchset, the concerned packet don't get blocked by the INVALID rule and are not seen by the conntrack. They can be cleanly filtered in the ruleset.

Patchset statistics:

 net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c |   35 +++++++++++++++++++++++-
 1 files changed, 34 insertions(+), 1 deletions(-)

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 3 lines
Éric Leblond <[email protected]>
INL, http://www.inl.fr/
NuFW, http://www.nufw.org
#17 lore raw
Quoted 10 lines · Eric Leblond
Quoted 1 line

How about just using NOTRACK target ?

This is a possible solution but you will then have to be a Netfilter Jedi to build a correct IPv6 filtering ruleset. I think even Padawan have no clue about the existence of the NOTRACK target.

Seriously speaking, the NOTRACK target is tagged "NETFILTER_ADVANCED" and IPv6 is becoming more and more frequent. I don't think we should use such a complicated solution for simply obtaining an IPv6 address. We will loose quit a bunch of users on this.

RFC4890, Recommendations for Filtering ICMPv6 Messages in Firewalls, deals with ICMPv6 filtering on firewalls in details and even contains a sample ip6tables script.

Wouldn't it make sense to add simply the RFC to the iptables source tree, and a sentence to the ip6tables manpage saying:

"Please read RFC 4890 and the sample script in it on how to filter ICMPv6 properly in an IPv6 environment."

Best regards,
Jozsef
-
E-mail : [email protected], [email protected] PGP key : http://www.kfki.hu/~kadlec/pgp_public_key.txt
Address : KFKI Research Institute for Particle and Nuclear Physics

          H-1525 Budapest 114, POB. 49, Hungary
#18 lore raw
Quoted 17 lines · Jozsef Kadlecsik
Quoted 10 lines · Eric Leblond
Quoted 1 line

How about just using NOTRACK target ?

This is a possible solution but you will then have to be a Netfilter Jedi to build a correct IPv6 filtering ruleset. I think even Padawan have no clue about the existence of the NOTRACK target.

Seriously speaking, the NOTRACK target is tagged "NETFILTER_ADVANCED" and IPv6 is becoming more and more frequent. I don't think we should use such a complicated solution for simply obtaining an IPv6 address. We will loose quit a bunch of users on this.

RFC4890, Recommendations for Filtering ICMPv6 Messages in Firewalls, deals with ICMPv6 filtering on firewalls in details and even contains a sample ip6tables script.

Quoted 5 lines

Wouldn't it make sense to add simply the RFC to the iptables source tree, and a sentence to the ip6tables manpage saying:

"Please read RFC 4890 and the sample script in it on how to filter ICMPv6 properly in an IPv6 environment."

Looking through the sample script again, it is incomplete as it does not handle the ICMPv6 traffic targeted to/sent from the firewall itself. But it'd be not hard to add the missing rules.

Best regards,
Jozsef
-
E-mail : [email protected], [email protected] PGP key : http://www.kfki.hu/~kadlec/pgp_public_key.txt
Address : KFKI Research Institute for Particle and Nuclear Physics

          H-1525 Budapest 114, POB. 49, Hungary
#19 lore raw

From: Jozsef Kadlecsik <[email protected]>
Date: Fri, 23 Jan 2009 10:50:59 +0100 (CET)

Quoted 22 lines · Jozsef Kadlecsik
Quoted 21 lines · Eric Leblond
Quoted 11 lines
Quoted 2 lines

How about just using NOTRACK target ?

This is a possible solution but you will then have to be a Netfilter Jedi to build a correct IPv6 filtering ruleset. I think even Padawan have no clue about the existence of the NOTRACK target.

Seriously speaking, the NOTRACK target is tagged "NETFILTER_ADVANCED" and IPv6 is becoming more and more frequent. I don't think we should use such a complicated solution for simply obtaining an IPv6 address. We will loose quit a bunch of users on this.

RFC4890, Recommendations for Filtering ICMPv6 Messages in Firewalls, deals with ICMPv6 filtering on firewalls in details and even contains a sample ip6tables script.

Wouldn't it make sense to add simply the RFC to the iptables source tree, and a sentence to the ip6tables manpage saying:

Quoted 6 lines
Quoted 2 lines

"Please read RFC 4890 and the sample script in it on how to filter ICMPv6 properly in an IPv6 environment."

Looking through the sample script again, it is incomplete as it does not handle the ICMPv6 traffic targeted to/sent from the firewall itself. But it'd be not hard to add the missing rules.

I looks not to show the recommended rules but just the usage of ip6tables.

-- Yasuyuki Kozakai

#20 lore raw
In reply to Eric Leblond

Hi,

From: Eric Leblond <[email protected]>
Date: Fri, 23 Jan 2009 10:02:27 +0100

Quoted 7 lines

Hi,

Quoted 3 lines · Yasuyuki KOZAKAI

Hi, Eric,

How about just using NOTRACK target ?

Quoted 8 lines

This is a possible solution but you will then have to be a Netfilter Jedi to build a correct IPv6 filtering ruleset. I think even Padawan have no clue about the existence of the NOTRACK target.

Seriously speaking, the NOTRACK target is tagged "NETFILTER_ADVANCED" and IPv6 is becoming more and more frequent. I don't think we should use such a complicated solution for simply obtaining an IPv6 address. We will loose quit a bunch of users on this.

It's reasonable. One solution is to change it and to make distributer add NOTRACK rule to their configuration, but changing nf_conntrack would be faster ;)

From: Eric Leblond <[email protected]>
Date: Thu, 22 Jan 2009 00:43:50 +0100

Quoted 36 lines

This patches adds a sysctl flag to decide wheither or not detect icmpv6 autoconfiguration packet as INVALID.

---
 net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c +8 -0
index 0dbac72..4aa80ba 100644
@@ -27,6 +27,7 @@
 #include <net/netfilter/nf_log.h>
 
 static unsigned long nf_ct_icmpv6_timeout __read_mostly = 30*HZ;
+static unsigned long nf_ct_icmpv6_autoconf __read_mostly = 0;
 
 static bool icmpv6_pkt_to_tuple(const struct sk_buff *skb,
 				unsigned int dataoff,
@@ -259,6 +260,13 @@ static struct ctl_table icmpv6_sysctl_table[] = {
 		.proc_handler	= proc_dointvec_jiffies,
 	},
 	{
+		.procname	= "nf_conntrack_icmpv6_autoconf",
+		.data		= &nf_ct_icmpv6_autoconf,
+		.maxlen		= sizeof(unsigned int),
+		.mode		= 0644,
+		.proc_handler	= proc_dointvec_jiffies,
+	},
+	{
 		.ctl_name	= 0
 	}
 };
Signature · 1 line
1.5.6.3

I think this is not needed. User would not be aware of this configuration.

From: Eric Leblond <[email protected]>
Date: Thu, 22 Jan 2009 00:43:51 +0100

Quoted 6 lines

This patch removes connection tracking handling for ICMPv6 messages related to autoconfiguration. They can be tracked because they are massively using multicast (on pre-defined address). But they are not invalid.

<snip>

net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c

Quoted 10 lines
net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c +10 -0
+static const u_int8_t noct_valid_new[] = {
+	[ICMPV6_MGM_QUERY - 130] = 1,
+	[ICMPV6_MGM_REPORT -130] = 1,
+	[ICMPV6_MGM_REDUCTION - 130] = 1,
+	[NDISC_ROUTER_SOLICITATION - 130] = 1,
+	[NDISC_ROUTER_ADVERTISEMENT - 130] = 1,
+	[NDISC_NEIGHBOUR_SOLICITATION - 130] = 1,
+	[NDISC_NEIGHBOUR_ADVERTISEMENT - 130] = 1,
+	[ICMPV6_MLD2_REPORT - 130] = 1
+};

MLD is not part of auto configuration. But I agree to handle it.

net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c

Quoted 9 lines

static bool icmpv6_invert_tuple(struct nf_conntrack_tuple *tuple,

net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c +3 -1
 				const struct nf_conntrack_tuple *orig)
 {
 	int type = orig->dst.u.icmp.type - 128;
-	if (type < 0 || type >= sizeof(invmap) || !invmap[type])
+
+	if (type < 0 || type >= sizeof(invmap) || !invmap[type]) {
 		return false;
+	}

Really is this change necessary ?

Quoted 5 lines
net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c +1 -0
@@ -198,6 +212,17 @@ icmpv6_error(struct net *net, struct sk_buff *skb, unsigned int dataoff,
 		return -NF_ACCEPT;
 	}
 
+	/* autoconf message handling */

net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c icmpv6_error(struct net *net, struct sk_buff *skb, unsigned int dataoff, · line 225

Quoted 10 lines
net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c +10 -0
+	if (nf_ct_icmpv6_autoconf) {
+		int type = icmp6h->icmp6_type - 130;
+		if (type >= 0 && type < sizeof(noct_valid_new)
+		    && noct_valid_new[type]) {
+			skb->nfct = &nf_conntrack_untracked.ct_general;
+			skb->nfctinfo = IP_CT_NEW;
+			nf_conntrack_get(skb->nfct);
+			return -NF_ACCEPT;
+		}
+	}

I prefer 'NEW' rather than 'UNTRACKED' as other protocols which validation is unclear. So another solution is to let the connection tracking subsystem to create a new conntrack and to make nf_contrack_proto_icmpv6 assign 0 as timeout. How do you think ?

-- Yasuyuki Kozakai
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): [email protected]

#22 lore raw
Quoted 59 lines · Yasuyuki KOZAKAI

Hi,

From: Eric Leblond <[email protected]>
Date: Fri, 23 Jan 2009 10:02:27 +0100

Quoted 7 lines

Hi,

Quoted 3 lines · Yasuyuki KOZAKAI

Hi, Eric,

How about just using NOTRACK target ?

Quoted 8 lines

This is a possible solution but you will then have to be a Netfilter Jedi to build a correct IPv6 filtering ruleset. I think even Padawan have no clue about the existence of the NOTRACK target.

Seriously speaking, the NOTRACK target is tagged "NETFILTER_ADVANCED" and IPv6 is becoming more and more frequent. I don't think we should use such a complicated solution for simply obtaining an IPv6 address. We will loose quit a bunch of users on this.

It's reasonable. One solution is to change it and to make distributer add NOTRACK rule to their configuration, but changing nf_conntrack would be faster ;)

From: Eric Leblond <[email protected]>
Date: Thu, 22 Jan 2009 00:43:50 +0100

Quoted 30 lines

This patches adds a sysctl flag to decide wheither or not detect icmpv6 autoconfiguration packet as INVALID.

---
 net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c +7 -0
index 0dbac72..4aa80ba 100644
@@ -27,6 +27,7 @@
 #include <net/netfilter/nf_log.h>
 
 static unsigned long nf_ct_icmpv6_timeout __read_mostly = 30*HZ;
+static unsigned long nf_ct_icmpv6_autoconf __read_mostly = 0;
 
 static bool icmpv6_pkt_to_tuple(const struct sk_buff *skb,
 				unsigned int dataoff,
@@ -259,6 +260,13 @@ static struct ctl_table icmpv6_sysctl_table[] = {
 		.proc_handler	= proc_dointvec_jiffies,
 	},
 	{
+		.procname	= "nf_conntrack_icmpv6_autoconf",
+		.data		= &nf_ct_icmpv6_autoconf,
+		.maxlen		= sizeof(unsigned int),
+		.mode		= 0644,
+		.proc_handler	= proc_dointvec_jiffies,
+	},
Quoted 8 lines
Quoted 6 lines
net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c +1 -0
+	{
 		.ctl_name	= 0
 	}
 };
Signature · 1 line
1.5.6.3

I think this is not needed. User would not be aware of this configuration.

Ok, I'm really fine with it.

Quoted 12 lines

From: Eric Leblond <[email protected]>
Date: Thu, 22 Jan 2009 00:43:51 +0100

Quoted 6 lines

This patch removes connection tracking handling for ICMPv6 messages related to autoconfiguration. They can be tracked because they are massively using multicast (on pre-defined address). But they are not invalid.

<snip>

Quoted 12 lines

net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c

Quoted 10 lines
net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c +10 -0
+static const u_int8_t noct_valid_new[] = {
+	[ICMPV6_MGM_QUERY - 130] = 1,
+	[ICMPV6_MGM_REPORT -130] = 1,
+	[ICMPV6_MGM_REDUCTION - 130] = 1,
+	[NDISC_ROUTER_SOLICITATION - 130] = 1,
+	[NDISC_ROUTER_ADVERTISEMENT - 130] = 1,
+	[NDISC_NEIGHBOUR_SOLICITATION - 130] = 1,
+	[NDISC_NEIGHBOUR_ADVERTISEMENT - 130] = 1,
+	[ICMPV6_MLD2_REPORT - 130] = 1
+};

MLD is not part of auto configuration. But I agree to handle it.

Ok.

Quoted 13 lines

net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c

Quoted 11 lines

static bool icmpv6_invert_tuple(struct nf_conntrack_tuple *tuple,

net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c +3 -1
 				const struct nf_conntrack_tuple *orig)
 {
 	int type = orig->dst.u.icmp.type - 128;
-	if (type < 0 || type >= sizeof(invmap) || !invmap[type])
+
+	if (type < 0 || type >= sizeof(invmap) || !invmap[type]) {
 		return false;
+	}

Really is this change necessary ?

I've resend the patch without this change. It was forgotten during a merge of previous work. Sorry for that.

Quoted 4 lines
Quoted 4 lines
net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c +0 -0
@@ -198,6 +212,17 @@ icmpv6_error(struct net *net, struct sk_buff *skb, unsigned int dataoff,
 		return -NF_ACCEPT;
 	}
 
Quoted 16 lines

net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c icmpv6_error(struct net *net, struct sk_buff *skb, unsigned int dataoff, · line 225

Quoted 11 lines
net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c +11 -0
+	/* autoconf message handling */
+	if (nf_ct_icmpv6_autoconf) {
+		int type = icmp6h->icmp6_type - 130;
+		if (type >= 0 && type < sizeof(noct_valid_new)
+		    && noct_valid_new[type]) {
+			skb->nfct = &nf_conntrack_untracked.ct_general;
+			skb->nfctinfo = IP_CT_NEW;
+			nf_conntrack_get(skb->nfct);
+			return -NF_ACCEPT;
+		}
+	}

I prefer 'NEW' rather than 'UNTRACKED' as other protocols which validation is unclear. So another solution is to let the connection tracking subsystem to create a new conntrack and to make nf_contrack_proto_icmpv6 assign 0 as timeout. How do you think ?

If we do that, we can have nfnetlink messages (NEW, DESTROY) send to userspace. Personnaly, I don't think they are necessary. But there is an other issue: as we can't invert the tuple, the information provided to userspace will be false.

Once we agree on this last point, I will send a reworked patchset (with at least the removal of sysctl stuff).

BR,

Signature · 3 lines
Éric Leblond <[email protected]>
INL, http://www.inl.fr/
NuFW, http://www.nufw.org
#23 lore raw

Hi,

From: Eric Leblond <[email protected]>
Date: Fri, 23 Jan 2009 11:51:30 +0100

Quoted 12 lines
Quoted 11 lines

Review

Quoted 9 lines

static bool icmpv6_invert_tuple(struct nf_conntrack_tuple *tuple,

(quoted diff) +3 -1
 				const struct nf_conntrack_tuple *orig)
 {
 	int type = orig->dst.u.icmp.type - 128;
-	if (type < 0 || type >= sizeof(invmap) || !invmap[type])
+
+	if (type < 0 || type >= sizeof(invmap) || !invmap[type]) {
 		return false;
+	}

Really is this change necessary ?

Quoted 2 lines

I've resend the patch without this change. It was forgotten during a merge of previous work. Sorry for that.

Ah, sorry & thank you for noticing.

Quoted 21 lines
Quoted 4 lines
Quoted 4 lines
(quoted diff) +0 -0
@@ -198,6 +212,17 @@ icmpv6_error(struct net *net, struct sk_buff *skb, unsigned int dataoff,
 		return -NF_ACCEPT;
 	}
 
Quoted 16 lines

Review icmpv6_error(struct net *net, struct sk_buff *skb, unsigned int dataoff, · line 225

Quoted 11 lines
(quoted diff) +11 -0
+	/* autoconf message handling */
+	if (nf_ct_icmpv6_autoconf) {
+		int type = icmp6h->icmp6_type - 130;
+		if (type >= 0 && type < sizeof(noct_valid_new)
+		    && noct_valid_new[type]) {
+			skb->nfct = &nf_conntrack_untracked.ct_general;
+			skb->nfctinfo = IP_CT_NEW;
+			nf_conntrack_get(skb->nfct);
+			return -NF_ACCEPT;
+		}
+	}

I prefer 'NEW' rather than 'UNTRACKED' as other protocols which validation is unclear. So another solution is to let the connection tracking subsystem to create a new conntrack and to make nf_contrack_proto_icmpv6 assign 0 as timeout. How do you think ?

Quoted 7 lines

If we do that, we can have nfnetlink messages (NEW, DESTROY) send to userspace. Personnaly, I don't think they are necessary. But there is an other issue: as we can't invert the tuple, the information provided to userspace will be false.

Once we agree on this last point, I will send a reworked patchset (with at least the removal of sysctl stuff).

Thank you. I understand why ICMPv6 packets are special here and I agree to assign UNTRACKED to them. Indeed non-invertible tuple might bring issues.

-- Yasuyuki Kozakai

#24 lore raw

PATCH 1/1 netfilter: don't track ICMPv6 negotiation message.

This patch removes connection tracking handling for ICMPv6 messages related to autoconfiguration. They can be tracked because they are massively using multicast (on pre-defined address). But they are not invalid.

---
 net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)
net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c +21 -0
index 6f859c1..94ace19 100644
@@ -53,6 +53,17 @@ static const u_int8_t invmap[] = {
 	[ICMPV6_NI_REPLY - 128]		= ICMPV6_NI_QUERY +1
 };
 
+static const u_int8_t noct_valid_new[] = {
+	[ICMPV6_MGM_QUERY - 130] = 1,
+	[ICMPV6_MGM_REPORT -130] = 1,
+	[ICMPV6_MGM_REDUCTION - 130] = 1,
+	[NDISC_ROUTER_SOLICITATION - 130] = 1,
+	[NDISC_ROUTER_ADVERTISEMENT - 130] = 1,
+	[NDISC_NEIGHBOUR_SOLICITATION - 130] = 1,
+	[NDISC_NEIGHBOUR_ADVERTISEMENT - 130] = 1,
+	[ICMPV6_MLD2_REPORT - 130] = 1
+};
+
 static bool icmpv6_invert_tuple(struct nf_conntrack_tuple *tuple,
 				const struct nf_conntrack_tuple *orig)
 {
@@ -182,6 +193,7 @@ icmpv6_error(struct net *net, struct sk_buff *skb, unsigned int dataoff,
 {
 	const struct icmp6hdr *icmp6h;
 	struct icmp6hdr _ih;
+	int type;
 
 	icmp6h = skb_header_pointer(skb, dataoff, sizeof(_ih), &_ih);
 	if (icmp6h == NULL) {
@@ -199,6 +211,15 @@ icmpv6_error(struct net *net, struct sk_buff *skb, unsigned int dataoff,
 		return -NF_ACCEPT;
 	}
 
+	type = icmp6h->icmp6_type - 130;
+	if (type >= 0 && type < sizeof(noct_valid_new)
+	    && noct_valid_new[type]) {
+		skb->nfct = &nf_conntrack_untracked.ct_general;
+		skb->nfctinfo = IP_CT_NEW;
+		nf_conntrack_get(skb->nfct);
+		return NF_ACCEPT;
+	}
+
 	/* is not error message ? */
 	if (icmp6h->icmp6_type >= 128)
 		return NF_ACCEPT;
Signature · 1 line
1.5.6.3
#25 lore raw

Re: [PATCH] netfilter: don't track ICMPv6 negotiation message.

Can you s/autoconfiguration/Stateless Address Autoconfiguration, MLD, and MLDv2/ in commit log ?

Others are fine to me.

-- Yasuyuki Kozakai

From: Eric Leblond <[email protected]>
Date: Sat, 24 Jan 2009 11:32:58 +0100

Quoted 59 lines

This patch removes connection tracking handling for ICMPv6 messages related to autoconfiguration. They can be tracked because they are massively using multicast (on pre-defined address). But they are not invalid.

---
 net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)
net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c +21 -0
index 6f859c1..94ace19 100644
@@ -53,6 +53,17 @@ static const u_int8_t invmap[] = {
 	[ICMPV6_NI_REPLY - 128]		= ICMPV6_NI_QUERY +1
 };
 
+static const u_int8_t noct_valid_new[] = {
+	[ICMPV6_MGM_QUERY - 130] = 1,
+	[ICMPV6_MGM_REPORT -130] = 1,
+	[ICMPV6_MGM_REDUCTION - 130] = 1,
+	[NDISC_ROUTER_SOLICITATION - 130] = 1,
+	[NDISC_ROUTER_ADVERTISEMENT - 130] = 1,
+	[NDISC_NEIGHBOUR_SOLICITATION - 130] = 1,
+	[NDISC_NEIGHBOUR_ADVERTISEMENT - 130] = 1,
+	[ICMPV6_MLD2_REPORT - 130] = 1
+};
+
 static bool icmpv6_invert_tuple(struct nf_conntrack_tuple *tuple,
 				const struct nf_conntrack_tuple *orig)
 {
@@ -182,6 +193,7 @@ icmpv6_error(struct net *net, struct sk_buff *skb, unsigned int dataoff,
 {
 	const struct icmp6hdr *icmp6h;
 	struct icmp6hdr _ih;
+	int type;
 
 	icmp6h = skb_header_pointer(skb, dataoff, sizeof(_ih), &_ih);
 	if (icmp6h == NULL) {
@@ -199,6 +211,15 @@ icmpv6_error(struct net *net, struct sk_buff *skb, unsigned int dataoff,
 		return -NF_ACCEPT;
 	}
 
+	type = icmp6h->icmp6_type - 130;
+	if (type >= 0 && type < sizeof(noct_valid_new)
+	    && noct_valid_new[type]) {
+		skb->nfct = &nf_conntrack_untracked.ct_general;
+		skb->nfctinfo = IP_CT_NEW;
+		nf_conntrack_get(skb->nfct);
+		return NF_ACCEPT;
+	}
+
 	/* is not error message ? */
 	if (icmp6h->icmp6_type >= 128)
 		return NF_ACCEPT;
Signature · 1 line
1.5.6.3

A message that is not in the archive (sent off-list or not yet received): [email protected]

#27 lore raw
Quoted 12 lines · Yasuyuki KOZAKAI

From: Eric Leblond <[email protected]>
Date: Fri, 23 Jan 2009 11:51:30 +0100

Quoted 9 lines
Quoted 4 lines

I prefer 'NEW' rather than 'UNTRACKED' as other protocols which validation is unclear. So another solution is to let the connection tracking subsystem to create a new conntrack and to make nf_contrack_proto_icmpv6 assign 0 as timeout. How do you think ?

If we do that, we can have nfnetlink messages (NEW, DESTROY) send to userspace. Personnaly, I don't think they are necessary. But there is an other issue: as we can't invert the tuple, the information provided to userspace will be false.

Quoted 6 lines
Quoted 2 lines

Once we agree on this last point, I will send a reworked patchset (with at least the removal of sysctl stuff).

Thank you. I understand why ICMPv6 packets are special here and I agree to assign UNTRACKED to them. Indeed non-invertible tuple might bring issues.

How about adding a flag to indicate that only one direction of the tuple exists? It makes sense to support this for other kinds of simplex flows as well in my opinion and it somewhat goes in the same direction as the patch I talked about during the workshop to have only a single tuple within the conntrack and have reply tuples or potentially other tuples that relate to a connection within the ct_extend area. And using NEW and having netlink events seems more consistent to me.

#28 lore raw

From: Patrick McHardy <[email protected]>
Date: Mon, 26 Jan 2009 14:11:37 +0100

Quoted 20 lines
Quoted 12 lines · Yasuyuki KOZAKAI

From: Eric Leblond <[email protected]>
Date: Fri, 23 Jan 2009 11:51:30 +0100

Quoted 9 lines
Quoted 4 lines

I prefer 'NEW' rather than 'UNTRACKED' as other protocols which validation is unclear. So another solution is to let the connection tracking subsystem to create a new conntrack and to make nf_contrack_proto_icmpv6 assign 0 as timeout. How do you think ?

If we do that, we can have nfnetlink messages (NEW, DESTROY) send to userspace. Personnaly, I don't think they are necessary. But there is an other issue: as we can't invert the tuple, the information provided to userspace will be false.

Quoted 6 lines
Quoted 2 lines

Once we agree on this last point, I will send a reworked patchset (with at least the removal of sysctl stuff).

Thank you. I understand why ICMPv6 packets are special here and I agree to assign UNTRACKED to them. Indeed non-invertible tuple might bring issues.

Quoted 8 lines

How about adding a flag to indicate that only one direction of the tuple exists? It makes sense to support this for other kinds of simplex flows as well in my opinion and it somewhat goes in the same direction as the patch I talked about during the workshop to have only a single tuple within the conntrack and have reply tuples or potentially other tuples that relate to a connection within the ct_extend area. And using NEW and having netlink events seems more consistent to me.

It sounds good for long term solution. For now Eric's patch is enough, I think.

And sorry, I don't remember your patch in detail since maybe nftables talk was impressive to me ;) but it sounds that it will make easier to implement a module to track protocols using broadcast.

-- Yasuyuki Kozakai

A message that is not in the archive (sent off-list or not yet received): [email protected]

#30 lore raw
Quoted 15 lines · Yasuyuki KOZAKAI

From: Patrick McHardy <[email protected]>
Date: Mon, 26 Jan 2009 14:11:37 +0100

Quoted 11 lines
Quoted 3 lines

Thank you. I understand why ICMPv6 packets are special here and I agree to assign UNTRACKED to them. Indeed non-invertible tuple might bring issues.

How about adding a flag to indicate that only one direction of the tuple exists? It makes sense to support this for other kinds of simplex flows as well in my opinion and it somewhat goes in the same direction as the patch I talked about during the workshop to have only a single tuple within the conntrack and have reply tuples or potentially other tuples that relate to a connection within the ct_extend area. And using NEW and having netlink events seems more consistent to me.

Quoted 2 lines

It sounds good for long term solution. For now Eric's patch is enough, I think.

OK, thanks.

Quoted 3 lines

And sorry, I don't remember your patch in detail since maybe nftables talk was impressive to me ;) but it sounds that it will make easier to implement a module to track protocols using broadcast.

:) Yes, that was one of the ideas. The other one was that f.i. protocols like SIP don't actually care about the network identitities of their flows and might send traffic related to a single logical connection on multiple different flows. I'm hoping that allowing more than two tuples per conntrack will help with proper tracking.