Skip to contentSkip to conversation

ipv6: re-enable fragment header matching in ipv6_find_hdr

PATCH In review Florian Westphal 2 participants 2 messages Mar 1, 2016 – Mar 3, 2016

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

PATCH 1/1 ipv6: re-enable fragment header matching in ipv6_find_hdr

When ipv6_find_hdr is used to find a fragment header (caller specifies target NEXTHDR_FRAGMENT) we erronously return -ENOENT for all fragments with nonzero offset.

Before commit 9195bb8e381d, when target was specified, we did not enter the exthdr walk loop as nexthdr == target so this used to work.

Now we do (so we can skip empty route headers). When we then stumble upon a frag with nonzero frag_off we must return -ENOENT ("header not found") only if the caller did not specifically request NEXTHDR_FRAGMENT.

This allows nfables exthdr expression to match ipv6 fragments, e.g. via

nft add rule ip6 filter input frag frag-off gt 0

Fixes 9195bb8e381d ("ipv6: improve ipv6_find_hdr() to skip empty routing headers")
---
 net/ipv6/exthdrs_core.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
net/ipv6/exthdrs_core.c +5 -1
index 5c5d23e..9508a20 100644
@@ -257,7 +257,11 @@ int ipv6_find_hdr(const struct sk_buff *skb, unsigned int *offset,
 						*fragoff = _frag_off;
 					return hp->nexthdr;
 				}
-				return -ENOENT;
+				if (!found)
+					return -ENOENT;
+				if (fragoff)
+					*fragoff = _frag_off;
+				break;
 			}
 			hdrlen = 8;
 		} else if (nexthdr == NEXTHDR_AUTH) {
Signature · 1 line
2.4.10
maintainer
#1 lore raw

From: Florian Westphal <[email protected]>
Date: Tue, 1 Mar 2016 16:15:16 +0100

Quoted 11 lines

When ipv6_find_hdr is used to find a fragment header (caller specifies target NEXTHDR_FRAGMENT) we erronously return -ENOENT for all fragments with nonzero offset.

Before commit 9195bb8e381d, when target was specified, we did not enter the exthdr walk loop as nexthdr == target so this used to work.

Now we do (so we can skip empty route headers). When we then stumble upon a frag with nonzero frag_off we must return -ENOENT ("header not found") only if the caller did not specifically request NEXTHDR_FRAGMENT.

Quoted 6 lines

This allows nfables exthdr expression to match ipv6 fragments, e.g. via

nft add rule ip6 filter input frag frag-off gt 0

Fixes 9195bb8e381d ("ipv6: improve ipv6_find_hdr() to skip empty routing headers")

Applied and queued up for -stable, thanks Florian.