Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/sys/netinet6/ip6_input.c,v rcsdiff: /ftp/cvs/cvsroot/src/sys/netinet6/ip6_input.c,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.148 retrieving revision 1.149.4.4 diff -u -p -r1.148 -r1.149.4.4 --- src/sys/netinet6/ip6_input.c 2014/06/05 23:48:16 1.148 +++ src/sys/netinet6/ip6_input.c 2016/03/19 11:30:33 1.149.4.4 @@ -1,4 +1,4 @@ -/* $NetBSD: ip6_input.c,v 1.148 2014/06/05 23:48:16 rmind Exp $ */ +/* $NetBSD: ip6_input.c,v 1.149.4.4 2016/03/19 11:30:33 skrll Exp $ */ /* $KAME: ip6_input.c,v 1.188 2001/03/29 05:34:31 itojun Exp $ */ /* @@ -62,13 +62,15 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ip6_input.c,v 1.148 2014/06/05 23:48:16 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ip6_input.c,v 1.149.4.4 2016/03/19 11:30:33 skrll Exp $"); +#ifdef _KERNEL_OPT #include "opt_gateway.h" #include "opt_inet.h" #include "opt_inet6.h" #include "opt_ipsec.h" #include "opt_compat_netbsd.h" +#endif #include #include @@ -125,11 +127,6 @@ __KERNEL_RCSID(0, "$NetBSD: ip6_input.c, #include #include "faith.h" -#include "gif.h" - -#if NGIF > 0 -#include -#endif #include @@ -139,8 +136,6 @@ u_char ip6_protox[IPPROTO_MAX]; struct in6_ifaddr *in6_ifaddr; pktqueue_t *ip6_pktq __read_mostly; -extern callout_t in6_tmpaddrtimer_ch; - int ip6_forward_srcrt; /* XXX */ int ip6_sourcecheck; /* XXX */ int ip6_sourcecheck_interval; /* XXX */ @@ -180,7 +175,7 @@ ip6_init(void) pr->pr_protocol && pr->pr_protocol != IPPROTO_RAW) ip6_protox[pr->pr_protocol] = pr - inet6sw; - ip6_pktq = pktq_create(IFQ_MAXLEN, ip6intr); + ip6_pktq = pktq_create(IFQ_MAXLEN, ip6intr, NULL); KASSERT(ip6_pktq != NULL); scope6_init(); @@ -419,7 +414,7 @@ ip6_input(struct mbuf *m) * to the usage conflict. * in6_setscope() then also checks and rejects the cases where src or * dst are the loopback address and the receiving interface - * is not loopback. + * is not loopback. */ if (__predict_false( m_makewritable(&m, 0, sizeof(struct ip6_hdr), M_DONTWAIT))) @@ -748,11 +743,6 @@ ip6_input(struct mbuf *m) #ifdef IPSEC if (ipsec_used) { - struct m_tag *mtag; - struct tdb_ident *tdbi; - struct secpolicy *sp; - int s, error; - /* * enforce IPsec policy checking if we are seeing last * header. note that we do not visit this with @@ -760,39 +750,7 @@ ip6_input(struct mbuf *m) */ if ((inet6sw[ip_protox[nxt]].pr_flags & PR_LASTHDR) != 0) { - /* - * Check if the packet has already had IPsec - * processing done. If so, then just pass it - * along. This tag gets set during AH, ESP, - * etc. input handling, before the packet is - * returned to the ip input queue for delivery. - */ - mtag = m_tag_find(m, PACKET_TAG_IPSEC_IN_DONE, - NULL); - s = splsoftnet(); - if (mtag != NULL) { - tdbi = (struct tdb_ident *)(mtag + 1); - sp = ipsec_getpolicy(tdbi, - IPSEC_DIR_INBOUND); - } else { - sp = ipsec_getpolicybyaddr(m, - IPSEC_DIR_INBOUND, IP_FORWARDING, - &error); - } - if (sp != NULL) { - /* - * Check security policy against packet - * attributes. - */ - error = ipsec_in_reject(sp, m); - KEY_FREESP(&sp); - } else { - /* XXX error stat??? */ - error = EINVAL; - DPRINTF(("ip6_input: no SP, packet" - " discarded\n"));/*XXX*/ - } - splx(s); + int error = ipsec6_input(m); if (error) goto bad; } @@ -849,7 +807,7 @@ ip6_getdstifaddr(struct mbuf *m) * rtalertp - XXX: should be stored more smart way */ int -ip6_hopopts_input(u_int32_t *plenp, u_int32_t *rtalertp, +ip6_hopopts_input(u_int32_t *plenp, u_int32_t *rtalertp, struct mbuf **mp, int *offp) { struct mbuf *m = *mp; @@ -894,7 +852,7 @@ ip6_hopopts_input(u_int32_t *plenp, u_in * opthead + hbhlen is located in continuous memory region. */ static int -ip6_process_hopopts(struct mbuf *m, u_int8_t *opthead, int hbhlen, +ip6_process_hopopts(struct mbuf *m, u_int8_t *opthead, int hbhlen, u_int32_t *rtalertp, u_int32_t *plenp) { struct ip6_hdr *ip6; @@ -1069,7 +1027,7 @@ ip6_unknown_opt(u_int8_t *optp, struct m * you are using IP6_EXTHDR_CHECK() not m_pulldown()) */ void -ip6_savecontrol(struct in6pcb *in6p, struct mbuf **mp, +ip6_savecontrol(struct in6pcb *in6p, struct mbuf **mp, struct ip6_hdr *ip6, struct mbuf *m) { #ifdef RFC2292 @@ -1574,19 +1532,19 @@ ip6_delaux(struct mbuf *m) } #ifdef GATEWAY -/* +/* * sysctl helper routine for net.inet.ip6.maxflows. Since * we could reduce this value, call ip6flow_reap(); */ static int sysctl_net_inet6_ip6_maxflows(SYSCTLFN_ARGS) -{ +{ int error; - + error = sysctl_lookup(SYSCTLFN_CALL(rnode)); if (error || newp == NULL) return (error); - + mutex_enter(softnet_lock); KERNEL_LOCK(1, NULL); @@ -1594,13 +1552,13 @@ sysctl_net_inet6_ip6_maxflows(SYSCTLFN_A KERNEL_UNLOCK_ONE(NULL); mutex_exit(softnet_lock); - + return (0); } static int sysctl_net_inet6_ip6_hashsize(SYSCTLFN_ARGS) -{ +{ int error, tmp; struct sysctlnode node; @@ -1627,7 +1585,7 @@ sysctl_net_inet6_ip6_hashsize(SYSCTLFN_A * EINVAL if not a power of 2 */ error = EINVAL; - } + } return error; } @@ -1646,6 +1604,8 @@ const u_char inet6ctlerrmap[PRC_NCMDS] = ENOPROTOOPT }; +extern int sysctl_net_inet6_addrctlpolicy(SYSCTLFN_ARGS); + static int sysctl_net_inet6_ip6_stats(SYSCTLFN_ARGS) { @@ -1811,15 +1771,6 @@ sysctl_net_inet6_ip6_setup(struct sysctl NULL, 0, &ip6_defmcasthlim, 0, CTL_NET, PF_INET6, IPPROTO_IPV6, IPV6CTL_DEFMCASTHLIM, CTL_EOL); -#if NGIF > 0 - sysctl_createv(clog, 0, NULL, NULL, - CTLFLAG_PERMANENT|CTLFLAG_READWRITE, - CTLTYPE_INT, "gifhlim", - SYSCTL_DESCR("Default hop limit for a gif tunnel datagram"), - NULL, 0, &ip6_gif_hlim, 0, - CTL_NET, PF_INET6, IPPROTO_IPV6, - IPV6CTL_GIF_HLIM, CTL_EOL); -#endif /* NGIF */ sysctl_createv(clog, 0, NULL, NULL, CTLFLAG_PERMANENT, CTLTYPE_STRING, "kame_version", @@ -1854,15 +1805,6 @@ sysctl_net_inet6_ip6_setup(struct sysctl IPV6CTL_V6ONLY, CTL_EOL); sysctl_createv(clog, 0, NULL, NULL, CTLFLAG_PERMANENT|CTLFLAG_READWRITE, - CTLTYPE_INT, "auto_linklocal", - SYSCTL_DESCR("Default value of per-interface flag for " - "adding an IPv6 link-local address to " - "interfaces when attached"), - NULL, 0, &ip6_auto_linklocal, 0, - CTL_NET, PF_INET6, IPPROTO_IPV6, - IPV6CTL_AUTO_LINKLOCAL, CTL_EOL); - sysctl_createv(clog, 0, NULL, NULL, - CTLFLAG_PERMANENT|CTLFLAG_READWRITE, CTLTYPE_INT, "anonportmin", SYSCTL_DESCR("Lowest ephemeral port number to assign"), sysctl_net_inet_ip_ports, 0, &ip6_anonportmin, 0, @@ -1895,6 +1837,23 @@ sysctl_net_inet6_ip6_setup(struct sysctl #endif /* IPNOPRIVPORTS */ sysctl_createv(clog, 0, NULL, NULL, CTLFLAG_PERMANENT|CTLFLAG_READWRITE, + CTLTYPE_INT, "auto_linklocal", + SYSCTL_DESCR("Default value of per-interface flag for " + "adding an IPv6 link-local address to " + "interfaces when attached"), + NULL, 0, &ip6_auto_linklocal, 0, + CTL_NET, PF_INET6, IPPROTO_IPV6, + IPV6CTL_AUTO_LINKLOCAL, CTL_EOL); + sysctl_createv(clog, 0, NULL, NULL, + CTLFLAG_PERMANENT|CTLFLAG_READONLY, + CTLTYPE_STRUCT, "addctlpolicy", + SYSCTL_DESCR("Return the current address control" + " policy"), + sysctl_net_inet6_addrctlpolicy, 0, NULL, 0, + CTL_NET, PF_INET6, IPPROTO_IPV6, + IPV6CTL_ADDRCTLPOLICY, CTL_EOL); + sysctl_createv(clog, 0, NULL, NULL, + CTLFLAG_PERMANENT|CTLFLAG_READWRITE, CTLTYPE_INT, "use_tempaddr", SYSCTL_DESCR("Use temporary address"), NULL, 0, &ip6_use_tempaddr, 0, @@ -1902,6 +1861,14 @@ sysctl_net_inet6_ip6_setup(struct sysctl CTL_CREATE, CTL_EOL); sysctl_createv(clog, 0, NULL, NULL, CTLFLAG_PERMANENT|CTLFLAG_READWRITE, + CTLTYPE_INT, "prefer_tempaddr", + SYSCTL_DESCR("Prefer temporary address as source " + "address"), + NULL, 0, &ip6_prefer_tempaddr, 0, + CTL_NET, PF_INET6, IPPROTO_IPV6, + CTL_CREATE, CTL_EOL); + sysctl_createv(clog, 0, NULL, NULL, + CTLFLAG_PERMANENT|CTLFLAG_READWRITE, CTLTYPE_INT, "temppltime", SYSCTL_DESCR("preferred lifetime of a temporary address"), NULL, 0, &ip6_temp_preferred_lifetime, 0, @@ -1942,7 +1909,7 @@ sysctl_net_inet6_ip6_setup(struct sysctl NULL, 0, &ip6_mcast_pmtu, 0, CTL_NET, PF_INET6, IPPROTO_IPV6, CTL_CREATE, CTL_EOL); -#ifdef GATEWAY +#ifdef GATEWAY sysctl_createv(clog, 0, NULL, NULL, CTLFLAG_PERMANENT|CTLFLAG_READWRITE, CTLTYPE_INT, "maxflows",