netfilter: don't track ICMPv6 negotiation message.
Subsystems (2)
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/1 netfilter: don't track ICMPv6 negotiation message.
This patch removes connection tracking handling for ICMPv6 messages related to Stateless Address Autoconfiguration, MLD, and MLDv2. They can not be tracked because they are massively using multicast (on pre-defined address). But they are not invalid and should not be detected as such.
--- 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
@@ -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.6.1
Patrick McHardy
AppliedQuoted 5 lines · Eric Leblond
This patch removes connection tracking handling for ICMPv6 messages related to Stateless Address Autoconfiguration, MLD, and MLDv2. They can not be tracked because they are massively using multicast (on pre-defined address). But they are not invalid and should not be detected as such.
Applied, thanks Eric.
net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c icmpv6_error(struct net *net, struct sk_buff *skb, unsigned int dataoff, · line 216
Quoted 3 lines
net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c +3
-0+ type = icmp6h->icmp6_type -130 ; +if (type >=0 && type <sizeof (noct_valid_new) + && noct_valid_new[type]) {
I've made a small cosmetic change here and moved the && to the first line. I'm slowly trying to get rid of the inconsistent operator placement whenever we touch some code.
Hi,
I have two questions regarding this patch.
net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c icmpv6_error(struct net *net, struct sk_buff *skb, unsigned int dataoff, · line 221
Quoted 8 lines · Eric Leblond
net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c +8
-0+ 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 ; + }
Why do you set skb->nfctinfo = IP_CT_NEW?
Because in xt_state.c, at state_mt(...) :
if it is in front of an untracked packet (using nf_ct_is_untracked(skb)) it automatically sets the statebit to UNTRACKED and so the IP_CT_NEW isn't used.
Why do you return NF_ACCEPT and not -NF_ACCEPT?
By returning a positiv value, the packet will continue it's way through the connection tracker.
I hope that I was clear.
Please correct me if I'm wrong...
Greetings,
--
Christoph Paasch
École Polytechnique de Louvain
Département d'ingénierie informatique
www.rollerbulls.be
--
--
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
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,
Quoted 5 lines · Christoph Paasch
Hi,
I have two questions regarding this patch.
On Tue January 27 2009, Eric Leblond wrote:
Quoted 13 lines
net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c icmpv6_error(struct net *net, struct sk_buff *skb, unsigned int dataoff, · line 221
Quoted 8 lines
net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c +8
-0+ 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 ; + }Why do you set
skb->nfctinfo=IP_CT_NEW?
Because inxt_state.c, atstate_mt(...):
if it is in front of an untracked packet (usingnf_ct_is_untracked(skb)) it automatically sets the statebit to UNTRACKED and so theIP_CT_NEWisn't used.
Not much to say on that point. I wanted to be homogeneous with what is done in xt_NOTRACK.c.
Quoted 3 lines
Why do you return
NF_ACCEPTand not -NF_ACCEPT?
By returning a positiv value, the packet will continue it's way through the connection tracker.
If I understand well, icmpv6_error will be called in nf_conntrack_core.c as l4proto->error :
if (l4proto->error != NULL) {
ret = l4proto->error(net, skb, dataoff, &ctinfo, pf, hooknum);
if (ret <= 0) {
NF_CT_STAT_INC_ATOMIC(net, error);
NF_CT_STAT_INC_ATOMIC(net, invalid);
return -ret;
}
}It will thus increment error counters if return is -NF_ACCEPT. As the packets we deal with are not error I don't think it is correct to return
- -NF_ACCEPT.
But I agree with the fact, that returning NF_ACCEPT leads to some useless work inside the kernel.
BR,
- --
Eric Leblond <[email protected]>
INL: http://www.inl.fr/
NuFW: http://www.nufw.org/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFJjxfknxA7CdMWjzIRAn0aAKCQCN4JpW8eae4isbeSA/77Fl0vagCfdfhJ 7n/HGloTFIT9V+mAKnG4oPs=
=65y5
-----END PGP SIGNATURE-----
--
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
Hi,
thanks for your reply.
Quoted 11 lines · Eric Leblond
Hi,
Quoted 5 lines · Christoph Paasch
Why do you set
skb->nfctinfo=IP_CT_NEW?
Because inxt_state.c, atstate_mt(...):
if it is in front of an untracked packet (usingnf_ct_is_untracked(skb))
it automatically sets the statebit to UNTRACKED and so theIP_CT_NEWisn't used.Not much to say on that point. I wanted to be homogeneous with what is done in
xt_NOTRACK.c.
OK.
But then I'm asking me, why does the UNTRACKED state isn't documented in the iptables manpage, even if this one exists for the iptables state module? As those ICMPv6 messages will be recognized as UNTRACKED by xt_state.c, and so the firewall administrator needs to allow those kind of packets.
But well, this is more an issue of the iptables manpage, ...
Quoted 17 lines
Quoted 4 lines
Why do you return
NF_ACCEPTand not -NF_ACCEPT?
By returning a positiv value, the packet will continue it's way through the connection tracker.If I understand well,
icmpv6_errorwill be called innf_conntrack_core.casl4proto->error:if (l4proto->error != NULL) { ret = l4proto->error(net, skb, dataoff, &ctinfo, pf, hooknum); if (ret <= 0) { NF_CT_STAT_INC_ATOMIC(net, error); NF_CT_STAT_INC_ATOMIC(net, invalid); return -ret; } }
Quoted 6 lines
It will thus increment error counters if return is -NF_ACCEPT. As the packets we deal with are not error I don't think it is correct to return -NF_ACCEPT.
But I agree with the fact, that returning
NF_ACCEPTleads to some useless work inside the kernel.
The packet will then go up to the call to icmpv6_new (as the connection tracker will still look for a connection matching the tuple):
if (type < 0 || type >= sizeof(valid_new) || !valid_new[type]) {
/* Can't create a new ICMPv6 `conn' with this. */
pr_debug("icmpv6: can't create new conn with type %u\n",
type + 128);
nf_ct_dump_tuple_ipv6(&ct->tuplehash[0].tuple);
return false;
}And then the invalid counter will get incremented in nf_conntrack_in(...):
ct = resolve_normal_ct(net, skb, dataoff, pf, protonum,
l3proto, l4proto, &set_reply, &ctinfo);
if (!ct) {
/* Not valid part of a connection */
NF_CT_STAT_INC_ATOMIC(net, invalid);
return NF_ACCEPT;
}So, maybe the handling of the ICMPv6 negotiation messages should get moved to icmpv6_new, with a more descriptive pr_debug message than the one who is present.
--
Christoph Paasch
www.rollerbulls.be
--
--
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