// SPDX-License-Identifier: GPL-2.0-or-later/* * Extension Header handling for IPv6 * Linux INET6 implementation * * Authors: * Pedro Roque <roque@di.fc.ul.pt> * Andi Kleen <ak@muc.de> * Alexey Kuznetsov <kuznet@ms2.inr.ac.ru> *//* Changes: * yoshfuji : ensure not to overrun while parsing * tlv options. * Mitsuru KANDA @USAGI and: Remove ipv6_parse_exthdrs(). * YOSHIFUJI Hideaki @USAGI Register inbound extension header * handlers as inet6_protocol{}. */#include<linux/errno.h>#include<linux/types.h>#include<linux/socket.h>#include<linux/sockios.h>#include<linux/net.h>#include<linux/netdevice.h>#include<linux/in6.h>#include<linux/icmpv6.h>#include<linux/slab.h>#include<linux/export.h>#include<net/dst.h>#include<net/sock.h>#include<net/snmp.h>#include<net/ipv6.h>#include<net/protocol.h>#include<net/transp_v6.h>#include<net/rawv6.h>#include<net/ndisc.h>#include<net/ip6_route.h>#include<net/addrconf.h>#include<net/calipso.h>#if IS_ENABLED(CONFIG_IPV6_MIP6)#include<net/xfrm.h>#endif#include<linux/seg6.h>#include<net/seg6.h>#ifdef CONFIG_IPV6_SEG6_HMAC#include<net/seg6_hmac.h>#endif#include<net/rpl.h>#include<linux/ioam6.h>#include<linux/ioam6_genl.h>#include<net/ioam6.h>#include<net/dst_metadata.h>#include<linux/uaccess.h>/********************* Generic functions *********************//* An unknown option is detected, decide what to do */staticboolip6_tlvopt_unknown(structsk_buff*skb,intoptoff,booldisallow_unknowns){if(disallow_unknowns){/* If unknown TLVs are disallowed by configuration * then always silently drop packet. Note this also * means no ICMP parameter problem is sent which * could be a good property to mitigate a reflection DOS * attack. */gotodrop;}switch((skb_network_header(skb)[optoff]&0xC0)>>6){case0:/* ignore */returntrue;case1:/* drop packet */break;case3:/* Send ICMP if not a multicast address and drop packet *//* Actually, it is redundant check. icmp_send will recheck in any case. */if