net/ipv6: icmp: fix is_ineligible() to block errors for Redirect packets
Subsystems (4)
PATCH 1/1 net/ipv6: icmp: fix is_ineligible() to block errors for Redirect packets
RFC 4443 section 2.4(e.2) mandates that an ICMPv6 error message MUST NOT be originated in response to an ICMPv6 Redirect message (type 137).
Add check for NDISC_REDIRECT (137) so that redirect packets become ineligible and error packets are not generated for Redirect messages.
--- net/ipv6/icmp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/ipv6/icmp.c +2 -1
@@ -157,7 +157,8 @@ static bool is_ineligible(const struct sk_buff *skb)*/ if (!tp && frag_off !=0 )return false; -else if (!tp || !(*tp &ICMPV6_INFOMSG_MASK )) +else if (!tp || !(*tp &ICMPV6_INFOMSG_MASK ) || + *tp ==NDISC_REDIRECT )return true; }return false;
Signature · 1 line
2.53.0
PATCH 1/1 net/ipv6: icmp: fix is_ineligible() to block errors for Redirect packets
From: Sayooj K Karun <[email protected]>
Date: Tue, 26 May 2026 15:46:22 +0530
Quoted 1 line
[PATCH] net/ipv6: icmp: fix
is_ineligible()to block errors for Redirect packets
Is this a fix or a feature? The subject prefix must contain either "net-next" (if targeting the feature tree) or "net" (if targeting the fixes tree)
Quoted 5 lines
RFC 4443 section 2.4(e.2) mandates that an ICMPv6 error message MUST NOT be originated in response to an ICMPv6 Redirect message (type 137).
Add check for
NDISC_REDIRECT(137) so that redirect packets become ineligible and error packets are not generated for Redirect messages.
...for I didn't understand from the commit message which tree this should be taken to and whether this should be considered for backporting.
I'd also like to hear about real life scenarios where this misbehaves and what gets affected by this.
IOW very poor description to be reviewable.
Quoted 11 lines
Signed-off-by Sayooj K Karun <[email protected]>--- net/ipv6/icmp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)net/ipv6/icmp.c +0
-0
net/ipv6/icmp.c static bool is_ineligible(const struct sk_buff *skb) · line 164
Quoted 9 lines
net/ipv6/icmp.c +2
-1@@ -157,7 +157,8 @@ static bool is_ineligible(const struct sk_buff *skb)*/ if (!tp && frag_off !=0 )return false; -else if (!tp || !(*tp &ICMPV6_INFOMSG_MASK )) +else if (!tp || !(*tp &ICMPV6_INFOMSG_MASK ) || + *tp ==NDISC_REDIRECT )return true; }return false;
Thanks,
Olek
PATCH v2 1/1 net/ipv6: icmp: fix is_ineligible() to block errors for Redirect packets
In reply to Sayooj K KarunDiscovered while reading RFC 4443 and cross-checking the ICMPv6 stack, which in section 2.4(e.2) mandates that an ICMPv6 error MUST NOT be originated in response to an ICMPv6 Redirect message (type 137).
is_ineligible() is called by icmpv6_send() to decide whether a received packet is eligible to trigger an ICMPv6 error. It uses ICMPV6_INFOMSG_MASK (0x80) to suppress errors for ICMPv6 error types (bit 7 clear) while passing informational types (bit 7 set). However, NDISC_REDIRECT has type 137 (0x89), which has bit 7 set, so it passes the mask check and is_ineligible() returns false and icmpv6_send() proceeds to generate an error in response to a Redirect, violating the RFC.
A triggerable scenario: a host with an ip6tables/nftables REJECT rule applied to incoming ICMPv6 traffic (e.g., dropping Redirects from an untrusted router). When the Redirect hits the REJECT rule, nf_send_unreach6() calls icmpv6_send() with the Redirect as the triggering skb. Without this fix, is_ineligible() returns false and a Destination Unreachable is erroneously transmitted in response.
Add an explicit check for NDISC_REDIRECT so that Redirect packets are treated as ineligible, suppressing ICMPv6 error generation in response to them.
---
The bug can be triggered via a netfilter REJECT rule targeting ICMPv6 Redirect packets. Consider a host with the following rule:
ip6tables -A INPUT -s <untrusted-router> -p icmpv6 --icmpv6-type redirect \
-j REJECT --reject-with icmp6-adm-prohibitedWhen a Redirect packet (type 137) arrives from that source, the packet enters ip6_input(), which invokes NF_HOOK(NF_INET_LOCAL_IN). The netfilter framework iterates the registered hook entries via nf_hook_slow(), reaches the ip6tables filter table, and evaluates the rules. The incoming Redirect matches the rule, causing reject_tg6() (net/ipv6/netfilter/ip6t_REJECT.c) to be called as the rule's target action. reject_tg6() calls nf_send_unreach6(), which in turn calls icmpv6_send() with the Redirect packet as the triggering skb.
Inside icmpv6_send(), is_ineligible() is called to decide whether to suppress the error. The function detects that the inner protocol is IPPROTO_ICMPV6 and reads the ICMPv6 type byte. NDISC_REDIRECT is type 137 (0x89). The check !(*tp & ICMPV6_INFOMSG_MASK) evaluates as !(0x89 & 0x80) = !(0x80) = false, so is_ineligible() falls through and returns false and the kernel proceeds to transmit a Destination Unreachable in response to the Redirect, violating RFC 4443 section 2.4(e.2).
Tested using network namespaces with the above ip6tables rule. Without the fix, tcpdump confirms a Destination Unreachable is transmitted in response to the Redirect. With the fix applied and verified under QEMU, no error is generated.
From the RFC:
(e) An ICMPv6 error message MUST NOT be originated as a result of receiving the following:
(e.1) An ICMPv6 error message.
(e.2) An ICMPv6 redirect message [IPv6-DISC].
...
net/ipv6/icmp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/ipv6/icmp.c +2 -1
@@ -157,7 +157,8 @@ static bool is_ineligible(const struct sk_buff *skb)*/ if (!tp && frag_off !=0 )return false; -else if (!tp || !(*tp &ICMPV6_INFOMSG_MASK )) +else if (!tp || !(*tp &ICMPV6_INFOMSG_MASK ) || + *tp ==NDISC_REDIRECT )return true; }return false;
Signature · 1 line
2.53.0
Quoted 25 lines · Sayooj K Karun
Discovered while reading RFC 4443 and cross-checking the ICMPv6 stack, which in section 2.4(e.2) mandates that an ICMPv6 error MUST NOT be originated in response to an ICMPv6 Redirect message (type 137).
is_ineligible()is called byicmpv6_send()to decide whether a received packet is eligible to trigger an ICMPv6 error. It usesICMPV6_INFOMSG_MASK(0x80) to suppress errors for ICMPv6 error types (bit 7 clear) while passing informational types (bit 7 set). However,NDISC_REDIRECThas type 137 (0x89), which has bit 7 set, so it passes the mask check andis_ineligible()returns false andicmpv6_send()proceeds to generate an error in response to a Redirect, violating the RFC.A triggerable scenario: a host with an ip6tables/nftables REJECT rule applied to incoming ICMPv6 traffic (e.g., dropping Redirects from an untrusted router). When the Redirect hits the REJECT rule,
nf_send_unreach6()callsicmpv6_send()with the Redirect as the triggering skb. Without this fix,is_ineligible()returns false and a Destination Unreachable is erroneously transmitted in response.Add an explicit check for
NDISC_REDIRECTso that Redirect packets are treated as ineligible, suppressing ICMPv6 error generation in response to them.
Quoted 8 lines
Signed-off-by Sayooj K Karun <[email protected]>---
The bug can be triggered via a netfilter REJECT rule targeting ICMPv6 Redirect packets. Consider a host with the following rule:ip6tables -A INPUT -s <untrusted-router> -p icmpv6 --icmpv6-type redirect \ -j REJECT --reject-with icmp6-adm-prohibited
You are saying that after your patch, this ip6ables will no longer send a packet, and will effectively DROP
the packet.
This might break user choice/expectations/policy.
If the user wanted a DROP, they would have instead specified "-j DROP"
Apart from the netfilter world which is free to implement its own interpretation of the RFC,
how would the kernel send a reply?
Quoted 52 lines
When a Redirect packet (type 137) arrives from that source, the packet enters
ip6_input(), which invokesNF_HOOK(NF_INET_LOCAL_IN). The netfilter framework iterates the registered hook entries vianf_hook_slow(), reaches the ip6tables filter table, and evaluates the rules. The incoming Redirect matches the rule, causingreject_tg6()(net/ipv6/netfilter/ip6t_REJECT.c) to be called as the rule's target action.reject_tg6()callsnf_send_unreach6(), which in turn callsicmpv6_send()with the Redirect packet as the triggering skb.Inside
icmpv6_send(),is_ineligible()is called to decide whether to suppress the error. The function detects that the inner protocol isIPPROTO_ICMPV6and reads the ICMPv6 type byte.NDISC_REDIRECTis type 137 (0x89). The check !(*tp &ICMPV6_INFOMSG_MASK) evaluates as !(0x89 &0x80) = !(0x80) = false, sois_ineligible()falls through and returns false and the kernel proceeds to transmit a Destination Unreachable in response to the Redirect, violating RFC 4443 section 2.4(e.2).Tested using network namespaces with the above ip6tables rule. Without the fix, tcpdump confirms a Destination Unreachable is transmitted in response to the Redirect. With the fix applied and verified under QEMU, no error is generated.
From the RFC:
(e) An ICMPv6 error message MUST NOT be originated as a result of receiving the following:(e.1) An ICMPv6 error message.
(e.2) An ICMPv6 redirect message [IPv6-DISC].
...
net/ipv6/icmp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)net/ipv6/icmp.c +2
-2@@ -157,7 +157,8 @@ static bool is_ineligible(const struct sk_buff *skb)*/ if (!tp && frag_off !=0 )return false; -else if (!tp || !(*tp &ICMPV6_INFOMSG_MASK )) +else if (!tp || !(*tp &ICMPV6_INFOMSG_MASK ) || + *tp ==NDISC_REDIRECT )return true; }return false; --2.53.0
A message that is not in the archive (sent off-list or not yet received): CAFdLOz67Sxne4yXi3hB7Nf0eX=SzE9-P1phG4OzYfrgjQvmcGw@mail.gmail.com
Quoted 7 lines · Sayooj Karun
Hi Eric,
Thank you for the review.
The concern about REJECT becoming DROP for Redirect packets is correct, and that is intentional.
RFC 4443 section 2.4(e.2) mandates unconditionally that the originator MUST NOT send an ICMPv6 error in response to a Redirect message. There is no exception for netfilter policy.
Really? Have you CC netfilter maintainers?
Quoted 112 lines
To your question "how would the kernel send a reply?" : it cannot, as per the RFC.
A user who writes -j REJECT on ICMPv6 Redirect naturally expects an error to be sent back, but the protocol leaves no room for that. RFC 4443 Section 2.4(e.2) forbids it outright. The pre-patch behavior (sending Destination Unreachable in response to Redirect) was the RFC violation.The same suppression already exists in
is_ineligible()for section 2.4(e.1): a REJECT rule targeting any ICMPv6 error type (types 0–127) already silently drops without generating an error, because !(*tp &ICMPV6_INFOMSG_MASK) returns true. This patch applies the same logic to section 2.4(e.2) (Redirect, type 137). Both are entries in the same "MUST NOT" list in RFC 4443.
If the goal is to block incoming Redirects, -j DROP is the right tool. Using -j REJECT on Redirect packets was never RFC-compliant. The error response it tried to send was never allowed by the protocol.Thanks,
SayoojQuoted 99 lines · Eric Dumazet
Quoted 25 lines · Sayooj K Karun
Discovered while reading RFC 4443 and cross-checking the ICMPv6 stack, which in section 2.4(e.2) mandates that an ICMPv6 error MUST NOT be originated in response to an ICMPv6 Redirect message (type 137).
is_ineligible()is called byicmpv6_send()to decide whether a received packet is eligible to trigger an ICMPv6 error. It usesICMPV6_INFOMSG_MASK(0x80) to suppress errors for ICMPv6 error types (bit 7 clear) while passing informational types (bit 7 set). However,NDISC_REDIRECThas type 137 (0x89), which has bit 7 set, so it passes the mask check andis_ineligible()returns false andicmpv6_send()proceeds to generate an error in response to a Redirect, violating the RFC.A triggerable scenario: a host with an ip6tables/nftables REJECT rule applied to incoming ICMPv6 traffic (e.g., dropping Redirects from an untrusted router). When the Redirect hits the REJECT rule,
nf_send_unreach6()callsicmpv6_send()with the Redirect as the triggering skb. Without this fix,is_ineligible()returns false and a Destination Unreachable is erroneously transmitted in response.Add an explicit check for
NDISC_REDIRECTso that Redirect packets are treated as ineligible, suppressing ICMPv6 error generation in response to them.Quoted 8 lines
Signed-off-by Sayooj K Karun <[email protected]>---
The bug can be triggered via a netfilter REJECT rule targeting ICMPv6 Redirect packets. Consider a host with the following rule:ip6tables -A INPUT -s <untrusted-router> -p icmpv6 --icmpv6-type redirect \ -j REJECT --reject-with icmp6-adm-prohibitedYou are saying that after your patch, this ip6ables will no longer send a packet, and will effectively DROP
the packet.
This might break user choice/expectations/policy.
If the user wanted a DROP, they would have instead specified "-j DROP"Apart from the netfilter world which is free to implement its own interpretation of the RFC,
how would the kernel send a reply?Quoted 52 lines
When a Redirect packet (type 137) arrives from that source, the packet enters
ip6_input(), which invokesNF_HOOK(NF_INET_LOCAL_IN). The netfilter framework iterates the registered hook entries vianf_hook_slow(), reaches the ip6tables filter table, and evaluates the rules. The incoming Redirect matches the rule, causingreject_tg6()(net/ipv6/netfilter/ip6t_REJECT.c) to be called as the rule's target action.reject_tg6()callsnf_send_unreach6(), which in turn callsicmpv6_send()with the Redirect packet as the triggering skb.Inside
icmpv6_send(),is_ineligible()is called to decide whether to suppress the error. The function detects that the inner protocol isIPPROTO_ICMPV6and reads the ICMPv6 type byte.NDISC_REDIRECTis type 137 (0x89). The check !(*tp &ICMPV6_INFOMSG_MASK) evaluates as !(0x89 &0x80) = !(0x80) = false, sois_ineligible()falls through and returns false and the kernel proceeds to transmit a Destination Unreachable in response to the Redirect, violating RFC 4443 section 2.4(e.2).Tested using network namespaces with the above ip6tables rule. Without the fix, tcpdump confirms a Destination Unreachable is transmitted in response to the Redirect. With the fix applied and verified under QEMU, no error is generated.
From the RFC:
(e) An ICMPv6 error message MUST NOT be originated as a result of receiving the following:(e.1) An ICMPv6 error message.
(e.2) An ICMPv6 redirect message [IPv6-DISC].
...
net/ipv6/icmp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)net/ipv6/icmp.c +2
-2@@ -157,7 +157,8 @@ static bool is_ineligible(const struct sk_buff *skb)*/ if (!tp && frag_off !=0 )return false; -else if (!tp || !(*tp &ICMPV6_INFOMSG_MASK )) +else if (!tp || !(*tp &ICMPV6_INFOMSG_MASK ) || + *tp ==NDISC_REDIRECT )return true; }return false; --2.53.0
Pablo Neira Ayuso
maintainerHi,
Quoted 10 lines · Eric Dumazet
Quoted 7 lines · Sayooj Karun
Hi Eric,
Thank you for the review.
The concern about REJECT becoming DROP for Redirect packets is correct, and that is intentional.
RFC 4443 section 2.4(e.2) mandates unconditionally that the originator MUST NOT send an ICMPv6 error in response to a Redirect message. There is no exception for netfilter policy.Really? Have you CC netfilter maintainers?
Thanks for Cc'ing.
Quoted 7 lines
Quoted 7 lines
To your question "how would the kernel send a reply?" : it cannot, as per the RFC.
A user who writes -j REJECT on ICMPv6 Redirect naturally expects an error to be sent back, but the protocol leaves no room for that. RFC 4443 Section 2.4(e.2) forbids it outright. The pre-patch behavior (sending Destination Unreachable in response to Redirect) was the RFC violation.The same suppression already exists in
is_ineligible()for section 2.4(e.1): a REJECT rule targeting any ICMPv6 error type (types 0–127) already silently drops without generating an error, because !(*tp &ICMPV6_INFOMSG_MASK) returns true. This patch applies the same logic to section 2.4(e.2) (Redirect, type 137). Both are entries in the same "MUST NOT" list in RFC 4443.
If the goal is to block incoming Redirects, -j DROP is the right tool. Using -j REJECT on Redirect packets was never RFC-compliant. The error response it tried to send was never allowed by the protocol.
Netfilter, through policy, allows to modify the box behaviour in different ways that makes it non-RFC compliant.
But there is code already code such as nf_skb_is_icmp_unreach() which does not allow to reject a icmp dest unreach with another icmp dest unreach.
Also looking at your patch, how does it fix the REJECT case? Maybe you can propose a patch for nf-next as enhancement that can be reviewed to [email protected].
Thanks.
Quoted 103 lines
Quoted 103 lines
Thanks,
SayoojQuoted 99 lines · Eric Dumazet
Quoted 25 lines · Sayooj K Karun
Discovered while reading RFC 4443 and cross-checking the ICMPv6 stack, which in section 2.4(e.2) mandates that an ICMPv6 error MUST NOT be originated in response to an ICMPv6 Redirect message (type 137).
is_ineligible()is called byicmpv6_send()to decide whether a received packet is eligible to trigger an ICMPv6 error. It usesICMPV6_INFOMSG_MASK(0x80) to suppress errors for ICMPv6 error types (bit 7 clear) while passing informational types (bit 7 set). However,NDISC_REDIRECThas type 137 (0x89), which has bit 7 set, so it passes the mask check andis_ineligible()returns false andicmpv6_send()proceeds to generate an error in response to a Redirect, violating the RFC.A triggerable scenario: a host with an ip6tables/nftables REJECT rule applied to incoming ICMPv6 traffic (e.g., dropping Redirects from an untrusted router). When the Redirect hits the REJECT rule,
nf_send_unreach6()callsicmpv6_send()with the Redirect as the triggering skb. Without this fix,is_ineligible()returns false and a Destination Unreachable is erroneously transmitted in response.Add an explicit check for
NDISC_REDIRECTso that Redirect packets are treated as ineligible, suppressing ICMPv6 error generation in response to them.Quoted 8 lines
Signed-off-by Sayooj K Karun <[email protected]>---
The bug can be triggered via a netfilter REJECT rule targeting ICMPv6 Redirect packets. Consider a host with the following rule:ip6tables -A INPUT -s <untrusted-router> -p icmpv6 --icmpv6-type redirect \ -j REJECT --reject-with icmp6-adm-prohibitedYou are saying that after your patch, this ip6ables will no longer send a packet, and will effectively DROP
the packet.
This might break user choice/expectations/policy.
If the user wanted a DROP, they would have instead specified "-j DROP"Apart from the netfilter world which is free to implement its own interpretation of the RFC,
how would the kernel send a reply?Quoted 52 lines
When a Redirect packet (type 137) arrives from that source, the packet enters
ip6_input(), which invokesNF_HOOK(NF_INET_LOCAL_IN). The netfilter framework iterates the registered hook entries vianf_hook_slow(), reaches the ip6tables filter table, and evaluates the rules. The incoming Redirect matches the rule, causingreject_tg6()(net/ipv6/netfilter/ip6t_REJECT.c) to be called as the rule's target action.reject_tg6()callsnf_send_unreach6(), which in turn callsicmpv6_send()with the Redirect packet as the triggering skb.Inside
icmpv6_send(),is_ineligible()is called to decide whether to suppress the error. The function detects that the inner protocol isIPPROTO_ICMPV6and reads the ICMPv6 type byte.NDISC_REDIRECTis type 137 (0x89). The check !(*tp &ICMPV6_INFOMSG_MASK) evaluates as !(0x89 &0x80) = !(0x80) = false, sois_ineligible()falls through and returns false and the kernel proceeds to transmit a Destination Unreachable in response to the Redirect, violating RFC 4443 section 2.4(e.2).Tested using network namespaces with the above ip6tables rule. Without the fix, tcpdump confirms a Destination Unreachable is transmitted in response to the Redirect. With the fix applied and verified under QEMU, no error is generated.
From the RFC:
(e) An ICMPv6 error message MUST NOT be originated as a result of receiving the following:(e.1) An ICMPv6 error message.
(e.2) An ICMPv6 redirect message [IPv6-DISC].
...
net/ipv6/icmp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)net/ipv6/icmp.c +2
-2@@ -157,7 +157,8 @@ static bool is_ineligible(const struct sk_buff *skb)*/ if (!tp && frag_off !=0 )return false; -else if (!tp || !(*tp &ICMPV6_INFOMSG_MASK )) +else if (!tp || !(*tp &ICMPV6_INFOMSG_MASK ) || + *tp ==NDISC_REDIRECT )return true; }return false; --2.53.0
You are right that netfilter can be configured to make devices behave in non-RFC-compliant ways, so I will drop the "netfilter policy must obey the RFC" framing from my earlier reply.
The point I should have made is that is_ineligible() is not a netfilter function. It is the generic gate that icmpv6_send() uses to decide whether the kernel, as an ICMPv6 originator, may emit an error for a given trigger packet, and it is shared by all icmpv6_send() callers. It already enforces RFC 4443 section 2.4(e.1) at exactly this spot, via !(*tp & ICMPV6_INFOMSG_MASK), that is "do not originate an error in response to an ICMPv6 error". My patch adds (e.2) (Redirect) right next to it, the second rule from the same MUST NOT list. So this is not about overriding netfilter policy; it is completing the e.1/e.2 pair at the single point where the kernel decides ICMPv6 error eligibility.
On how it fixes the REJECT case: the two IPv6 reject paths differ in who actually frames the ICMPv6 error. The bridge/netdev path, nf_reject_skb_v6_unreach(), builds the packet by hand: it allocates the skb, writes the IPv6 and ICMPv6 headers, copies in the original packet and computes the checksum. Because it does all that itself, it has to carry its own guard, nf_skb_is_icmp6_unreach(), the IPv6 analogue of the nf_skb_is_icmp_unreach() you mention.
The L3 path, ip6t_REJECT / nft_reject -> nf_send_unreach6(), never frames a packet of its own. It just calls icmpv6_send() and lets the core ICMPv6 stack build and send the error. is_ineligible() is the gate that core builder consults first, before it allocates or assembles anything, so that is exactly where the e.1 suppression already lives for this path. There is no netfilter-local guard here, and there does not need to be.
So the scenario in my commit message is the L3 path:
ip6t_REJECT / nft_reject
> nf_send_unreach6()
> icmpv6_send() / icmp6_send()
> is_ineligible() // now returns true for NDISC_REDIRECT
> goto out, no packet is ever built or transmitted
The patch fixes the REJECT case because the L3 reject hands packet construction to icmp6_send(), and is_ineligible() runs at the top of that builder, before any error skb exists. It is the same spot that already drops e.1 today, so adding e.2 there completes the pair rather than introducing a new override.
I also agree there is a gap to close on the netfilter side. The bridge/netdev path never reaches is_ineligible(), and its nf_skb_is_icmp6_unreach() guard currently checks only ICMPV6_DEST_UNREACH, not Redirect, so it is not covered by this patch. I will send a follow-up to netfilter-devel for nf-next extending that guard to also skip Redirect, so both paths behave consistently.
Does that split sound right? this fix to is_ineligible() for the L3 path, plus a separate nf-next patch for the bridge/netdev reject guard?
Thanks,
Sayooj
Pablo Neira Ayuso
maintainerQuoted 15 lines · Sayooj K Karun
You are right that netfilter can be configured to make devices behave in non-RFC-compliant ways, so I will drop the "netfilter policy must obey the RFC" framing from my earlier reply.
The point I should have made is that
is_ineligible()is not a netfilter function. It is the generic gate thaticmpv6_send()uses to decide whether the kernel, as an ICMPv6 originator, may emit an error for a given trigger packet, and it is shared by allicmpv6_send()callers. It already enforces RFC 4443 section 2.4(e.1) at exactly this spot, via !(*tp &ICMPV6_INFOMSG_MASK), that is "do not originate an error in response to an ICMPv6 error". My patch adds (e.2) (Redirect) right next to it, the second rule from the same MUST NOT list. So this is not about overriding netfilter policy; it is completing the e.1/e.2 pair at the single point where the kernel decides ICMPv6 error eligibility.
Quoted 7 lines
On how it fixes the REJECT case: the two IPv6 reject paths differ in who actually frames the ICMPv6 error. The bridge/netdev path,
nf_reject_skb_v6_unreach(), builds the packet by hand: it allocates the skb, writes the IPv6 and ICMPv6 headers, copies in the original packet and computes the checksum. Because it does all that itself, it has to carry its own guard,nf_skb_is_icmp6_unreach(), the IPv6 analogue of thenf_skb_is_icmp_unreach()you mention.
Yes, because bridge/netdev path cannot assume the IP stack comes into play, so it needs a custom function to build the packet to reject the traffic.
Quoted 21 lines
The L3 path,
ip6t_REJECT/nft_reject->nf_send_unreach6(), never frames a packet of its own. It just callsicmpv6_send()and lets the core ICMPv6 stack build and send the error.is_ineligible()is the gate that core builder consults first, before it allocates or assembles anything, so that is exactly where the e.1 suppression already lives for this path. There is no netfilter-local guard here, and there does not need to be.So the scenario in my commit message is the L3 path:
ip6t_REJECT/nft_reject
>nf_send_unreach6()
>icmpv6_send()/icmp6_send()
>is_ineligible()// now returns true forNDISC_REDIRECT
> goto out, no packet is ever built or transmittedThe patch fixes the REJECT case because the L3 reject hands packet construction to
icmp6_send(), andis_ineligible()runs at the top of that builder, before any error skb exists. It is the same spot that already drops e.1 today, so adding e.2 there completes the pair rather than introducing a new override.
Quoted 6 lines
I also agree there is a gap to close on the netfilter side. The bridge/netdev path never reaches
is_ineligible(), and itsnf_skb_is_icmp6_unreach()guard currently checks onlyICMPV6_DEST_UNREACH, not Redirect, so it is not covered by this patch. I will send a follow-up to netfilter-devel for nf-next extending that guard to also skip Redirect, so both paths behave consistently.
Yes, nf-next is the target for this for review.
Quoted 2 lines
Does that split sound right? this fix to
is_ineligible()for the L3 path, plus a separate nf-next patch for the bridge/netdev reject guard?
Maybe, I did not look in depth with details, but posting a patch upfront to see how things look like make it easier for us, even if more changes are later requested on it.
Thanks.