version 1.149.4.10, 2017/02/05 13:40:59 |
version 1.149.4.11, 2017/08/28 17:53:12 |
Line 69 __KERNEL_RCSID(0, "$NetBSD$"); |
|
Line 69 __KERNEL_RCSID(0, "$NetBSD$"); |
|
#include "opt_inet.h" |
#include "opt_inet.h" |
#include "opt_inet6.h" |
#include "opt_inet6.h" |
#include "opt_ipsec.h" |
#include "opt_ipsec.h" |
#include "opt_compat_netbsd.h" |
|
#include "opt_net_mpsafe.h" |
#include "opt_net_mpsafe.h" |
#endif |
#endif |
|
|
#include <sys/param.h> |
#include <sys/param.h> |
#include <sys/systm.h> |
#include <sys/systm.h> |
#include <sys/malloc.h> |
|
#include <sys/mbuf.h> |
#include <sys/mbuf.h> |
#include <sys/domain.h> |
#include <sys/domain.h> |
#include <sys/protosw.h> |
#include <sys/protosw.h> |
Line 121 __KERNEL_RCSID(0, "$NetBSD$"); |
|
Line 119 __KERNEL_RCSID(0, "$NetBSD$"); |
|
#include <netipsec/key.h> |
#include <netipsec/key.h> |
#endif /* IPSEC */ |
#endif /* IPSEC */ |
|
|
#ifdef COMPAT_50 |
|
#include <compat/sys/time.h> |
|
#include <compat/sys/socket.h> |
|
#endif |
|
|
|
#include <netinet6/ip6protosw.h> |
#include <netinet6/ip6protosw.h> |
|
|
#include "faith.h" |
#include "faith.h" |
|
|
KASSERT(inet6_pfil_hook != NULL); |
KASSERT(inet6_pfil_hook != NULL); |
|
|
ip6stat_percpu = percpu_alloc(sizeof(uint64_t) * IP6_NSTATS); |
ip6stat_percpu = percpu_alloc(sizeof(uint64_t) * IP6_NSTATS); |
|
|
ip6_forward_rt_percpu = percpu_alloc(sizeof(struct route)); |
ip6_forward_rt_percpu = percpu_alloc(sizeof(struct route)); |
if (ip6_forward_rt_percpu == NULL) |
|
panic("failed to alllocate ip6_forward_rt_percpu"); |
|
} |
} |
|
|
static void |
static void |
Line 459 ip6_input(struct mbuf *m, struct ifnet * |
|
Line 449 ip6_input(struct mbuf *m, struct ifnet * |
|
* Multicast check |
* Multicast check |
*/ |
*/ |
if (IN6_IS_ADDR_MULTICAST(&ip6->ip6_dst)) { |
if (IN6_IS_ADDR_MULTICAST(&ip6->ip6_dst)) { |
struct in6_multi *in6m = 0; |
bool ingroup; |
|
|
in6_ifstat_inc(rcvif, ifs6_in_mcast); |
in6_ifstat_inc(rcvif, ifs6_in_mcast); |
/* |
/* |
* See if we belong to the destination multicast group on the |
* See if we belong to the destination multicast group on the |
* arrival interface. |
* arrival interface. |
*/ |
*/ |
IN6_LOOKUP_MULTI(ip6->ip6_dst, rcvif, in6m); |
ingroup = in6_multi_group(&ip6->ip6_dst, rcvif); |
if (in6m) |
if (ingroup) |
ours = 1; |
ours = 1; |
else if (!ip6_mrouter) { |
else if (!ip6_mrouter) { |
uint64_t *ip6s = IP6_STAT_GETREF(); |
uint64_t *ip6s = IP6_STAT_GETREF(); |
Line 800 ip6_input(struct mbuf *m, struct ifnet * |
|
Line 790 ip6_input(struct mbuf *m, struct ifnet * |
|
& PR_LASTHDR) != 0) { |
& PR_LASTHDR) != 0) { |
int error; |
int error; |
|
|
SOFTNET_LOCK(); |
|
error = ipsec6_input(m); |
error = ipsec6_input(m); |
SOFTNET_UNLOCK(); |
|
if (error) |
if (error) |
goto bad; |
goto bad; |
} |
} |
|
|
ip6_savecontrol(struct in6pcb *in6p, struct mbuf **mp, |
ip6_savecontrol(struct in6pcb *in6p, struct mbuf **mp, |
struct ip6_hdr *ip6, struct mbuf *m) |
struct ip6_hdr *ip6, struct mbuf *m) |
{ |
{ |
|
struct socket *so = in6p->in6p_socket; |
#ifdef RFC2292 |
#ifdef RFC2292 |
#define IS2292(x, y) ((in6p->in6p_flags & IN6P_RFC2292) ? (x) : (y)) |
#define IS2292(x, y) ((in6p->in6p_flags & IN6P_RFC2292) ? (x) : (y)) |
#else |
#else |
#define IS2292(x, y) (y) |
#define IS2292(x, y) (y) |
#endif |
#endif |
|
|
if (in6p->in6p_socket->so_options & SO_TIMESTAMP |
if (SOOPT_TIMESTAMP(so->so_options)) |
#ifdef SO_OTIMESTAMP |
mp = sbsavetimestamp(so->so_options, m, mp); |
|| in6p->in6p_socket->so_options & SO_OTIMESTAMP |
|
#endif |
|
) { |
|
struct timeval tv; |
|
|
|
microtime(&tv); |
|
#ifdef SO_OTIMESTAMP |
|
if (in6p->in6p_socket->so_options & SO_OTIMESTAMP) { |
|
struct timeval50 tv50; |
|
timeval_to_timeval50(&tv, &tv50); |
|
*mp = sbcreatecontrol((void *) &tv50, sizeof(tv50), |
|
SCM_OTIMESTAMP, SOL_SOCKET); |
|
} else |
|
#endif |
|
*mp = sbcreatecontrol((void *) &tv, sizeof(tv), |
|
SCM_TIMESTAMP, SOL_SOCKET); |
|
if (*mp) |
|
mp = &(*mp)->m_next; |
|
} |
|
|
|
/* some OSes call this logic with IPv4 packet, for SO_TIMESTAMP */ |
/* some OSes call this logic with IPv4 packet, for SO_TIMESTAMP */ |
if ((ip6->ip6_vfc & IPV6_VERSION_MASK) != IPV6_VERSION) |
if ((ip6->ip6_vfc & IPV6_VERSION_MASK) != IPV6_VERSION) |
Line 1128 ip6_savecontrol(struct in6pcb *in6p, str |
|
Line 1098 ip6_savecontrol(struct in6pcb *in6p, str |
|
memcpy(&pi6.ipi6_addr, &ip6->ip6_dst, sizeof(struct in6_addr)); |
memcpy(&pi6.ipi6_addr, &ip6->ip6_dst, sizeof(struct in6_addr)); |
in6_clearscope(&pi6.ipi6_addr); /* XXX */ |
in6_clearscope(&pi6.ipi6_addr); /* XXX */ |
pi6.ipi6_ifindex = m->m_pkthdr.rcvif_index; |
pi6.ipi6_ifindex = m->m_pkthdr.rcvif_index; |
*mp = sbcreatecontrol((void *) &pi6, |
*mp = sbcreatecontrol(&pi6, sizeof(pi6), |
sizeof(struct in6_pktinfo), |
|
IS2292(IPV6_2292PKTINFO, IPV6_PKTINFO), IPPROTO_IPV6); |
IS2292(IPV6_2292PKTINFO, IPV6_PKTINFO), IPPROTO_IPV6); |
if (*mp) |
if (*mp) |
mp = &(*mp)->m_next; |
mp = &(*mp)->m_next; |
Line 1138 ip6_savecontrol(struct in6pcb *in6p, str |
|
Line 1107 ip6_savecontrol(struct in6pcb *in6p, str |
|
if (in6p->in6p_flags & IN6P_HOPLIMIT) { |
if (in6p->in6p_flags & IN6P_HOPLIMIT) { |
int hlim = ip6->ip6_hlim & 0xff; |
int hlim = ip6->ip6_hlim & 0xff; |
|
|
*mp = sbcreatecontrol((void *) &hlim, sizeof(int), |
*mp = sbcreatecontrol(&hlim, sizeof(hlim), |
IS2292(IPV6_2292HOPLIMIT, IPV6_HOPLIMIT), IPPROTO_IPV6); |
IS2292(IPV6_2292HOPLIMIT, IPV6_HOPLIMIT), IPPROTO_IPV6); |
if (*mp) |
if (*mp) |
mp = &(*mp)->m_next; |
mp = &(*mp)->m_next; |
Line 1152 ip6_savecontrol(struct in6pcb *in6p, str |
|
Line 1121 ip6_savecontrol(struct in6pcb *in6p, str |
|
flowinfo >>= 20; |
flowinfo >>= 20; |
|
|
tclass = flowinfo & 0xff; |
tclass = flowinfo & 0xff; |
*mp = sbcreatecontrol((void *)&tclass, sizeof(tclass), |
*mp = sbcreatecontrol(&tclass, sizeof(tclass), |
IPV6_TCLASS, IPPROTO_IPV6); |
IPV6_TCLASS, IPPROTO_IPV6); |
|
|
if (*mp) |
if (*mp) |
Line 1200 ip6_savecontrol(struct in6pcb *in6p, str |
|
Line 1169 ip6_savecontrol(struct in6pcb *in6p, str |
|
* be removed before returning in the RFC 2292. |
* be removed before returning in the RFC 2292. |
* Note: this constraint is removed in RFC3542. |
* Note: this constraint is removed in RFC3542. |
*/ |
*/ |
*mp = sbcreatecontrol((void *)hbh, hbhlen, |
*mp = sbcreatecontrol(hbh, hbhlen, |
IS2292(IPV6_2292HOPOPTS, IPV6_HOPOPTS), |
IS2292(IPV6_2292HOPOPTS, IPV6_HOPOPTS), |
IPPROTO_IPV6); |
IPPROTO_IPV6); |
if (*mp) |
if (*mp) |
Line 1262 ip6_savecontrol(struct in6pcb *in6p, str |
|
Line 1231 ip6_savecontrol(struct in6pcb *in6p, str |
|
if (!(in6p->in6p_flags & IN6P_DSTOPTS)) |
if (!(in6p->in6p_flags & IN6P_DSTOPTS)) |
break; |
break; |
|
|
*mp = sbcreatecontrol((void *)ip6e, elen, |
*mp = sbcreatecontrol(ip6e, elen, |
IS2292(IPV6_2292DSTOPTS, IPV6_DSTOPTS), |
IS2292(IPV6_2292DSTOPTS, IPV6_DSTOPTS), |
IPPROTO_IPV6); |
IPPROTO_IPV6); |
if (*mp) |
if (*mp) |
Line 1273 ip6_savecontrol(struct in6pcb *in6p, str |
|
Line 1242 ip6_savecontrol(struct in6pcb *in6p, str |
|
if (!(in6p->in6p_flags & IN6P_RTHDR)) |
if (!(in6p->in6p_flags & IN6P_RTHDR)) |
break; |
break; |
|
|
*mp = sbcreatecontrol((void *)ip6e, elen, |
*mp = sbcreatecontrol(ip6e, elen, |
IS2292(IPV6_2292RTHDR, IPV6_RTHDR), |
IS2292(IPV6_2292RTHDR, IPV6_RTHDR), |
IPPROTO_IPV6); |
IPPROTO_IPV6); |
if (*mp) |
if (*mp) |
Line 1323 ip6_notify_pmtu(struct in6pcb *in6p, con |
|
Line 1292 ip6_notify_pmtu(struct in6pcb *in6p, con |
|
if (mtu == NULL) |
if (mtu == NULL) |
return; |
return; |
|
|
#ifdef DIAGNOSTIC |
KASSERT(so != NULL); |
if (so == NULL) /* I believe this is impossible */ |
|
panic("ip6_notify_pmtu: socket is NULL"); |
|
#endif |
|
|
|
memset(&mtuctl, 0, sizeof(mtuctl)); /* zero-clear for safety */ |
memset(&mtuctl, 0, sizeof(mtuctl)); /* zero-clear for safety */ |
mtuctl.ip6m_mtu = *mtu; |
mtuctl.ip6m_mtu = *mtu; |
Line 1334 ip6_notify_pmtu(struct in6pcb *in6p, con |
|
Line 1300 ip6_notify_pmtu(struct in6pcb *in6p, con |
|
if (sa6_recoverscope(&mtuctl.ip6m_addr)) |
if (sa6_recoverscope(&mtuctl.ip6m_addr)) |
return; |
return; |
|
|
if ((m_mtu = sbcreatecontrol((void *)&mtuctl, sizeof(mtuctl), |
if ((m_mtu = sbcreatecontrol(&mtuctl, sizeof(mtuctl), |
IPV6_PATHMTU, IPPROTO_IPV6)) == NULL) |
IPV6_PATHMTU, IPPROTO_IPV6)) == NULL) |
return; |
return; |
|
|