71#include "opt_kern_tls.h"
72#include "opt_ratelimit.h"
78#include <sys/kernel.h>
80#include <sys/malloc.h>
85#include <sys/protosw.h>
86#include <sys/socket.h>
87#include <sys/socketvar.h>
88#include <sys/syslog.h>
91#include <machine/in_cksum.h>
94#include <net/if_var.h>
95#include <net/if_vlan_var.h>
96#include <net/if_llatbl.h>
97#include <net/ethernet.h>
98#include <net/netisr.h>
100#include <net/route/nhop.h>
102#include <net/rss_config.h>
105#include <netinet/in.h>
106#include <netinet/in_var.h>
107#include <netinet/ip_var.h>
110#include <netinet/ip6.h>
111#include <netinet/icmp6.h>
113#include <netinet/in_pcb.h>
114#include <netinet/tcp_var.h>
118#include <netipsec/ipsec_support.h>
119#if defined(SCTP) || defined(SCTP_SUPPORT)
120#include <netinet/sctp.h>
121#include <netinet/sctp_crc32.h>
140 struct ucred *,
int);
142 struct socket *,
struct sockopt *);
143static int ip6_getpcbopt(
struct inpcb *,
int,
struct sockopt *);
145 struct ucred *,
int,
int,
int);
153 struct ifnet *,
const struct in6_addr *, u_long *,
int *, u_int,
156 u_long *,
int *, u_int);
164#define MAKE_EXTHDR(hp, mp, _ol) \
167 struct ip6_ext *eh = (struct ip6_ext *)(hp); \
168 error = ip6_copyexthdr((mp), (caddr_t)(hp), \
169 ((eh)->ip6e_len + 1) << 3); \
172 (_ol) += (*(mp))->m_len; \
183#define MAKE_CHAIN(m, mp, p, i)\
187 panic("%s:%d: assumption failed: "\
188 "hdr not split: hdrsplit %d exthdrs %p",\
189 __func__, __LINE__, hdrsplit, &exthdrs);\
190 *mtod((m), u_char *) = *(p);\
192 p = mtod((m), u_char *);\
193 (m)->m_next = (mp)->m_next;\
204 csum = in_cksum_skip(m, offset + plen, offset);
205 if (m->m_pkthdr.csum_flags & CSUM_UDP_IPV6 && csum == 0)
207 offset += m->m_pkthdr.csum_data;
209 if (offset +
sizeof(csum) > m->m_len)
210 m_copyback(m, offset,
sizeof(csum), (caddr_t)&csum);
212 *(u_short *)mtodo(m, offset) = csum;
217 int plen,
int optlen)
220 KASSERT((plen >= optlen), (
"%s:%d: plen %d < optlen %d, m %p, ifp %p "
222 __func__, __LINE__, plen, optlen, m, ifp, csum_flags));
224 if (csum_flags & CSUM_DELAY_DATA_IPV6) {
226 sizeof(
struct ip6_hdr) + optlen);
227 m->m_pkthdr.csum_flags &= ~CSUM_DELAY_DATA_IPV6;
229#if defined(SCTP) || defined(SCTP_SUPPORT)
230 if (csum_flags & CSUM_SCTP_IPV6) {
231 sctp_delayed_cksum(m,
sizeof(
struct ip6_hdr) + optlen);
232 m->m_pkthdr.csum_flags &= ~CSUM_SCTP_IPV6;
238ip6_fragment(
struct ifnet *ifp,
struct mbuf *m0,
int hlen, u_char nextproto,
239 int fraglen , uint32_t
id)
241 struct mbuf *m, **mnext, *m_frgpart;
242 struct ip6_hdr *ip6, *mhip6;
243 struct ip6_frag *ip6f;
246 int tlen = m0->m_pkthdr.len;
248 KASSERT((fraglen % 8 == 0), (
"Fragment length must be a multiple of 8"));
251 ip6 = mtod(m,
struct ip6_hdr *);
252 mnext = &m->m_nextpkt;
254 for (off = hlen; off < tlen; off += fraglen) {
255 m = m_gethdr(M_NOWAIT, MT_DATA);
268 if (m_dup_pkthdr(m, m0, M_NOWAIT) == 0) {
275 mnext = &m->m_nextpkt;
276 m->m_data += max_linkhdr;
277 mhip6 = mtod(m,
struct ip6_hdr *);
279 m->m_len =
sizeof(*mhip6);
285 ip6f->ip6f_offlg = htons((u_short)((off - hlen) & ~7));
286 if (off + fraglen >= tlen)
287 fraglen = tlen - off;
289 ip6f->ip6f_offlg |= IP6F_MORE_FRAG;
290 mhip6->ip6_plen = htons((u_short)(fraglen + hlen +
291 sizeof(*ip6f) -
sizeof(
struct ip6_hdr)));
292 if ((m_frgpart = m_copym(m0, off, fraglen, M_NOWAIT)) == NULL) {
297 m->m_pkthdr.len = fraglen + hlen +
sizeof(*ip6f);
298 ip6f->ip6f_reserved = 0;
299 ip6f->ip6f_ident = id;
300 ip6f->ip6f_nxt = nextproto;
310 struct mbuf *m,
struct sockaddr_in6 *dst,
struct route_in6 *ro,
314 struct ktls_session *tls = NULL;
316 struct m_snd_tag *mst;
319 MPASS((m->m_pkthdr.csum_flags & CSUM_SND_TAG) == 0);
329 if (m->m_next != NULL && mbuf_has_tls_session(m->m_next)) {
330 tls = ktls_hold(m->m_next->m_epg_tls);
350 if (inp != NULL && mst == NULL) {
351 if ((inp->inp_flags2 & INP_RATE_LIMIT_CHANGED) != 0 ||
352 (inp->inp_snd_tag != NULL &&
353 inp->inp_snd_tag->ifp != ifp))
354 in_pcboutput_txrtlmt(inp, ifp, m);
356 if (inp->inp_snd_tag != NULL)
357 mst = inp->inp_snd_tag;
360 if (stamp_tag && mst != NULL) {
361 KASSERT(m->m_pkthdr.rcvif == NULL,
362 (
"trying to add a send tag to a forwarded packet"));
363 if (mst->ifp != ifp) {
370 m->m_pkthdr.snd_tag = m_snd_tag_ref(mst);
371 m->m_pkthdr.csum_flags |= CSUM_SND_TAG;
381 error = ktls_output_eagain(inp, tls);
387 in_pcboutput_eagain(inp);
410 struct route_in6 *ro,
int flags,
struct ip6_moptions *im6o,
411 struct ifnet **ifpp,
struct inpcb *inp)
414 struct ifnet *ifp, *origifp;
417 struct route_in6 *ro_pmtu;
418 struct nhop_object *nh;
427 int alwaysfrag, dontfrag;
428 u_int32_t optlen, plen = 0, unfragpartlen;
436 struct m_tag *fwd_tag = NULL;
442 INP_LOCK_ASSERT(inp);
443 M_SETFIB(m, inp->inp_inc.inc_fibnum);
444 if ((flags & IP_NODEFAULTFLOWID) == 0) {
446 m->m_pkthdr.flowid = inp->inp_flowid;
447 M_HASHTYPE_SET(m, inp->inp_flowtype);
449 if ((inp->inp_flags2 & INP_2PCP_SET) != 0)
450 vlan_pcp = (inp->inp_flags2 & INP_2PCP_MASK) >>
453 m->m_pkthdr.numa_domain = inp->inp_numa_domain;
457#if defined(IPSEC) || defined(IPSEC_SUPPORT)
463 if (IPSEC_ENABLED(ipv6)) {
464 if ((error = IPSEC_OUTPUT(ipv6, m, inp)) != 0) {
465 if (error == EINPROGRESS)
473 ip6 = mtod(m,
struct ip6_hdr *);
491 bzero(&exthdrs,
sizeof(exthdrs));
493 unfragpartlen =
sizeof(
struct ip6_hdr);
499 if (opt->ip6po_rthdr) {
500#ifndef RTHDR_SUPPORT_IMPLEMENTED
531 unfragpartlen += optlen;
553 ip6 = mtod(m,
struct ip6_hdr *);
558 m->m_pkthdr.len += optlen;
559 plen = m->m_pkthdr.len -
sizeof(*ip6);
562 if (plen > IPV6_MAXPACKET) {
569 ip6 = mtod(m,
struct ip6_hdr *);
576 ip6->ip6_plen = htons(plen);
577 nexthdrp = &ip6->ip6_nxt;
603 panic(
"%s:%d: assumption failed: "
604 "hdr not split: hdrsplit %d exthdrs %p",
605 __func__, __LINE__, hdrsplit, &exthdrs);
608 *mtod(exthdrs.
ip6e_dest2, u_char *) = ip6->ip6_nxt;
609 ip6->ip6_nxt = IPPROTO_DSTOPTS;
628 if (opt && opt->ip6po_rthdr)
629 ro = &opt->ip6po_route;
634 fibnum = (inp != NULL) ? inp->inp_inc.inc_fibnum : M_GETFIB(m);
645 if (IPV6_DSCP(ip6) == 0)
647 if (IPV6_ECN(ip6) == 0)
650 ip6->ip6_flow |= htonl((opt->
ip6po_tclass & mask) << 20);
658 ip6->ip6_hlim = im6o->im6o_multicast_hlim;
663 if (ro == NULL || ro->ro_nh == NULL) {
664 bzero(dst,
sizeof(*dst));
677 if (ro->ro_nh != NULL && inp != NULL) {
678 ro->ro_dst.sin6_family = AF_INET6;
679 NH_VALIDATE((
struct route *)ro, &inp->inp_rt_cookie,
682 if (ro->ro_nh != NULL && fwd_tag == NULL &&
683 (!NH_IS_VALID(ro->ro_nh) ||
684 ro->ro_dst.sin6_family != AF_INET6 ||
686 RO_INVALIDATE_CACHE(ro);
688 if (ro->ro_nh != NULL && fwd_tag == NULL &&
689 ro->ro_dst.sin6_family == AF_INET6 &&
695 LLE_FREE(ro->ro_lle);
697 if (fwd_tag == NULL) {
698 bzero(&dst_sa,
sizeof(dst_sa));
704 &nh, fibnum, m->m_pkthdr.flowid);
721 if (nh->nh_flags & NHF_HOST)
724 counter_u64_add(nh->nh_pksent, 1);
727 struct nhop_object *nh;
731 if (fwd_tag == NULL) {
732 bzero(&dst_sa,
sizeof(dst_sa));
740 (ifp = im6o->im6o_multicast_ifp) != NULL) {
753 error = EHOSTUNREACH;
766 error = EHOSTUNREACH;;
773 if (nh->nh_flags & NHF_GATEWAY)
787 bzero(&src_sa,
sizeof(src_sa));
794 bzero(&dst_sa,
sizeof(dst_sa));
823 if (ia != NULL && ia->ia_ifp)
826 }
else if ((ifp->if_flags & IFF_LOOPBACK) == 0 ||
845 error = EHOSTUNREACH;
851 if (opt && opt->ip6po_nextroute.ro_nh) {
859 else if ((nh->nh_flags & NHF_GATEWAY))
864 m->m_flags &= ~(M_BCAST | M_MCAST);
866 m->m_flags = (m->m_flags & ~M_BCAST) | M_MCAST;
870 if (!(ifp->if_flags & IFF_MULTICAST)) {
877 (im6o && im6o->im6o_multicast_loop)) {
905 m->m_pkthdr.rcvif = NULL;
920 if (ip6->ip6_hlim == 0 || (ifp->if_flags & IFF_LOOPBACK) ||
935 if ((error =
ip6_getpmtu(ro_pmtu, ro != ro_pmtu, ifp, &ip6->ip6_dst,
936 &mtu, &alwaysfrag, fibnum, *nexthdrp)) != 0)
938 KASSERT(mtu > 0, (
"%s:%d: mtu %ld, ro_pmtu %p ro %p ifp %p "
939 "alwaysfrag %d fibnum %u\n", __func__, __LINE__, mtu, ro_pmtu, ro,
940 ifp, alwaysfrag, fibnum));
954 if (mtu > IPV6_MMTU) {
979 struct ip6_hbh *hbh = mtod(exthdrs.
ip6e_hbh,
struct ip6_hbh *);
984 if ((hbh->ip6h_len + 1) << 3 > exthdrs.
ip6e_hbh->m_len)
985 panic(
"ip6e_hbh is not contiguous");
994 m->m_pkthdr.rcvif = ifp;
996 ((hbh->ip6h_len + 1) << 3) -
sizeof(
struct ip6_hbh),
997 &dummy, &plen) < 0) {
1002 m->m_flags &= ~M_LOOP;
1003 m->m_pkthdr.rcvif = NULL;
1010 odst = ip6->ip6_dst;
1014 ip6 = mtod(m,
struct ip6_hdr *);
1030 if (m->m_pkthdr.rcvif == NULL)
1031 m->m_pkthdr.rcvif = V_loif;
1032 if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA_IPV6) {
1033 m->m_pkthdr.csum_flags |=
1034 CSUM_DATA_VALID_IPV6 | CSUM_PSEUDO_HDR;
1035 m->m_pkthdr.csum_data = 0xffff;
1037#if defined(SCTP) || defined(SCTP_SUPPORT)
1038 if (m->m_pkthdr.csum_flags & CSUM_SCTP_IPV6)
1039 m->m_pkthdr.csum_flags |= CSUM_SCTP_VALID;
1041 error = netisr_queue(NETISR_IPV6, m);
1045 RO_INVALIDATE_CACHE(ro);
1050 if (fibnum != M_GETFIB(m)) {
1052 fibnum = M_GETFIB(m);
1054 RO_INVALIDATE_CACHE(ro);
1062 if (m->m_pkthdr.rcvif == NULL)
1063 m->m_pkthdr.rcvif = V_loif;
1064 if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA_IPV6) {
1065 m->m_pkthdr.csum_flags |=
1066 CSUM_DATA_VALID_IPV6 | CSUM_PSEUDO_HDR;
1067 m->m_pkthdr.csum_data = 0xffff;
1069#if defined(SCTP) || defined(SCTP_SUPPORT)
1070 if (m->m_pkthdr.csum_flags & CSUM_SCTP_IPV6)
1071 m->m_pkthdr.csum_flags |= CSUM_SCTP_VALID;
1073 error = netisr_queue(NETISR_IPV6, m);
1078 (fwd_tag = m_tag_find(m, PACKET_TAG_IPFORWARD, NULL)) != NULL) {
1083 bcopy((fwd_tag+1), &dst_sa,
sizeof(
struct sockaddr_in6));
1085 m->m_flags &= ~M_IP6_NEXTHOP;
1086 m_tag_delete(m, fwd_tag);
1092 EVL_APPLY_PRI(m, vlan_pcp);
1095 if ((ifp->if_capenable & IFCAP_MEXTPG) == 0) {
1096 m = mb_unmapped_to_ext(m);
1122 sw_csum = m->m_pkthdr.csum_flags;
1124 tso = ((sw_csum & ifp->if_hwassist &
1125 (CSUM_TSO | CSUM_INNER_TSO)) != 0) ? 1 : 0;
1126 sw_csum &= ~ifp->if_hwassist;
1137 tlen = m->m_pkthdr.len;
1143 if (dontfrag && alwaysfrag) {
1148 if (dontfrag && tlen >
IN6_LINKMTU(ifp) && !tso) {
1164 if (dontfrag || (!alwaysfrag && tlen <= mtu)) {
1167 ip6 = mtod(m,
struct ip6_hdr *);
1171 counter_u64_add(ia6->
ia_ifa.ifa_opackets, 1);
1172 counter_u64_add(ia6->
ia_ifa.ifa_obytes,
1176 (flags & IP_NO_SND_TAG_RL) ?
false :
true);
1181 if (mtu < IPV6_MMTU) {
1186 }
else if (ip6->ip6_plen == 0) {
1199 if (mtu > IPV6_MAXPACKET)
1200 mtu = IPV6_MAXPACKET;
1202 len = (mtu - unfragpartlen -
sizeof(
struct ip6_frag)) & ~7;
1222 nextproto = *mtod(exthdrs.
ip6e_rthdr, u_char *);
1223 *mtod(exthdrs.
ip6e_rthdr, u_char *) = IPPROTO_FRAGMENT;
1225 nextproto = *mtod(exthdrs.
ip6e_dest1, u_char *);
1226 *mtod(exthdrs.
ip6e_dest1, u_char *) = IPPROTO_FRAGMENT;
1228 nextproto = *mtod(exthdrs.
ip6e_hbh, u_char *);
1229 *mtod(exthdrs.
ip6e_hbh, u_char *) = IPPROTO_FRAGMENT;
1231 ip6 = mtod(m,
struct ip6_hdr *);
1232 nextproto = ip6->ip6_nxt;
1233 ip6->ip6_nxt = IPPROTO_FRAGMENT;
1243 error =
ip6_fragment(ifp, m, unfragpartlen, nextproto,len,
id);
1261 counter_u64_add(ia->
ia_ifa.ifa_opackets, 1);
1262 counter_u64_add(ia->
ia_ifa.ifa_obytes,
1266 EVL_APPLY_PRI(m, vlan_pcp);
1296 if (hlen > MCLBYTES)
1300 m = m_getcl(M_NOWAIT, MT_DATA, 0);
1302 m = m_get(M_NOWAIT, MT_DATA);
1307 bcopy(hdr, mtod(m, caddr_t), hlen);
1323#define JUMBOOPTLEN 8
1332 mopt = m_get(M_NOWAIT, MT_DATA);
1336 optbuf = mtod(mopt, u_char *);
1340 struct ip6_hbh *hbh;
1350 int oldoptlen = mopt->m_len;
1364 n = m_getcl(M_NOWAIT, MT_DATA, 0);
1368 bcopy(mtod(mopt, caddr_t), mtod(n, caddr_t),
1370 optbuf = mtod(n, caddr_t) + oldoptlen;
1374 optbuf = mtod(mopt, u_char *) + mopt->m_len;
1377 optbuf[0] = IP6OPT_PADN;
1384 hbh = mtod(mopt,
struct ip6_hbh *);
1389 optbuf[2] = IP6OPT_JUMBO;
1392 bcopy(&v, &optbuf[4],
sizeof(u_int32_t));
1406 struct ip6_frag **frghdrp)
1408 struct mbuf *n, *mlast;
1410 if (hlen >
sizeof(
struct ip6_hdr)) {
1411 n = m_copym(m0,
sizeof(
struct ip6_hdr),
1412 hlen -
sizeof(
struct ip6_hdr), M_NOWAIT);
1420 for (mlast = n; mlast->m_next; mlast = mlast->m_next)
1423 if (M_WRITABLE(mlast) &&
1424 M_TRAILINGSPACE(mlast) >=
sizeof(
struct ip6_frag)) {
1426 *frghdrp = (
struct ip6_frag *)(mtod(mlast, caddr_t) +
1428 mlast->m_len +=
sizeof(
struct ip6_frag);
1429 m->m_pkthdr.len +=
sizeof(
struct ip6_frag);
1434 mfrg = m_get(M_NOWAIT, MT_DATA);
1437 mfrg->m_len =
sizeof(
struct ip6_frag);
1438 *frghdrp = mtod(mfrg,
struct ip6_frag *);
1439 mlast->m_next = mfrg;
1454 struct epoch_tracker et;
1455 struct nhop_object *nh;
1462 NET_EPOCH_ENTER(et);
1463 nh =
fib6_lookup(fibnum, &kdst, scopeid, NHR_NONE, 0);
1465 error =
ip6_calcmtu(nh->nh_ifp, dst, nh->nh_mtu, mtup, NULL, 0);
1467 error = EHOSTUNREACH;
1485 struct ifnet *ifp,
const struct in6_addr *dst, u_long *mtup,
1486 int *alwaysfragp, u_int fibnum, u_int proto)
1488 struct nhop_object *nh;
1497 if (ro_pmtu == NULL || do_lookup) {
1503 if (ro_pmtu != NULL) {
1506 ro_pmtu->ro_mtu = 0;
1510 if (ro_pmtu == NULL || ro_pmtu->ro_mtu == 0) {
1511 bzero(sa6_dst,
sizeof(*sa6_dst));
1517 nh =
fib6_lookup(fibnum, &kdst, scopeid, NHR_NONE, 0);
1520 if (ro_pmtu != NULL)
1521 ro_pmtu->ro_mtu = mtu;
1524 mtu = ro_pmtu->ro_mtu;
1527 if (ro_pmtu != NULL && ro_pmtu->ro_nh != NULL)
1528 mtu = ro_pmtu->ro_nh->nh_mtu;
1530 return (
ip6_calcmtu(ifp, dst, mtu, mtup, alwaysfragp, proto));
1542 u_long *mtup,
int *alwaysfragp, u_int proto)
1550 struct in_conninfo inc;
1552 bzero(&inc,
sizeof(inc));
1553 inc.inc_flags |= INC_ISIPV6;
1554 inc.inc6_faddr = *dst;
1559 if (proto != IPPROTO_TCP)
1560 mtu = tcp_hc_getmtu(&inc);
1563 mtu = min(mtu, rt_mtu);
1568 else if (mtu < IPV6_MMTU) {
1583 error = EHOSTUNREACH;
1587 *alwaysfragp = alwaysfrag;
1597 int optdatalen, uproto;
1599 struct inpcb *inp = sotoinpcb(so);
1601 int level, op, optname;
1605 uint32_t rss_bucket;
1616#define IPV6_PKTOPTIONS_MBUF_LIMIT ((u_long)nmbclusters * MCLBYTES / 4)
1618 level = sopt->sopt_level;
1619 op = sopt->sopt_dir;
1620 optname = sopt->sopt_name;
1621 optlen = sopt->sopt_valsize;
1625 uproto = (int)so->so_proto->pr_protocol;
1627 if (level != IPPROTO_IPV6) {
1630 if (sopt->sopt_level == SOL_SOCKET &&
1631 sopt->sopt_dir == SOPT_SET) {
1632 switch (sopt->sopt_name) {
1635 if ((so->so_options & SO_REUSEADDR) != 0)
1636 inp->inp_flags2 |= INP_REUSEADDR;
1638 inp->inp_flags2 &= ~INP_REUSEADDR;
1644 if ((so->so_options & SO_REUSEPORT) != 0)
1645 inp->inp_flags2 |= INP_REUSEPORT;
1647 inp->inp_flags2 &= ~INP_REUSEPORT;
1651 case SO_REUSEPORT_LB:
1653 if ((so->so_options & SO_REUSEPORT_LB) != 0)
1654 inp->inp_flags2 |= INP_REUSEPORT_LB;
1656 inp->inp_flags2 &= ~INP_REUSEPORT_LB;
1662 inp->inp_inc.inc_fibnum = so->so_fibnum;
1666 case SO_MAX_PACING_RATE:
1669 inp->inp_flags2 |= INP_RATE_LIMIT_CHANGED;
1685#ifdef IPV6_PKTOPTIONS
1686 case IPV6_PKTOPTIONS:
1692 printf(
"ip6_ctloutput: mbuf limit hit\n");
1697 error = soopt_getm(sopt, &m);
1700 error = soopt_mcopyin(sopt, m);
1728 error = priv_check(td,
1729 PRIV_NETINET_SETHDROPTS);
1756 error = priv_check(td,
1757 PRIV_NETINET_BINDANY);
1762 if (optlen !=
sizeof(
int)) {
1766 error = sooptcopyin(sopt, &optval,
1767 sizeof optval,
sizeof optval);
1772 if (optval < -1 || optval >= 256)
1776 inp->in6p_hops = optval;
1777 if ((inp->inp_vflag &
1779 inp->inp_ip_ttl = optval;
1782#define OPTSET(bit) \
1786 inp->inp_flags |= (bit); \
1788 inp->inp_flags &= ~(bit); \
1791#define OPTSET2292(bit) \
1794 inp->inp_flags |= IN6P_RFC2292; \
1796 inp->inp_flags |= (bit); \
1798 inp->inp_flags &= ~(bit); \
1801#define OPTBIT(bit) (inp->inp_flags & (bit) ? 1 : 0)
1803#define OPTSET2_N(bit, val) do { \
1805 inp->inp_flags2 |= bit; \
1807 inp->inp_flags2 &= ~bit; \
1809#define OPTSET2(bit, val) do { \
1811 OPTSET2_N(bit, val); \
1814#define OPTBIT2(bit) (inp->inp_flags2 & (bit) ? 1 : 0)
1815#define OPTSET2292_EXCLUSIVE(bit) \
1818 if (OPTBIT(IN6P_RFC2292)) { \
1822 inp->inp_flags |= (bit); \
1824 inp->inp_flags &= ~(bit); \
1838 if (
OPTBIT(IN6P_RFC2292)) {
1843 if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) {
1845 return (ECONNRESET);
1847 optp = &inp->in6p_outputopts;
1849 (u_char *)&optval,
sizeof(optval),
1850 optp, (td != NULL) ? td->td_ucred :
1883 if (uproto != IPPROTO_TCP)
1888 OPTSET2(INP_RECVFLOWID, optval);
1893 OPTSET2(INP_RECVRSSBUCKETID, optval);
1899 if (inp->inp_lport ||
1909 inp->inp_flags |= IN6P_IPV6_V6ONLY;
1910 inp->inp_vflag &= ~INP_IPV4;
1912 inp->inp_flags &= ~IN6P_IPV6_V6ONLY;
1913 inp->inp_vflag |= INP_IPV4;
1922 OPTSET(IN6P_AUTOFLOWLABEL);
1926 OPTSET2(INP_ORIGDSTADDR, optval);
1933 OPTSET2(INP_BINDMULTI, optval);
1937 if ((optval >= 0) &&
1938 (optval < rss_getnumbuckets())) {
1940 inp->inp_rss_listen_bucket = optval;
1949 if ((optval >= -1) && (optval <=
1950 (INP_2PCP_MASK >> INP_2PCP_SHIFT))) {
1978 if (optlen !=
sizeof(optval)) {
1982 error = sooptcopyin(sopt, &optval,
1983 sizeof optval,
sizeof optval);
1989 if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) {
1991 return (ECONNRESET);
1993 optp = &inp->in6p_outputopts;
1995 (u_char *)&optval,
sizeof(optval),
1996 optp, (td != NULL) ? td->td_ucred :
2008 if (optlen !=
sizeof(
int)) {
2012 error = sooptcopyin(sopt, &optval,
2013 sizeof optval,
sizeof optval);
2029 error = priv_check(td,
2030 PRIV_NETINET_SETHDROPTS);
2038 error = priv_check(td,
2039 PRIV_NETINET_SETHDROPTS);
2059 u_char optbuf_storage[MCLBYTES];
2064 if (
OPTBIT(IN6P_RFC2292)) {
2074 error = sooptcopyin(sopt, optbuf_storage,
2075 sizeof(optbuf_storage), 0);
2078 optlen = sopt->sopt_valsize;
2079 optbuf = optbuf_storage;
2081 if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) {
2083 return (ECONNRESET);
2085 optp = &inp->in6p_outputopts;
2087 optp, (td != NULL) ? td->td_ucred : NULL,
2100 case MCAST_BLOCK_SOURCE:
2101 case MCAST_UNBLOCK_SOURCE:
2102 case MCAST_JOIN_GROUP:
2103 case MCAST_LEAVE_GROUP:
2104 case MCAST_JOIN_SOURCE_GROUP:
2105 case MCAST_LEAVE_SOURCE_GROUP:
2110 error = sooptcopyin(sopt, &optval,
2111 sizeof optval,
sizeof optval);
2118 inp->inp_flags &= ~(INP_LOWPORT);
2119 inp->inp_flags &= ~(INP_HIGHPORT);
2123 inp->inp_flags &= ~(INP_LOWPORT);
2124 inp->inp_flags |= INP_HIGHPORT;
2128 inp->inp_flags &= ~(INP_HIGHPORT);
2129 inp->inp_flags |= INP_LOWPORT;
2139#if defined(IPSEC) || defined(IPSEC_SUPPORT)
2141 if (IPSEC_ENABLED(ipv6)) {
2142 error = IPSEC_PCBCTL(ipv6, inp, sopt);
2149 error = ENOPROTOOPT;
2157#ifdef IPV6_PKTOPTIONS
2158 case IPV6_PKTOPTIONS:
2169 sopt->sopt_valsize = 0;
2197 optval =
OPTBIT(IN6P_HOPOPTS);
2201 optval =
OPTBIT(IN6P_DSTOPTS);
2205 optval =
OPTBIT(IN6P_RTHDRDSTOPTS);
2209 optval = inp->in6p_hops;
2213 optval =
OPTBIT(IN6P_PKTINFO);
2217 optval =
OPTBIT(IN6P_HOPLIMIT);
2221 optval =
OPTBIT(IN6P_RTHDR);
2225 optval =
OPTBIT(IN6P_MTU);
2229 optval =
OPTBIT(IN6P_IPV6_V6ONLY);
2235 flags = inp->inp_flags;
2236 if (flags & INP_HIGHPORT)
2238 else if (flags & INP_LOWPORT)
2245 optval =
OPTBIT(IN6P_TCLASS);
2249 optval =
OPTBIT(IN6P_AUTOFLOWLABEL);
2253 optval =
OPTBIT2(INP_ORIGDSTADDR);
2257 optval =
OPTBIT(INP_BINDANY);
2261 optval = inp->inp_flowid;
2265 optval = inp->inp_flowtype;
2269 optval =
OPTBIT2(INP_RECVFLOWID);
2274 rss_hash2bucket(inp->inp_flowid,
2278 optval = rss_bucket;
2284 optval =
OPTBIT2(INP_RECVRSSBUCKETID);
2289 optval =
OPTBIT2(INP_BINDMULTI);
2294 optval = (inp->inp_flags2 &
2305 error = sooptcopyout(sopt, &optval,
2315 if (!(so->so_state & SS_ISCONNECTED))
2325 bcopy(&inp->in6p_faddr, &addr,
sizeof(addr));
2331 if (pmtu > IPV6_MAXPACKET)
2332 pmtu = IPV6_MAXPACKET;
2334 bzero(&mtuinfo,
sizeof(mtuinfo));
2335 mtuinfo.
ip6m_mtu = (u_int32_t)pmtu;
2336 optdata = (
void *)&mtuinfo;
2337 optdatalen =
sizeof(mtuinfo);
2338 error = sooptcopyout(sopt, optdata,
2350 optval =
OPTBIT(IN6P_PKTINFO);
2353 optval =
OPTBIT(IN6P_HOPLIMIT);
2356 optval =
OPTBIT(IN6P_HOPOPTS);
2359 optval =
OPTBIT(IN6P_RTHDR);
2362 optval =
OPTBIT(IN6P_DSTOPTS|IN6P_RTHDRDSTOPTS);
2365 error = sooptcopyout(sopt, &optval,
2388#if defined(IPSEC) || defined(IPSEC_SUPPORT)
2390 if (IPSEC_ENABLED(ipv6)) {
2391 error = IPSEC_PCBCTL(ipv6, inp, sopt);
2397 error = ENOPROTOOPT;
2409 int error = 0, optval, optlen;
2410 const int icmp6off = offsetof(
struct icmp6_hdr, icmp6_cksum);
2411 struct inpcb *inp = sotoinpcb(so);
2412 int level, op, optname;
2414 level = sopt->sopt_level;
2415 op = sopt->sopt_dir;
2416 optname = sopt->sopt_name;
2417 optlen = sopt->sopt_valsize;
2419 if (level != IPPROTO_IPV6) {
2435 if (optlen !=
sizeof(
int)) {
2439 error = sooptcopyin(sopt, &optval,
sizeof(optval),
2443 if (optval < -1 || (optval % 2) != 0) {
2449 }
else if (so->so_proto->pr_protocol ==
2451 if (optval != icmp6off)
2454 inp->in6p_cksum = optval;
2458 if (so->so_proto->pr_protocol == IPPROTO_ICMPV6)
2461 optval = inp->in6p_cksum;
2463 error = sooptcopyout(sopt, &optval,
sizeof(optval));
2473 error = ENOPROTOOPT;
2486 struct socket *so,
struct sockopt *sopt)
2490 struct thread *td = sopt->sopt_td;
2491 struct epoch_tracker et;
2499 printf(
"ip6_pcbopts: all specified options are cleared.\n");
2503 opt = malloc(
sizeof(*opt), M_IP6OPT, M_NOWAIT);
2509 if (!m || m->m_len == 0) {
2514 free(opt, M_IP6OPT);
2519 NET_EPOCH_ENTER(et);
2521 td->td_ucred : NULL, so->so_proto->pr_protocol)) != 0) {
2523 free(opt, M_IP6OPT);
2540 bzero(opt,
sizeof(*opt));
2549 struct ucred *cred,
int uproto)
2551 struct epoch_tracker et;
2555 if (*pktopt == NULL) {
2556 *pktopt = malloc(
sizeof(
struct ip6_pktopts), M_IP6OPT,
2558 if (*pktopt == NULL)
2564 NET_EPOCH_ENTER(et);
2565 ret =
ip6_setpktopt(optname, buf, len, opt, cred, 1, 0, uproto);
2571#define GET_PKTOPT_VAR(field, lenexpr) do { \
2572 if (pktopt && pktopt->field) { \
2574 optdata = malloc(sopt->sopt_valsize, M_TEMP, M_WAITOK); \
2575 malloc_optdata = true; \
2577 if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { \
2579 free(optdata, M_TEMP); \
2580 return (ECONNRESET); \
2582 pktopt = inp->in6p_outputopts; \
2583 if (pktopt && pktopt->field) { \
2584 optdatalen = min(lenexpr, sopt->sopt_valsize); \
2585 bcopy(pktopt->field, optdata, optdatalen); \
2587 free(optdata, M_TEMP); \
2589 malloc_optdata = false; \
2594#define GET_PKTOPT_EXT_HDR(field) GET_PKTOPT_VAR(field, \
2595 (((struct ip6_ext *)pktopt->field)->ip6e_len + 1) << 3)
2597#define GET_PKTOPT_SOCKADDR(field) GET_PKTOPT_VAR(field, \
2598 pktopt->field->sa_len)
2603 void *optdata = NULL;
2604 bool malloc_optdata =
false;
2608 int deftclass = 0, on;
2614 pktopt = inp->in6p_outputopts;
2618 optdata = (
void *)&null_pktinfo;
2621 sizeof(null_pktinfo));
2625 bzero(&null_pktinfo,
sizeof(null_pktinfo));
2632 optdata = (
void *)&deftclass;
2633 optdatalen =
sizeof(int);
2653 optdata = (
void *)&defminmtu;
2654 optdatalen =
sizeof(int);
2661 optdata = (
void *)&on;
2662 optdatalen =
sizeof(on);
2667 optdata = (
void *)&defpreftemp;
2668 optdatalen =
sizeof(int);
2672 panic(
"ip6_getpcbopt: unexpected option\n");
2675 return (ENOPROTOOPT);
2679 error = sooptcopyout(sopt, optdata, optdatalen);
2681 free(optdata, M_TEMP);
2702 if (pktopt->ip6po_nextroute.ro_nh) {
2703 NH_FREE(pktopt->ip6po_nextroute.ro_nh);
2704 pktopt->ip6po_nextroute.ro_nh = NULL;
2706 if (pktopt->ip6po_nexthop)
2707 free(pktopt->ip6po_nexthop, M_IP6OPT);
2708 pktopt->ip6po_nexthop = NULL;
2720 if (optname == -1 || optname ==
IPV6_RTHDR) {
2724 if (pktopt->ip6po_route.ro_nh) {
2725 NH_FREE(pktopt->ip6po_route.ro_nh);
2726 pktopt->ip6po_route.ro_nh = NULL;
2736#define PKTOPT_EXTHDRCPY(type) \
2739 int hlen = (((struct ip6_ext *)src->type)->ip6e_len + 1) << 3;\
2740 dst->type = malloc(hlen, M_IP6OPT, canwait);\
2741 if (dst->type == NULL)\
2743 bcopy(src->type, dst->type, hlen);\
2750 if (dst == NULL || src == NULL) {
2751 printf(
"ip6_clearpktopts: invalid argument\n");
2767 if (src->ip6po_nexthop) {
2768 dst->ip6po_nexthop = malloc(src->ip6po_nexthop->sa_len,
2770 if (dst->ip6po_nexthop == NULL)
2772 bcopy(src->ip6po_nexthop, dst->ip6po_nexthop,
2773 src->ip6po_nexthop->sa_len);
2785#undef PKTOPT_EXTHDRCPY
2793 dst = malloc(
sizeof(*dst), M_IP6OPT, canwait);
2798 if ((error =
copypktopts(dst, src, canwait)) != 0) {
2799 free(dst, M_IP6OPT);
2814 free(pktopt, M_IP6OPT);
2822 struct ip6_pktopts *stickyopt,
struct ucred *cred,
int uproto)
2824 struct cmsghdr *cm = NULL;
2826 if (control == NULL || opt == NULL)
2848 if ((error =
copypktopts(opt, stickyopt, M_NOWAIT)) != 0)
2856 if (control->m_next)
2859 for (; control->m_len > 0; control->m_data += CMSG_ALIGN(cm->cmsg_len),
2860 control->m_len -= CMSG_ALIGN(cm->cmsg_len)) {
2863 if (control->m_len < CMSG_LEN(0))
2866 cm = mtod(control,
struct cmsghdr *);
2867 if (cm->cmsg_len == 0 || cm->cmsg_len > control->m_len)
2869 if (cm->cmsg_level != IPPROTO_IPV6)
2873 cm->cmsg_len - CMSG_LEN(0), opt, cred, 0, 1, uproto);
2892 struct ucred *cred,
int sticky,
int cmsg,
int uproto)
2894 int minmtupolicy, preftemp;
2899 if (!sticky && !cmsg) {
2901 printf(
"ip6_setpktopt: impossible case\n");
2920 return (ENOPROTOOPT);
2923 if (sticky && cmsg) {
2936 return (ENOPROTOOPT);
2944 struct ifnet *ifp = NULL;
2965 if (uproto == IPPROTO_TCP && optname ==
IPV6_PKTINFO &&
2977 if (ifp != NULL && (ifp->if_afdata[AF_INET6] == NULL ||
2988 return (EADDRNOTAVAIL);
3003 M_IP6OPT, M_NOWAIT);
3021 return (ENOPROTOOPT);
3023 if (len !=
sizeof(
int))
3026 if (*hlimp < -1 || *hlimp > 255)
3037 if (len !=
sizeof(
int))
3039 tclass = *(
int *)buf;
3040 if (tclass < -1 || tclass > 255)
3050 error = priv_check_cred(cred, PRIV_NETINET_SETHDROPTS);
3061 if (len <
sizeof(
struct sockaddr) || len < *buf)
3064 switch (((
struct sockaddr *)buf)->sa_family) {
3085 return (EAFNOSUPPORT);
3090 opt->ip6po_nexthop = malloc(*buf, M_IP6OPT, M_NOWAIT);
3091 if (opt->ip6po_nexthop == NULL)
3093 bcopy(buf, opt->ip6po_nexthop, *buf);
3099 struct ip6_hbh *hbh;
3108 error = priv_check_cred(cred, PRIV_NETINET_SETHDROPTS);
3119 if (len <
sizeof(
struct ip6_hbh))
3121 hbh = (
struct ip6_hbh *)buf;
3122 hbhlen = (hbh->ip6h_len + 1) << 3;
3128 opt->
ip6po_hbh = malloc(hbhlen, M_IP6OPT, M_NOWAIT);
3140 struct ip6_dest *dest, **newdest = NULL;
3144 error = priv_check_cred(cred, PRIV_NETINET_SETHDROPTS);
3155 if (len <
sizeof(
struct ip6_dest))
3157 dest = (
struct ip6_dest *)buf;
3158 destlen = (dest->ip6d_len + 1) << 3;
3180 if (opt->ip6po_rthdr == NULL)
3195 *newdest = malloc(destlen, M_IP6OPT, M_NOWAIT);
3196 if (*newdest == NULL)
3198 bcopy(dest, *newdest, destlen);
3206 struct ip6_rthdr *rth;
3215 if (len <
sizeof(
struct ip6_rthdr))
3217 rth = (
struct ip6_rthdr *)buf;
3218 rthlen = (rth->ip6r_len + 1) << 3;
3222 switch (rth->ip6r_type) {
3224 if (rth->ip6r_len == 0)
3226 if (rth->ip6r_len % 2)
3228 if (rth->ip6r_len / 2 != rth->ip6r_segleft)
3237 opt->ip6po_rthdr = malloc(rthlen, M_IP6OPT, M_NOWAIT);
3238 if (opt->ip6po_rthdr == NULL)
3240 bcopy(rth, opt->ip6po_rthdr, rthlen);
3246 if (len !=
sizeof(
int))
3248 minmtupolicy = *(
int *)buf;
3258 if (len !=
sizeof(
int))
3261 if (uproto == IPPROTO_TCP || *(
int *)buf == 0) {
3272 if (len !=
sizeof(
int))
3274 preftemp = *(
int *)buf;
3284 return (ENOPROTOOPT);
3300 struct ip6_hdr *ip6;
3302 copym = m_copym(m, 0, M_COPYALL, M_NOWAIT);
3311 if (!M_WRITABLE(copym) ||
3312 copym->m_len <
sizeof(
struct ip6_hdr)) {
3313 copym = m_pullup(copym,
sizeof(
struct ip6_hdr));
3317 ip6 = mtod(copym,
struct ip6_hdr *);
3324 if (copym->m_pkthdr.csum_flags & CSUM_DELAY_DATA_IPV6) {
3325 copym->m_pkthdr.csum_flags |= CSUM_DATA_VALID_IPV6 |
3327 copym->m_pkthdr.csum_data = 0xffff;
3329 if_simloop(ifp, copym, AF_INET6, 0);
3339 struct ip6_hdr *ip6;
3341 ip6 = mtod(m,
struct ip6_hdr *);
3342 if (m->m_len >
sizeof(*ip6)) {
3343 mh = m_gethdr(M_NOWAIT, MT_DATA);
3348 m_move_pkthdr(mh, m);
3349 M_ALIGN(mh,
sizeof(*ip6));
3350 m->m_len -=
sizeof(*ip6);
3351 m->m_data +=
sizeof(*ip6);
3354 m->m_len =
sizeof(*ip6);
3355 bcopy((caddr_t)ip6, mtod(m, caddr_t),
sizeof(*ip6));
3369 if (!inp->in6p_outputopts)
3374 (((struct ip6_ext *)(x)) ? (((struct ip6_ext *)(x))->ip6e_len + 1) << 3 : 0)
3376 len +=
elen(inp->in6p_outputopts->ip6po_hbh);
3377 if (inp->in6p_outputopts->ip6po_rthdr)
3379 len +=
elen(inp->in6p_outputopts->ip6po_dest1);
3380 len +=
elen(inp->in6p_outputopts->ip6po_rthdr);
3381 len +=
elen(inp->in6p_outputopts->ip6po_dest2);
struct in6_ifaddr * in6_ifawithifp(struct ifnet *ifp, struct in6_addr *dst)
int in6_localip(struct in6_addr *in6)
struct in6_ifaddr * in6ifa_ifpwithaddr(struct ifnet *ifp, const struct in6_addr *addr)
#define IPV6_RTHDR_TYPE_0
#define IPV6_PORTRANGE_HIGH
#define IPV6_PORTRANGE_LOW
#define IPV6_IPSEC_POLICY
#define IPV6_AUTOFLOWLABEL
#define IPV6_MULTICAST_LOOP
#define IPV6_RECVRTHDRDSTOPTS
#define IPV6_UNICAST_HOPS
#define IN6_IS_ADDR_MC_LINKLOCAL(a)
#define IN6_IS_ADDR_UNSPECIFIED(a)
#define IPV6_2292PKTOPTIONS
#define IPV6_PORTRANGE_DEFAULT
#define IPV6_MULTICAST_HOPS
#define IPV6_2292HOPLIMIT
#define IN6_ARE_ADDR_EQUAL(a, b)
#define IPV6_PREFER_TEMPADDR
#define IPV6_RSS_LISTEN_BUCKET
#define IPV6_RTHDRDSTOPTS
#define IN6_IS_ADDR_MULTICAST(a)
#define IN6_IS_ADDR_MC_INTFACELOCAL(a)
#define IN6_IS_ADDR_MC_NODELOCAL(a)
#define IPV6_RECVRSSBUCKETID
#define IPV6_MULTICAST_IF
#define IPV6_RECVHOPLIMIT
struct nhop_object * fib6_lookup(uint32_t fibnum, const struct in6_addr *dst6, uint32_t scopeid, uint32_t flags, uint32_t flowid)
int ip6_getmoptions(struct inpcb *inp, struct sockopt *sopt)
int ip6_setmoptions(struct inpcb *inp, struct sockopt *sopt)
int in6_selectroute(struct sockaddr_in6 *dstsock, struct ip6_pktopts *opts, struct ip6_moptions *mopts, struct route_in6 *ro, struct ifnet **retifp, struct nhop_object **retnh, u_int fibnum, uint32_t flowid)
#define in6_ifstat_inc(ifp, tag)
u_int32_t ip6_randomid(void)
static struct sockaddr_in6 sin6
static int ip6_copyexthdr(struct mbuf **, caddr_t, int)
#define OPTSET2292_EXCLUSIVE(bit)
#define GET_PKTOPT_EXT_HDR(field)
static int ip6_pcbopts(struct ip6_pktopts **, struct mbuf *, struct socket *, struct sockopt *)
void ip6_clearpktopts(struct ip6_pktopts *pktopt, int optname)
int ip6_fragment(struct ifnet *ifp, struct mbuf *m0, int hlen, u_char nextproto, int fraglen, uint32_t id)
void in6_delayed_cksum(struct mbuf *m, uint32_t plen, u_short offset)
static MALLOC_DEFINE(M_IP6OPT, "ip6opt", "IPv6 options")
void ip6_mloopback(struct ifnet *ifp, struct mbuf *m)
int ip6_ctloutput(struct socket *so, struct sockopt *sopt)
static int ip6_setpktopt(int, u_char *, int, struct ip6_pktopts *, struct ucred *, int, int, int)
static int ip6_pcbopt(int, u_char *, int, struct ip6_pktopts **, struct ucred *, int)
static int copypktopts(struct ip6_pktopts *, struct ip6_pktopts *, int)
#define MAKE_CHAIN(m, mp, p, i)
void ip6_initpktopts(struct ip6_pktopts *opt)
int ip6_optlen(struct inpcb *inp)
#define GET_PKTOPT_SOCKADDR(field)
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)
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)
void ip6_freepcbopts(struct ip6_pktopts *pktopt)
#define OPTSET2(bit, val)
int ip6_setpktopts(struct mbuf *control, struct ip6_pktopts *opt, struct ip6_pktopts *stickyopt, struct ucred *cred, int uproto)
struct ip6_pktopts * ip6_copypktopts(struct ip6_pktopts *src, int canwait)
#define PKTOPT_EXTHDRCPY(type)
static void ip6_output_delayed_csum(struct mbuf *m, struct ifnet *ifp, int csum_flags, int plen, int optlen)
static int ip6_getpmtu_ctl(u_int, const struct in6_addr *, u_long *)
static int ip6_getpcbopt(struct inpcb *, int, struct sockopt *)
#define MAKE_EXTHDR(hp, mp, _ol)
#define OPTSET2_N(bit, val)
static int ip6_splithdr(struct mbuf *, struct ip6_exthdrs *)
static int ip6_insert_jumboopt(struct ip6_exthdrs *, u_int32_t)
static int ip6_getpmtu(struct route_in6 *, int, struct ifnet *, const struct in6_addr *, u_long *, int *, u_int, u_int)
#define IPV6_PKTOPTIONS_MBUF_LIMIT
static int ip6_insertfraghdr(struct mbuf *, struct mbuf *, int, struct ip6_frag **)
static int ip6_calcmtu(struct ifnet *, const struct in6_addr *, u_long, u_long *, int *, u_int)
int ip6_raw_ctloutput(struct socket *so, struct sockopt *sopt)
#define IP6PO_MINMTU_DISABLE
#define IP6STAT_INC(name)
#define IP6PO_TEMPADDR_SYSTEM
#define V_inet6_pfil_head
#define V_ip6_defmcasthlim
#define IP6PO_MINMTU_MCASTONLY
#define V_ip6_use_defzone
#define IP6PO_TEMPADDR_PREFER
int(* ip6_mforward)(struct ip6_hdr *, struct ifnet *, struct mbuf *)
#define IP6PO_TEMPADDR_NOTPREFER
int nd6_output_ifp(struct ifnet *ifp, struct ifnet *origifp, struct mbuf *m, struct sockaddr_in6 *dst, struct route *ro)
#define ND6_IFF_IFDISABLED
int in6_setscope(struct in6_addr *in6, struct ifnet *ifp, u_int32_t *ret_id)
void in6_splitscope(const struct in6_addr *src, struct in6_addr *dst, uint32_t *scopeid)
struct ifnet * in6_getlinkifnet(uint32_t zoneid)
int in6_clearscope(struct in6_addr *in6)
int sa6_embedscope(struct sockaddr_in6 *sin6, int defaultok)
int sa6_recoverscope(struct sockaddr_in6 *sin6)
struct in6_addr ipi6_addr
unsigned int ipi6_ifindex
struct ip6_hbh * ip6po_hbh
struct ip6po_rhinfo ip6po_rhinfo
int ip6po_prefer_tempaddr
struct in6_pktinfo * ip6po_pktinfo
struct ip6_dest * ip6po_dest2
struct ip6_dest * ip6po_dest1
struct ip6_rthdr * ip6po_rhi_rthdr
struct in6_addr sin6_addr