diff options
author | Florian Westphal <fw@strlen.de> | 2016-03-01 18:15:16 +0300 |
---|---|---|
committer | Jiri Slaby <jslaby@suse.cz> | 2016-04-18 18:09:19 +0300 |
commit | c2f68b2e2e01b6a4081bee02e0c6646d5f7e83b4 (patch) | |
tree | eded0c5f606236ba34325a27e278b37d07d30f55 /net | |
parent | be212a56698c9918e5262974713505b7cdd5c171 (diff) | |
download | linux-c2f68b2e2e01b6a4081bee02e0c6646d5f7e83b4.tar.xz |
ipv6: re-enable fragment header matching in ipv6_find_hdr
[ Upstream commit 5d150a985520bbe3cb2aa1ceef24a7e32f20c15f ]
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")
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Diffstat (limited to 'net')
-rw-r--r-- | net/ipv6/exthdrs_core.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/net/ipv6/exthdrs_core.c b/net/ipv6/exthdrs_core.c index 8af3eb57f438..c7c8f71d0d48 100644 --- a/net/ipv6/exthdrs_core.c +++ b/net/ipv6/exthdrs_core.c @@ -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) { |