FreeBSD kernel IPv6 code
|
#include <sys/cdefs.h>
#include "opt_inet.h"
#include "opt_inet6.h"
#include "opt_ipsec.h"
#include "opt_kern_tls.h"
#include "opt_ratelimit.h"
#include "opt_route.h"
#include "opt_rss.h"
#include "opt_sctp.h"
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/ktls.h>
#include <sys/malloc.h>
#include <sys/mbuf.h>
#include <sys/errno.h>
#include <sys/priv.h>
#include <sys/proc.h>
#include <sys/protosw.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
#include <sys/syslog.h>
#include <sys/ucred.h>
#include <machine/in_cksum.h>
#include <net/if.h>
#include <net/if_var.h>
#include <net/if_vlan_var.h>
#include <net/if_llatbl.h>
#include <net/ethernet.h>
#include <net/netisr.h>
#include <net/route.h>
#include <net/route/nhop.h>
#include <net/pfil.h>
#include <net/rss_config.h>
#include <net/vnet.h>
#include <netinet/in.h>
#include <netinet/in_var.h>
#include <netinet/ip_var.h>
#include <netinet6/in6_fib.h>
#include <netinet6/in6_var.h>
#include <netinet/ip6.h>
#include <netinet/icmp6.h>
#include <netinet6/ip6_var.h>
#include <netinet/in_pcb.h>
#include <netinet/tcp_var.h>
#include <netinet6/nd6.h>
#include <netinet6/in6_rss.h>
#include <netipsec/ipsec_support.h>
#include <netinet6/ip6protosw.h>
#include <netinet6/scope6_var.h>
Go to the source code of this file.
Data Structures | |
struct | ip6_exthdrs |
Macros | |
#define | MAKE_EXTHDR(hp, mp, _ol) |
#define | MAKE_CHAIN(m, mp, p, i) |
#define | JUMBOOPTLEN 8 /* length of jumbo payload option and padding */ |
#define | IPV6_PKTOPTIONS_MBUF_LIMIT ((u_long)nmbclusters * MCLBYTES / 4) |
#define | OPTSET(bit) |
#define | OPTSET2292(bit) |
#define | OPTBIT(bit) (inp->inp_flags & (bit) ? 1 : 0) |
#define | OPTSET2_N(bit, val) |
#define | OPTSET2(bit, val) |
#define | OPTBIT2(bit) (inp->inp_flags2 & (bit) ? 1 : 0) |
#define | OPTSET2292_EXCLUSIVE(bit) |
#define | GET_PKTOPT_VAR(field, lenexpr) |
#define | GET_PKTOPT_EXT_HDR(field) |
#define | GET_PKTOPT_SOCKADDR(field) |
#define | PKTOPT_EXTHDRCPY(type) |
#define | elen(x) (((struct ip6_ext *)(x)) ? (((struct ip6_ext *)(x))->ip6e_len + 1) << 3 : 0) |
Functions | |
__FBSDID ("$FreeBSD$") | |
static | MALLOC_DEFINE (M_IP6OPT, "ip6opt", "IPv6 options") |
static int | ip6_pcbopt (int, u_char *, int, struct ip6_pktopts **, struct ucred *, int) |
static int | ip6_pcbopts (struct ip6_pktopts **, struct mbuf *, struct socket *, struct sockopt *) |
static int | ip6_getpcbopt (struct inpcb *, int, struct sockopt *) |
static int | ip6_setpktopt (int, u_char *, int, struct ip6_pktopts *, struct ucred *, int, int, int) |
static int | ip6_copyexthdr (struct mbuf **, caddr_t, int) |
static int | ip6_insertfraghdr (struct mbuf *, struct mbuf *, int, struct ip6_frag **) |
static int | ip6_insert_jumboopt (struct ip6_exthdrs *, u_int32_t) |
static int | ip6_splithdr (struct mbuf *, struct ip6_exthdrs *) |
static int | ip6_getpmtu (struct route_in6 *, int, struct ifnet *, const struct in6_addr *, u_long *, int *, u_int, u_int) |
static int | ip6_calcmtu (struct ifnet *, const struct in6_addr *, u_long, u_long *, int *, u_int) |
static int | ip6_getpmtu_ctl (u_int, const struct in6_addr *, u_long *) |
static int | copypktopts (struct ip6_pktopts *, struct ip6_pktopts *, int) |
void | in6_delayed_cksum (struct mbuf *m, uint32_t plen, u_short offset) |
static void | ip6_output_delayed_csum (struct mbuf *m, struct ifnet *ifp, int csum_flags, int plen, int optlen) |
int | ip6_fragment (struct ifnet *ifp, struct mbuf *m0, int hlen, u_char nextproto, int fraglen, uint32_t id) |
static int | ip6_output_send (struct inpcb *inp, struct ifnet *ifp, struct ifnet *origifp, struct mbuf *m, struct sockaddr_in6 *dst, struct route_in6 *ro, bool stamp_tag) |
int | ip6_output (struct mbuf *m0, struct ip6_pktopts *opt, struct route_in6 *ro, int flags, struct ip6_moptions *im6o, struct ifnet **ifpp, struct inpcb *inp) |
int | ip6_ctloutput (struct socket *so, struct sockopt *sopt) |
int | ip6_raw_ctloutput (struct socket *so, struct sockopt *sopt) |
void | ip6_initpktopts (struct ip6_pktopts *opt) |
void | ip6_clearpktopts (struct ip6_pktopts *pktopt, int optname) |
struct ip6_pktopts * | ip6_copypktopts (struct ip6_pktopts *src, int canwait) |
void | ip6_freepcbopts (struct ip6_pktopts *pktopt) |
int | ip6_setpktopts (struct mbuf *control, struct ip6_pktopts *opt, struct ip6_pktopts *stickyopt, struct ucred *cred, int uproto) |
void | ip6_mloopback (struct ifnet *ifp, struct mbuf *m) |
int | ip6_optlen (struct inpcb *inp) |
Variables | |
int | in6_mcast_loop |
#define elen | ( | x | ) | (((struct ip6_ext *)(x)) ? (((struct ip6_ext *)(x))->ip6e_len + 1) << 3 : 0) |
#define GET_PKTOPT_EXT_HDR | ( | field | ) |
Definition at line 2594 of file ip6_output.c.
#define GET_PKTOPT_SOCKADDR | ( | field | ) |
Definition at line 2597 of file ip6_output.c.
#define GET_PKTOPT_VAR | ( | field, | |
lenexpr | |||
) |
Definition at line 2571 of file ip6_output.c.
#define IPV6_PKTOPTIONS_MBUF_LIMIT ((u_long)nmbclusters * MCLBYTES / 4) |
#define JUMBOOPTLEN 8 /* length of jumbo payload option and padding */ |
#define MAKE_CHAIN | ( | m, | |
mp, | |||
p, | |||
i | |||
) |
Definition at line 183 of file ip6_output.c.
#define MAKE_EXTHDR | ( | hp, | |
mp, | |||
_ol | |||
) |
Definition at line 164 of file ip6_output.c.
#define OPTBIT | ( | bit | ) | (inp->inp_flags & (bit) ? 1 : 0) |
#define OPTBIT2 | ( | bit | ) | (inp->inp_flags2 & (bit) ? 1 : 0) |
#define OPTSET | ( | bit | ) |
#define OPTSET2 | ( | bit, | |
val | |||
) |
#define OPTSET2292 | ( | bit | ) |
#define OPTSET2292_EXCLUSIVE | ( | bit | ) |
#define OPTSET2_N | ( | bit, | |
val | |||
) |
#define PKTOPT_EXTHDRCPY | ( | type | ) |
Definition at line 2736 of file ip6_output.c.
__FBSDID | ( | "$FreeBSD$" | ) |
|
static |
Definition at line 2748 of file ip6_output.c.
References ip6_clearpktopts(), ip6_pktopts::ip6po_flags, ip6_pktopts::ip6po_hlim, ip6_pktopts::ip6po_minmtu, ip6_pktopts::ip6po_pktinfo, ip6_pktopts::ip6po_prefer_tempaddr, ip6po_rthdr, ip6_pktopts::ip6po_tclass, and PKTOPT_EXTHDRCPY.
Referenced by ip6_copypktopts(), and ip6_setpktopts().
void in6_delayed_cksum | ( | struct mbuf * | m, |
uint32_t | plen, | ||
u_short | offset | ||
) |
Definition at line 200 of file ip6_output.c.
Referenced by ip6_output_delayed_csum().
|
static |
Definition at line 1541 of file ip6_output.c.
References IN6_LINKMTU.
Referenced by ip6_getpmtu(), and ip6_getpmtu_ctl().
void ip6_clearpktopts | ( | struct ip6_pktopts * | pktopt, |
int | optname | ||
) |
Definition at line 2687 of file ip6_output.c.
References ip6_pktopts::ip6po_dest1, ip6_pktopts::ip6po_dest2, ip6_pktopts::ip6po_hbh, ip6_pktopts::ip6po_hlim, ip6_pktopts::ip6po_pktinfo, ip6po_rhinfo::ip6po_rhi_rthdr, ip6_pktopts::ip6po_rhinfo, ip6_pktopts::ip6po_tclass, IPV6_DSTOPTS, IPV6_HOPLIMIT, IPV6_HOPOPTS, IPV6_NEXTHOP, IPV6_PKTINFO, IPV6_RTHDR, IPV6_RTHDRDSTOPTS, and IPV6_TCLASS.
Referenced by copypktopts(), ip6_freepcbopts(), ip6_pcbopts(), ip6_setpktopt(), rip6_output(), and udp6_output().
|
static |
Definition at line 1292 of file ip6_output.c.
struct ip6_pktopts * ip6_copypktopts | ( | struct ip6_pktopts * | src, |
int | canwait | ||
) |
Definition at line 2788 of file ip6_output.c.
References copypktopts(), and ip6_initpktopts().
int ip6_ctloutput | ( | struct socket * | so, |
struct sockopt * | sopt | ||
) |
Definition at line 1595 of file ip6_output.c.
References IN6_IS_ADDR_UNSPECIFIED, ip6_getmoptions(), ip6_getpcbopt(), ip6_getpmtu_ctl(), ip6_pcbopt(), ip6_pcbopts(), ip6_setmoptions(), ip6_mtuinfo::ip6m_mtu, IPV6_2292DSTOPTS, IPV6_2292HOPLIMIT, IPV6_2292HOPOPTS, IPV6_2292PKTINFO, IPV6_2292PKTOPTIONS, IPV6_2292RTHDR, IPV6_AUTOFLOWLABEL, IPV6_BINDANY, IPV6_BINDMULTI, IPV6_DONTFRAG, IPV6_DSTOPTS, IPV6_FLOWID, IPV6_FLOWTYPE, IPV6_HOPLIMIT, IPV6_HOPOPTS, IPV6_IPSEC_POLICY, IPV6_JOIN_GROUP, IPV6_LEAVE_GROUP, IPV6_MSFILTER, IPV6_MULTICAST_HOPS, IPV6_MULTICAST_IF, IPV6_MULTICAST_LOOP, IPV6_NEXTHOP, IPV6_ORIGDSTADDR, IPV6_PATHMTU, IPV6_PKTINFO, IPV6_PKTOPTIONS_MBUF_LIMIT, IPV6_PORTRANGE, IPV6_PORTRANGE_DEFAULT, IPV6_PORTRANGE_HIGH, IPV6_PORTRANGE_LOW, IPV6_PREFER_TEMPADDR, IPV6_RECVDSTOPTS, IPV6_RECVFLOWID, IPV6_RECVHOPLIMIT, IPV6_RECVHOPOPTS, IPV6_RECVPATHMTU, IPV6_RECVPKTINFO, IPV6_RECVRSSBUCKETID, IPV6_RECVRTHDR, IPV6_RECVRTHDRDSTOPTS, IPV6_RECVTCLASS, IPV6_RSS_LISTEN_BUCKET, IPV6_RSSBUCKETID, IPV6_RTHDR, IPV6_RTHDRDSTOPTS, IPV6_TCLASS, IPV6_UNICAST_HOPS, IPV6_USE_MIN_MTU, IPV6_V6ONLY, IPV6_VLAN_PCP, OPTBIT, OPTBIT2, OPTSET, OPTSET2, OPTSET2292, OPTSET2292_EXCLUSIVE, and OPTSET2_N.
Referenced by rip6_ctloutput().
int ip6_fragment | ( | struct ifnet * | ifp, |
struct mbuf * | m0, | ||
int | hlen, | ||
u_char | nextproto, | ||
int | fraglen, | ||
uint32_t | id | ||
) |
Definition at line 238 of file ip6_output.c.
References in6_ifstat_inc, ip6_insertfraghdr(), and IP6STAT_INC.
Referenced by ip6_output().
void ip6_freepcbopts | ( | struct ip6_pktopts * | pktopt | ) |
Definition at line 2807 of file ip6_output.c.
References ip6_clearpktopts().
|
static |
Definition at line 2601 of file ip6_output.c.
References GET_PKTOPT_EXT_HDR, GET_PKTOPT_SOCKADDR, in6_clearscope(), IP6PO_DONTFRAG, ip6_pktopts::ip6po_flags, ip6_pktopts::ip6po_minmtu, IP6PO_MINMTU_MCASTONLY, ip6po_nexthop, ip6_pktopts::ip6po_pktinfo, ip6_pktopts::ip6po_prefer_tempaddr, ip6po_rthdr, ip6_pktopts::ip6po_tclass, IP6PO_TEMPADDR_SYSTEM, in6_pktinfo::ipi6_addr, IPV6_DONTFRAG, IPV6_DSTOPTS, IPV6_HOPOPTS, IPV6_NEXTHOP, IPV6_PKTINFO, IPV6_PREFER_TEMPADDR, IPV6_RTHDR, IPV6_RTHDRDSTOPTS, IPV6_TCLASS, and IPV6_USE_MIN_MTU.
Referenced by ip6_ctloutput().
|
static |
Definition at line 1484 of file ip6_output.c.
References fib6_lookup(), IN6_ARE_ADDR_EQUAL, in6_splitscope(), ip6_calcmtu(), sin6, sockaddr_in6::sin6_addr, sockaddr_in6::sin6_family, and sockaddr_in6::sin6_len.
Referenced by ip6_output().
|
static |
Definition at line 1452 of file ip6_output.c.
References fib6_lookup(), in6_splitscope(), and ip6_calcmtu().
Referenced by ip6_ctloutput().
void ip6_initpktopts | ( | struct ip6_pktopts * | opt | ) |
Definition at line 2537 of file ip6_output.c.
References ip6_pktopts::ip6po_hlim, ip6_pktopts::ip6po_minmtu, IP6PO_MINMTU_MCASTONLY, ip6_pktopts::ip6po_prefer_tempaddr, ip6_pktopts::ip6po_tclass, and IP6PO_TEMPADDR_SYSTEM.
Referenced by ip6_copypktopts(), ip6_pcbopt(), ip6_setpktopts(), and mld_init().
|
static |
Definition at line 1317 of file ip6_output.c.
References ip6_exthdrs::ip6e_hbh, ip6_exthdrs::ip6e_ip6, and JUMBOOPTLEN.
Referenced by ip6_output().
|
static |
Definition at line 1405 of file ip6_output.c.
Referenced by ip6_fragment().
void ip6_mloopback | ( | struct ifnet * | ifp, |
struct mbuf * | m | ||
) |
Definition at line 3297 of file ip6_output.c.
References in6_clearscope().
Referenced by ip6_output(), and phyint_send().
int ip6_optlen | ( | struct inpcb * | inp | ) |
Definition at line 3365 of file ip6_output.c.
References elen.
int ip6_output | ( | struct mbuf * | m0, |
struct ip6_pktopts * | opt, | ||
struct route_in6 * | ro, | ||
int | flags, | ||
struct ip6_moptions * | im6o, | ||
struct ifnet ** | ifpp, | ||
struct inpcb * | inp | ||
) |
Definition at line 409 of file ip6_output.c.
References fib6_lookup(), in6_ifaddr::ia_ifa, ifatoia6, IN6_ARE_ADDR_EQUAL, in6_clearscope(), in6_getlinkifnet(), in6_ifawithifp(), in6_ifstat_inc, IN6_IS_ADDR_MC_INTFACELOCAL, IN6_IS_ADDR_MC_LINKLOCAL, IN6_IS_ADDR_MC_NODELOCAL, IN6_IS_ADDR_MULTICAST, IN6_IS_ADDR_UNSPECIFIED, IN6_LINKMTU, in6_localip(), in6_mcast_loop, in6_selectroute(), in6_setscope(), in6_splitscope(), ip6_fragment(), ip6_getpmtu(), ip6_insert_jumboopt(), ip6_mforward, ip6_mloopback(), ip6_notify_pmtu(), ip6_output_delayed_csum(), ip6_output_send(), ip6_process_hopopts(), ip6_randomid(), ip6_splithdr(), ip6_exthdrs::ip6e_dest1, ip6_exthdrs::ip6e_dest2, ip6_exthdrs::ip6e_hbh, ip6_exthdrs::ip6e_ip6, ip6_exthdrs::ip6e_rthdr, ip6_pktopts::ip6po_dest1, ip6_pktopts::ip6po_dest2, IP6PO_DONTFRAG, ip6_pktopts::ip6po_flags, ip6_pktopts::ip6po_hbh, ip6_pktopts::ip6po_hlim, ip6_pktopts::ip6po_minmtu, IP6PO_MINMTU_ALL, IP6PO_MINMTU_DISABLE, ip6_pktopts::ip6po_tclass, IP6STAT_INC, IPV6_FORWARDING, IPV6_MINMTU, IPV6_UNSPECSRC, M_FASTFWD_OURS, M_IP6_NEXTHOP, M_LOOP, M_SKIP_FIREWALL, MAKE_CHAIN, MAKE_EXTHDR, sa6_recoverscope(), sin6, sockaddr_in6::sin6_addr, sockaddr_in6::sin6_family, sockaddr_in6::sin6_len, sockaddr_in6::sin6_scope_id, V_inet6_pfil_head, V_ip6_defmcasthlim, and V_ip6_mrouter.
Referenced by icmp6_redirect_output(), icmp6_reflect(), in6_gif_output(), in6_gre_output(), mld_dispatch_packet(), nd6_na_output_fib(), nd6_ns_output_fib(), phyint_send(), rip6_output(), and udp6_output().
|
static |
Definition at line 216 of file ip6_output.c.
References in6_delayed_cksum().
Referenced by ip6_output().
|
static |
Definition at line 309 of file ip6_output.c.
References nd6_output_ifp().
Referenced by ip6_output().
|
static |
Definition at line 2548 of file ip6_output.c.
References ip6_initpktopts(), and ip6_setpktopt().
Referenced by ip6_ctloutput().
|
static |
Definition at line 2485 of file ip6_output.c.
References ip6_clearpktopts(), ip6_setpktopts(), ip6_pktopts::ip6po_dest1, ip6_pktopts::ip6po_dest2, ip6_pktopts::ip6po_hbh, ip6_pktopts::ip6po_pktinfo, ip6po_rhinfo::ip6po_rhi_rthdr, and ip6_pktopts::ip6po_rhinfo.
Referenced by ip6_ctloutput().
int ip6_raw_ctloutput | ( | struct socket * | so, |
struct sockopt * | sopt | ||
) |
Definition at line 2407 of file ip6_output.c.
References IPV6_CHECKSUM.
Referenced by rip6_ctloutput().
|
static |
Definition at line 2891 of file ip6_output.c.
References in6_ifaddr::ia_ifa, IN6_IS_ADDR_MULTICAST, IN6_IS_ADDR_UNSPECIFIED, in6_setscope(), in6ifa_ifpwithaddr(), ip6_clearpktopts(), ip6_pktopts::ip6po_dest1, ip6_pktopts::ip6po_dest2, IP6PO_DONTFRAG, ip6_pktopts::ip6po_flags, ip6_pktopts::ip6po_hbh, ip6_pktopts::ip6po_hlim, ip6_pktopts::ip6po_minmtu, IP6PO_MINMTU_ALL, IP6PO_MINMTU_DISABLE, IP6PO_MINMTU_MCASTONLY, ip6_pktopts::ip6po_pktinfo, ip6_pktopts::ip6po_prefer_tempaddr, ip6_pktopts::ip6po_tclass, IP6PO_TEMPADDR_NOTPREFER, IP6PO_TEMPADDR_PREFER, IP6PO_TEMPADDR_SYSTEM, in6_pktinfo::ipi6_addr, in6_pktinfo::ipi6_ifindex, IPV6_2292DSTOPTS, IPV6_2292HOPLIMIT, IPV6_2292HOPOPTS, IPV6_2292NEXTHOP, IPV6_2292PKTINFO, IPV6_2292PKTOPTIONS, IPV6_2292RTHDR, IPV6_DONTFRAG, IPV6_DSTOPTS, IPV6_HOPLIMIT, IPV6_HOPOPTS, IPV6_NEXTHOP, IPV6_PKTINFO, IPV6_PREFER_TEMPADDR, IPV6_RTHDR, IPV6_RTHDR_TYPE_0, IPV6_RTHDRDSTOPTS, IPV6_TCLASS, IPV6_USE_MIN_MTU, ND6_IFF_IFDISABLED, ND_IFINFO, sa6_embedscope(), sockaddr_in6::sin6_addr, sockaddr_in6::sin6_len, and V_ip6_use_defzone.
Referenced by ip6_pcbopt(), and ip6_setpktopts().
int ip6_setpktopts | ( | struct mbuf * | control, |
struct ip6_pktopts * | opt, | ||
struct ip6_pktopts * | stickyopt, | ||
struct ucred * | cred, | ||
int | uproto | ||
) |
Definition at line 2821 of file ip6_output.c.
References copypktopts(), ip6_initpktopts(), and ip6_setpktopt().
Referenced by ip6_pcbopts(), rip6_output(), and udp6_output().
|
static |
Definition at line 3336 of file ip6_output.c.
References ip6_exthdrs::ip6e_ip6.
Referenced by ip6_output().
|
static |
|
extern |
Definition at line 186 of file in6_mcast.c.
Referenced by in6p_findmoptions(), ip6_getmoptions(), and ip6_output().