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.116.2.1 retrieving revision 1.129.4.1 diff -u -p -r1.116.2.1 -r1.129.4.1 --- src/sys/netinet6/ip6_input.c 2008/05/18 12:35:35 1.116.2.1 +++ src/sys/netinet6/ip6_input.c 2011/05/31 03:05:08 1.129.4.1 @@ -1,4 +1,4 @@ -/* $NetBSD: ip6_input.c,v 1.116.2.1 2008/05/18 12:35:35 yamt Exp $ */ +/* $NetBSD: ip6_input.c,v 1.129.4.1 2011/05/31 03:05:08 rmind Exp $ */ /* $KAME: ip6_input.c,v 1.188 2001/03/29 05:34:31 itojun Exp $ */ /* @@ -62,12 +62,14 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ip6_input.c,v 1.116.2.1 2008/05/18 12:35:35 yamt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ip6_input.c,v 1.129.4.1 2011/05/31 03:05:08 rmind Exp $"); +#include "opt_gateway.h" #include "opt_inet.h" #include "opt_inet6.h" #include "opt_ipsec.h" #include "opt_pfil_hooks.h" +#include "opt_compat_netbsd.h" #include #include @@ -120,6 +122,11 @@ __KERNEL_RCSID(0, "$NetBSD: ip6_input.c, #include #endif /* FAST_IPSEC */ +#ifdef COMPAT_50 +#include +#include +#endif + #include #include "faith.h" @@ -131,6 +138,8 @@ __KERNEL_RCSID(0, "$NetBSD: ip6_input.c, #include +extern struct inpcbtable tcbtable; /* XXX include of tcp_var.h no good */ + extern struct domain inet6domain; u_char ip6_protox[IPPROTO_MAX]; @@ -155,6 +164,7 @@ static struct m_tag *ip6_setdstifaddr(st static int ip6_hopopts_input(u_int32_t *, u_int32_t *, struct mbuf **, int *); static struct mbuf *ip6_pullexthdr(struct mbuf *, size_t, int); +static void sysctl_net_inet6_ip6_setup(struct sysctllog **); /* * IP6 initialization: fill in IP6 protocol switch table. @@ -166,6 +176,7 @@ ip6_init(void) const struct ip6protosw *pr; int i; + sysctl_net_inet6_ip6_setup(NULL); pr = (const struct ip6protosw *)pffindproto(PF_INET6, IPPROTO_RAW, SOCK_RAW); if (pr == 0) panic("ip6_init"); @@ -954,7 +965,7 @@ ip6_process_hopopts(struct mbuf *m, u_in return (-1); } optlen = IP6OPT_RTALERT_LEN; - bcopy((void *)(opt + 2), (void *)&rtalert_val, 2); + memcpy((void *)&rtalert_val, (void *)(opt + 2), 2); *rtalertp = ntohs(rtalert_val); break; case IP6OPT_JUMBO: @@ -989,7 +1000,7 @@ ip6_process_hopopts(struct mbuf *m, u_in * We may see jumbolen in unaligned location, so * we'd need to perform bcopy(). */ - bcopy(opt + 2, &jumboplen, sizeof(jumboplen)); + memcpy(&jumboplen, opt + 2, sizeof(jumboplen)); jumboplen = (u_int32_t)htonl(jumboplen); #if 1 @@ -1102,17 +1113,27 @@ ip6_savecontrol(struct in6pcb *in6p, str #define IS2292(x, y) (y) #endif -#ifdef SO_TIMESTAMP - if (in6p->in6p_socket->so_options & SO_TIMESTAMP) { + if (in6p->in6p_socket->so_options & SO_TIMESTAMP +#ifdef SO_OTIMESTAMP + || 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; } -#endif /* some OSes call this logic with IPv4 packet, for SO_TIMESTAMP */ if ((ip6->ip6_vfc & IPV6_VERSION_MASK) != IPV6_VERSION) @@ -1122,7 +1143,7 @@ ip6_savecontrol(struct in6pcb *in6p, str if ((in6p->in6p_flags & IN6P_PKTINFO) != 0) { struct in6_pktinfo pi6; - bcopy(&ip6->ip6_dst, &pi6.ipi6_addr, sizeof(struct in6_addr)); + memcpy(&pi6.ipi6_addr, &ip6->ip6_dst, sizeof(struct in6_addr)); in6_clearscope(&pi6.ipi6_addr); /* XXX */ pi6.ipi6_ifindex = m->m_pkthdr.rcvif ? m->m_pkthdr.rcvif->if_index : 0; @@ -1257,7 +1278,7 @@ ip6_savecontrol(struct in6pcb *in6p, str switch (nxt) { case IPPROTO_DSTOPTS: - if (!in6p->in6p_flags & IN6P_DSTOPTS) + if (!(in6p->in6p_flags & IN6P_DSTOPTS)) break; *mp = sbcreatecontrol((void *)ip6e, elen, @@ -1268,7 +1289,7 @@ ip6_savecontrol(struct in6pcb *in6p, str break; case IPPROTO_ROUTING: - if (!in6p->in6p_flags & IN6P_RTHDR) + if (!(in6p->in6p_flags & IN6P_RTHDR)) break; *mp = sbcreatecontrol((void *)ip6e, elen, @@ -1562,7 +1583,7 @@ ip6_addaux(struct mbuf *m) M_NOWAIT); if (mtag) { m_tag_prepend(m, mtag); - bzero(mtag + 1, sizeof(struct ip6aux)); + memset(mtag + 1, 0, sizeof(struct ip6aux)); } } return mtag; @@ -1595,17 +1616,21 @@ ip6_delaux(struct mbuf *m) static int sysctl_net_inet6_ip6_maxflows(SYSCTLFN_ARGS) { - int s; + int error; - s = sysctl_lookup(SYSCTLFN_CALL(rnode)); - if (s || newp == NULL) - return (s); + error = sysctl_lookup(SYSCTLFN_CALL(rnode)); + if (error || newp == NULL) + return (error); - s = splsoftnet(); - ip6flow_reap(0); - splx(s); + mutex_enter(softnet_lock); + KERNEL_LOCK(1, NULL); + + ip6flow_reap(0); + + KERNEL_UNLOCK_ONE(NULL); + mutex_exit(softnet_lock); - return (0); + return (0); } static int @@ -1625,16 +1650,21 @@ sysctl_net_inet6_ip6_hashsize(SYSCTLFN_A /* * Can only fail due to malloc() */ - if (ip6flow_invalidate_all(tmp)) - return ENOMEM; + mutex_enter(softnet_lock); + KERNEL_LOCK(1, NULL); + + error = ip6flow_invalidate_all(tmp); + + KERNEL_UNLOCK_ONE(NULL); + mutex_exit(softnet_lock); } else { /* * EINVAL if not a power of 2 - */ - return EINVAL; + */ + error = EINVAL; } - return (0); + return error; } #endif /* GATEWAY */ @@ -1642,7 +1672,7 @@ sysctl_net_inet6_ip6_hashsize(SYSCTLFN_A * System control for IP6 */ -u_char inet6ctlerrmap[PRC_NCMDS] = { +const u_char inet6ctlerrmap[PRC_NCMDS] = { 0, 0, 0, 0, 0, EMSGSIZE, EHOSTDOWN, EHOSTUNREACH, EHOSTUNREACH, EHOSTUNREACH, ECONNREFUSED, ECONNREFUSED, @@ -1658,7 +1688,8 @@ sysctl_net_inet6_ip6_stats(SYSCTLFN_ARGS return (NETSTAT_SYSCTL(ip6stat_percpu, IP6_NSTATS)); } -SYSCTL_SETUP(sysctl_net_inet6_ip6_setup, "sysctl net.inet6.ip6 subtree setup") +static void +sysctl_net_inet6_ip6_setup(struct sysctllog **clog) { #ifdef RFC2292 #define IS2292(x, y) ((in6p->in6p_flags & IN6P_RFC2292) ? (x) : (y)) @@ -1764,6 +1795,20 @@ SYSCTL_SETUP(sysctl_net_inet6_ip6_setup, IPV6CTL_ACCEPT_RTADV, CTL_EOL); sysctl_createv(clog, 0, NULL, NULL, CTLFLAG_PERMANENT|CTLFLAG_READWRITE, + CTLTYPE_INT, "rtadv_maxroutes", + SYSCTL_DESCR("Maximum number of routes accepted via router advertisements"), + NULL, 0, &ip6_rtadv_maxroutes, 0, + CTL_NET, PF_INET6, IPPROTO_IPV6, + IPV6CTL_RTADV_MAXROUTES, CTL_EOL); + sysctl_createv(clog, 0, NULL, NULL, + CTLFLAG_PERMANENT, + CTLTYPE_INT, "rtadv_numroutes", + SYSCTL_DESCR("Current number of routes accepted via router advertisements"), + NULL, 0, &nd6_numroutes, 0, + CTL_NET, PF_INET6, IPPROTO_IPV6, + IPV6CTL_RTADV_NUMROUTES, CTL_EOL); + sysctl_createv(clog, 0, NULL, NULL, + CTLFLAG_PERMANENT|CTLFLAG_READWRITE, CTLTYPE_INT, "keepfaith", SYSCTL_DESCR("Activate faith interface"), NULL, 0, &ip6_keepfaith, 0,