#ifndef _NET_IPV6_H
#define _NET_IPV6_H
#include <linux/ipv6.h>
#include <linux/hardirq.h>
#include <linux/jhash.h>
#include <linux/refcount.h>
#include <linux/jump_label_ratelimit.h>
#include <net/if_inet6.h>
#include <net/flow.h>
#include <net/flow_dissector.h>
#include <net/inet_dscp.h>
#include <net/snmp.h>
#include <net/netns/hash.h>
struct ip_tunnel_info;
#define SIN6_LEN_RFC2133 …
#define IPV6_MAXPLEN …
#define NEXTHDR_HOP …
#define NEXTHDR_IPV4 …
#define NEXTHDR_TCP …
#define NEXTHDR_UDP …
#define NEXTHDR_IPV6 …
#define NEXTHDR_ROUTING …
#define NEXTHDR_FRAGMENT …
#define NEXTHDR_GRE …
#define NEXTHDR_ESP …
#define NEXTHDR_AUTH …
#define NEXTHDR_ICMP …
#define NEXTHDR_NONE …
#define NEXTHDR_DEST …
#define NEXTHDR_SCTP …
#define NEXTHDR_MOBILITY …
#define NEXTHDR_MAX …
#define IPV6_DEFAULT_HOPLIMIT …
#define IPV6_DEFAULT_MCASTHOPS …
#define IP6_DEFAULT_MAX_DST_OPTS_CNT …
#define IP6_DEFAULT_MAX_HBH_OPTS_CNT …
#define IP6_DEFAULT_MAX_DST_OPTS_LEN …
#define IP6_DEFAULT_MAX_HBH_OPTS_LEN …
#define IPV6_ADDR_ANY …
#define IPV6_ADDR_UNICAST …
#define IPV6_ADDR_MULTICAST …
#define IPV6_ADDR_LOOPBACK …
#define IPV6_ADDR_LINKLOCAL …
#define IPV6_ADDR_SITELOCAL …
#define IPV6_ADDR_COMPATv4 …
#define IPV6_ADDR_SCOPE_MASK …
#define IPV6_ADDR_MAPPED …
#define IPV6_ADDR_MC_SCOPE(a) …
#define __IPV6_ADDR_SCOPE_INVALID …
#define IPV6_ADDR_SCOPE_NODELOCAL …
#define IPV6_ADDR_SCOPE_LINKLOCAL …
#define IPV6_ADDR_SCOPE_SITELOCAL …
#define IPV6_ADDR_SCOPE_ORGLOCAL …
#define IPV6_ADDR_SCOPE_GLOBAL …
#define IPV6_ADDR_MC_FLAG_TRANSIENT(a) …
#define IPV6_ADDR_MC_FLAG_PREFIX(a) …
#define IPV6_ADDR_MC_FLAG_RENDEZVOUS(a) …
struct frag_hdr { … };
struct hop_jumbo_hdr { … };
#define IP6_MF …
#define IP6_OFFSET …
struct ip6_fraglist_iter { … };
int ip6_fraglist_init(struct sk_buff *skb, unsigned int hlen, u8 *prevhdr,
u8 nexthdr, __be32 frag_id,
struct ip6_fraglist_iter *iter);
void ip6_fraglist_prepare(struct sk_buff *skb, struct ip6_fraglist_iter *iter);
static inline struct sk_buff *ip6_fraglist_next(struct ip6_fraglist_iter *iter)
{ … }
struct ip6_frag_state { … };
void ip6_frag_init(struct sk_buff *skb, unsigned int hlen, unsigned int mtu,
unsigned short needed_tailroom, int hdr_room, u8 *prevhdr,
u8 nexthdr, __be32 frag_id, struct ip6_frag_state *state);
struct sk_buff *ip6_frag_next(struct sk_buff *skb,
struct ip6_frag_state *state);
#define IP6_REPLY_MARK(net, mark) …
#include <net/sock.h>
extern int sysctl_mld_max_msf;
extern int sysctl_mld_qrv;
#define _DEVINC(net, statname, mod, idev, field) …
#define _DEVINCATOMIC(net, statname, mod, idev, field) …
#define _DEVINC_ATOMIC_ATOMIC(net, statname, idev, field) …
#define _DEVADD(net, statname, mod, idev, field, val) …
#define _DEVUPD(net, statname, mod, idev, field, val) …
#define IP6_INC_STATS(net, idev,field) …
#define __IP6_INC_STATS(net, idev,field) …
#define IP6_ADD_STATS(net, idev,field,val) …
#define __IP6_ADD_STATS(net, idev,field,val) …
#define IP6_UPD_PO_STATS(net, idev,field,val) …
#define __IP6_UPD_PO_STATS(net, idev,field,val) …
#define ICMP6_INC_STATS(net, idev, field) …
#define __ICMP6_INC_STATS(net, idev, field) …
#define ICMP6MSGOUT_INC_STATS(net, idev, field) …
#define ICMP6MSGIN_INC_STATS(net, idev, field) …
struct ip6_ra_chain { … };
extern struct ip6_ra_chain *ip6_ra_chain;
extern rwlock_t ip6_ra_lock;
struct ipv6_txoptions { … };
enum flowlabel_reflect { … };
struct ip6_flowlabel { … };
#define IPV6_FLOWINFO_MASK …
#define IPV6_FLOWLABEL_MASK …
#define IPV6_FLOWLABEL_STATELESS_FLAG …
#define IPV6_TCLASS_MASK …
#define IPV6_TCLASS_SHIFT …
struct ipv6_fl_socklist { … };
struct ipcm6_cookie { … };
static inline void ipcm6_init(struct ipcm6_cookie *ipc6)
{ … }
static inline void ipcm6_init_sk(struct ipcm6_cookie *ipc6,
const struct sock *sk)
{ … }
static inline struct ipv6_txoptions *txopt_get(const struct ipv6_pinfo *np)
{ … }
static inline void txopt_put(struct ipv6_txoptions *opt)
{ … }
#if IS_ENABLED(CONFIG_IPV6)
struct ip6_flowlabel *__fl6_sock_lookup(struct sock *sk, __be32 label);
extern struct static_key_false_deferred ipv6_flowlabel_exclusive;
static inline struct ip6_flowlabel *fl6_sock_lookup(struct sock *sk,
__be32 label)
{ … }
#endif
struct ipv6_txoptions *fl6_merge_options(struct ipv6_txoptions *opt_space,
struct ip6_flowlabel *fl,
struct ipv6_txoptions *fopt);
void fl6_free_socklist(struct sock *sk);
int ipv6_flowlabel_opt(struct sock *sk, sockptr_t optval, int optlen);
int ipv6_flowlabel_opt_get(struct sock *sk, struct in6_flowlabel_req *freq,
int flags);
int ip6_flowlabel_init(void);
void ip6_flowlabel_cleanup(void);
bool ip6_autoflowlabel(struct net *net, const struct sock *sk);
static inline void fl6_sock_release(struct ip6_flowlabel *fl)
{ … }
enum skb_drop_reason icmpv6_notify(struct sk_buff *skb, u8 type,
u8 code, __be32 info);
void icmpv6_push_pending_frames(struct sock *sk, struct flowi6 *fl6,
struct icmp6hdr *thdr, int len);
int ip6_ra_control(struct sock *sk, int sel);
int ipv6_parse_hopopts(struct sk_buff *skb);
struct ipv6_txoptions *ipv6_dup_options(struct sock *sk,
struct ipv6_txoptions *opt);
struct ipv6_txoptions *ipv6_renew_options(struct sock *sk,
struct ipv6_txoptions *opt,
int newtype,
struct ipv6_opt_hdr *newopt);
struct ipv6_txoptions *__ipv6_fixup_options(struct ipv6_txoptions *opt_space,
struct ipv6_txoptions *opt);
static inline struct ipv6_txoptions *
ipv6_fixup_options(struct ipv6_txoptions *opt_space, struct ipv6_txoptions *opt)
{ … }
bool ipv6_opt_accepted(const struct sock *sk, const struct sk_buff *skb,
const struct inet6_skb_parm *opt);
struct ipv6_txoptions *ipv6_update_options(struct sock *sk,
struct ipv6_txoptions *opt);
static inline int ipv6_has_hopopt_jumbo(const struct sk_buff *skb)
{ … }
static inline int ipv6_hopopt_jumbo_remove(struct sk_buff *skb)
{ … }
static inline bool ipv6_accept_ra(const struct inet6_dev *idev)
{ … }
#define IPV6_FRAG_HIGH_THRESH …
#define IPV6_FRAG_LOW_THRESH …
#define IPV6_FRAG_TIMEOUT …
int __ipv6_addr_type(const struct in6_addr *addr);
static inline int ipv6_addr_type(const struct in6_addr *addr)
{ … }
static inline int ipv6_addr_scope(const struct in6_addr *addr)
{ … }
static inline int __ipv6_addr_src_scope(int type)
{ … }
static inline int ipv6_addr_src_scope(const struct in6_addr *addr)
{ … }
static inline bool __ipv6_addr_needs_scope_id(int type)
{ … }
static inline __u32 ipv6_iface_scope_id(const struct in6_addr *addr, int iface)
{ … }
static inline int ipv6_addr_cmp(const struct in6_addr *a1, const struct in6_addr *a2)
{ … }
static inline bool
ipv6_masked_addr_cmp(const struct in6_addr *a1, const struct in6_addr *m,
const struct in6_addr *a2)
{ … }
static inline void ipv6_addr_prefix(struct in6_addr *pfx,
const struct in6_addr *addr,
int plen)
{ … }
static inline void ipv6_addr_prefix_copy(struct in6_addr *addr,
const struct in6_addr *pfx,
int plen)
{ … }
static inline void __ipv6_addr_set_half(__be32 *addr,
__be32 wh, __be32 wl)
{ … }
static inline void ipv6_addr_set(struct in6_addr *addr,
__be32 w1, __be32 w2,
__be32 w3, __be32 w4)
{ … }
static inline bool ipv6_addr_equal(const struct in6_addr *a1,
const struct in6_addr *a2)
{ … }
#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) && BITS_PER_LONG == 64
static inline bool __ipv6_prefix_equal64_half(const __be64 *a1,
const __be64 *a2,
unsigned int len)
{ … }
static inline bool ipv6_prefix_equal(const struct in6_addr *addr1,
const struct in6_addr *addr2,
unsigned int prefixlen)
{ … }
#else
static inline bool ipv6_prefix_equal(const struct in6_addr *addr1,
const struct in6_addr *addr2,
unsigned int prefixlen)
{
const __be32 *a1 = addr1->s6_addr32;
const __be32 *a2 = addr2->s6_addr32;
unsigned int pdw, pbi;
pdw = prefixlen >> 5;
if (pdw && memcmp(a1, a2, pdw << 2))
return false;
pbi = prefixlen & 0x1f;
if (pbi && ((a1[pdw] ^ a2[pdw]) & htonl((0xffffffff) << (32 - pbi))))
return false;
return true;
}
#endif
static inline bool ipv6_addr_any(const struct in6_addr *a)
{ … }
static inline u32 ipv6_addr_hash(const struct in6_addr *a)
{ … }
static inline u32 __ipv6_addr_jhash(const struct in6_addr *a, const u32 initval)
{ … }
static inline bool ipv6_addr_loopback(const struct in6_addr *a)
{ … }
static inline bool ipv6_addr_v4mapped(const struct in6_addr *a)
{ … }
static inline bool ipv6_addr_v4mapped_loopback(const struct in6_addr *a)
{ … }
static inline u32 ipv6_portaddr_hash(const struct net *net,
const struct in6_addr *addr6,
unsigned int port)
{ … }
static inline bool ipv6_addr_orchid(const struct in6_addr *a)
{ … }
static inline bool ipv6_addr_is_multicast(const struct in6_addr *addr)
{ … }
static inline void ipv6_addr_set_v4mapped(const __be32 addr,
struct in6_addr *v4mapped)
{ … }
static inline int __ipv6_addr_diff32(const void *token1, const void *token2, int addrlen)
{ … }
#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) && BITS_PER_LONG == 64
static inline int __ipv6_addr_diff64(const void *token1, const void *token2, int addrlen)
{ … }
#endif
static inline int __ipv6_addr_diff(const void *token1, const void *token2, int addrlen)
{ … }
static inline int ipv6_addr_diff(const struct in6_addr *a1, const struct in6_addr *a2)
{ … }
__be32 ipv6_select_ident(struct net *net,
const struct in6_addr *daddr,
const struct in6_addr *saddr);
__be32 ipv6_proxy_select_ident(struct net *net, struct sk_buff *skb);
int ip6_dst_hoplimit(struct dst_entry *dst);
static inline int ip6_sk_dst_hoplimit(struct ipv6_pinfo *np, struct flowi6 *fl6,
struct dst_entry *dst)
{ … }
static inline void iph_to_flow_copy_v6addrs(struct flow_keys *flow,
const struct ipv6hdr *iph)
{ … }
#if IS_ENABLED(CONFIG_IPV6)
static inline bool ipv6_can_nonlocal_bind(struct net *net,
struct inet_sock *inet)
{ … }
#define IP6_AUTO_FLOW_LABEL_OFF …
#define IP6_AUTO_FLOW_LABEL_OPTOUT …
#define IP6_AUTO_FLOW_LABEL_OPTIN …
#define IP6_AUTO_FLOW_LABEL_FORCED …
#define IP6_AUTO_FLOW_LABEL_MAX …
#define IP6_DEFAULT_AUTO_FLOW_LABELS …
static inline __be32 ip6_make_flowlabel(struct net *net, struct sk_buff *skb,
__be32 flowlabel, bool autolabel,
struct flowi6 *fl6)
{ … }
static inline int ip6_default_np_autolabel(struct net *net)
{ … }
#else
static inline __be32 ip6_make_flowlabel(struct net *net, struct sk_buff *skb,
__be32 flowlabel, bool autolabel,
struct flowi6 *fl6)
{
return flowlabel;
}
static inline int ip6_default_np_autolabel(struct net *net)
{
return 0;
}
#endif
#if IS_ENABLED(CONFIG_IPV6)
static inline int ip6_multipath_hash_policy(const struct net *net)
{ … }
static inline u32 ip6_multipath_hash_fields(const struct net *net)
{ … }
#else
static inline int ip6_multipath_hash_policy(const struct net *net)
{
return 0;
}
static inline u32 ip6_multipath_hash_fields(const struct net *net)
{
return 0;
}
#endif
static inline void ip6_flow_hdr(struct ipv6hdr *hdr, unsigned int tclass,
__be32 flowlabel)
{ … }
static inline __be32 ip6_flowinfo(const struct ipv6hdr *hdr)
{ … }
static inline __be32 ip6_flowlabel(const struct ipv6hdr *hdr)
{ … }
static inline u8 ip6_tclass(__be32 flowinfo)
{ … }
static inline dscp_t ip6_dscp(__be32 flowinfo)
{ … }
static inline __be32 ip6_make_flowinfo(unsigned int tclass, __be32 flowlabel)
{ … }
static inline __be32 flowi6_get_flowlabel(const struct flowi6 *fl6)
{ … }
int ipv6_rcv(struct sk_buff *skb, struct net_device *dev,
struct packet_type *pt, struct net_device *orig_dev);
void ipv6_list_rcv(struct list_head *head, struct packet_type *pt,
struct net_device *orig_dev);
int ip6_rcv_finish(struct net *net, struct sock *sk, struct sk_buff *skb);
int ip6_xmit(const struct sock *sk, struct sk_buff *skb, struct flowi6 *fl6,
__u32 mark, struct ipv6_txoptions *opt, int tclass, u32 priority);
int ip6_find_1stfragopt(struct sk_buff *skb, u8 **nexthdr);
int ip6_append_data(struct sock *sk,
int getfrag(void *from, char *to, int offset, int len,
int odd, struct sk_buff *skb),
void *from, size_t length, int transhdrlen,
struct ipcm6_cookie *ipc6, struct flowi6 *fl6,
struct rt6_info *rt, unsigned int flags);
int ip6_push_pending_frames(struct sock *sk);
void ip6_flush_pending_frames(struct sock *sk);
int ip6_send_skb(struct sk_buff *skb);
struct sk_buff *__ip6_make_skb(struct sock *sk, struct sk_buff_head *queue,
struct inet_cork_full *cork,
struct inet6_cork *v6_cork);
struct sk_buff *ip6_make_skb(struct sock *sk,
int getfrag(void *from, char *to, int offset,
int len, int odd, struct sk_buff *skb),
void *from, size_t length, int transhdrlen,
struct ipcm6_cookie *ipc6,
struct rt6_info *rt, unsigned int flags,
struct inet_cork_full *cork);
static inline struct sk_buff *ip6_finish_skb(struct sock *sk)
{ … }
int ip6_dst_lookup(struct net *net, struct sock *sk, struct dst_entry **dst,
struct flowi6 *fl6);
struct dst_entry *ip6_dst_lookup_flow(struct net *net, const struct sock *sk, struct flowi6 *fl6,
const struct in6_addr *final_dst);
struct dst_entry *ip6_sk_dst_lookup_flow(struct sock *sk, struct flowi6 *fl6,
const struct in6_addr *final_dst,
bool connected);
struct dst_entry *ip6_blackhole_route(struct net *net,
struct dst_entry *orig_dst);
int ip6_output(struct net *net, struct sock *sk, struct sk_buff *skb);
int ip6_forward(struct sk_buff *skb);
int ip6_input(struct sk_buff *skb);
int ip6_mc_input(struct sk_buff *skb);
void ip6_protocol_deliver_rcu(struct net *net, struct sk_buff *skb, int nexthdr,
bool have_final);
int __ip6_local_out(struct net *net, struct sock *sk, struct sk_buff *skb);
int ip6_local_out(struct net *net, struct sock *sk, struct sk_buff *skb);
void ipv6_push_nfrag_opts(struct sk_buff *skb, struct ipv6_txoptions *opt,
u8 *proto, struct in6_addr **daddr_p,
struct in6_addr *saddr);
void ipv6_push_frag_opts(struct sk_buff *skb, struct ipv6_txoptions *opt,
u8 *proto);
int ipv6_skip_exthdr(const struct sk_buff *, int start, u8 *nexthdrp,
__be16 *frag_offp);
bool ipv6_ext_hdr(u8 nexthdr);
enum { … };
int ipv6_find_hdr(const struct sk_buff *skb, unsigned int *offset, int target,
unsigned short *fragoff, int *fragflg);
int ipv6_find_tlv(const struct sk_buff *skb, int offset, int type);
struct in6_addr *fl6_update_dst(struct flowi6 *fl6,
const struct ipv6_txoptions *opt,
struct in6_addr *orig);
DECLARE_STATIC_KEY_FALSE(ip6_min_hopcount);
int do_ipv6_setsockopt(struct sock *sk, int level, int optname, sockptr_t optval,
unsigned int optlen);
int ipv6_setsockopt(struct sock *sk, int level, int optname, sockptr_t optval,
unsigned int optlen);
int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
sockptr_t optval, sockptr_t optlen);
int ipv6_getsockopt(struct sock *sk, int level, int optname,
char __user *optval, int __user *optlen);
int __ip6_datagram_connect(struct sock *sk, struct sockaddr *addr,
int addr_len);
int ip6_datagram_connect(struct sock *sk, struct sockaddr *addr, int addr_len);
int ip6_datagram_connect_v6_only(struct sock *sk, struct sockaddr *addr,
int addr_len);
int ip6_datagram_dst_update(struct sock *sk, bool fix_sk_saddr);
void ip6_datagram_release_cb(struct sock *sk);
int ipv6_recv_error(struct sock *sk, struct msghdr *msg, int len,
int *addr_len);
int ipv6_recv_rxpmtu(struct sock *sk, struct msghdr *msg, int len,
int *addr_len);
void ipv6_icmp_error(struct sock *sk, struct sk_buff *skb, int err, __be16 port,
u32 info, u8 *payload);
void ipv6_local_error(struct sock *sk, int err, struct flowi6 *fl6, u32 info);
void ipv6_local_rxpmtu(struct sock *sk, struct flowi6 *fl6, u32 mtu);
void inet6_cleanup_sock(struct sock *sk);
void inet6_sock_destruct(struct sock *sk);
int inet6_release(struct socket *sock);
int inet6_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len);
int inet6_bind_sk(struct sock *sk, struct sockaddr *uaddr, int addr_len);
int inet6_getname(struct socket *sock, struct sockaddr *uaddr,
int peer);
int inet6_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg);
int inet6_compat_ioctl(struct socket *sock, unsigned int cmd,
unsigned long arg);
int inet6_hash_connect(struct inet_timewait_death_row *death_row,
struct sock *sk);
int inet6_sendmsg(struct socket *sock, struct msghdr *msg, size_t size);
int inet6_recvmsg(struct socket *sock, struct msghdr *msg, size_t size,
int flags);
extern const struct proto_ops inet6_stream_ops;
extern const struct proto_ops inet6_dgram_ops;
extern const struct proto_ops inet6_sockraw_ops;
struct group_source_req;
struct group_filter;
int ip6_mc_source(int add, int omode, struct sock *sk,
struct group_source_req *pgsr);
int ip6_mc_msfilter(struct sock *sk, struct group_filter *gsf,
struct sockaddr_storage *list);
int ip6_mc_msfget(struct sock *sk, struct group_filter *gsf,
sockptr_t optval, size_t ss_offset);
#ifdef CONFIG_PROC_FS
int ac6_proc_init(struct net *net);
void ac6_proc_exit(struct net *net);
int raw6_proc_init(void);
void raw6_proc_exit(void);
int tcp6_proc_init(struct net *net);
void tcp6_proc_exit(struct net *net);
int udp6_proc_init(struct net *net);
void udp6_proc_exit(struct net *net);
int udplite6_proc_init(void);
void udplite6_proc_exit(void);
int ipv6_misc_proc_init(void);
void ipv6_misc_proc_exit(void);
int snmp6_register_dev(struct inet6_dev *idev);
int snmp6_unregister_dev(struct inet6_dev *idev);
#else
static inline int ac6_proc_init(struct net *net) { return 0; }
static inline void ac6_proc_exit(struct net *net) { }
static inline int snmp6_register_dev(struct inet6_dev *idev) { return 0; }
static inline int snmp6_unregister_dev(struct inet6_dev *idev) { return 0; }
#endif
#ifdef CONFIG_SYSCTL
struct ctl_table *ipv6_icmp_sysctl_init(struct net *net);
size_t ipv6_icmp_sysctl_table_size(void);
struct ctl_table *ipv6_route_sysctl_init(struct net *net);
size_t ipv6_route_sysctl_table_size(struct net *net);
int ipv6_sysctl_register(void);
void ipv6_sysctl_unregister(void);
#endif
int ipv6_sock_mc_join(struct sock *sk, int ifindex,
const struct in6_addr *addr);
int ipv6_sock_mc_join_ssm(struct sock *sk, int ifindex,
const struct in6_addr *addr, unsigned int mode);
int ipv6_sock_mc_drop(struct sock *sk, int ifindex,
const struct in6_addr *addr);
static inline int ip6_sock_set_v6only(struct sock *sk)
{ … }
static inline void ip6_sock_set_recverr(struct sock *sk)
{ … }
#define IPV6_PREFER_SRC_MASK …
static inline int ip6_sock_set_addr_preferences(struct sock *sk, int val)
{ … }
static inline void ip6_sock_set_recvpktinfo(struct sock *sk)
{ … }
#endif