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/netinet/ip_input.c,v rcsdiff: /ftp/cvs/cvsroot/src/sys/netinet/ip_input.c,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.319.4.7 retrieving revision 1.339 diff -u -p -r1.319.4.7 -r1.339 --- src/sys/netinet/ip_input.c 2016/10/05 20:56:09 1.319.4.7 +++ src/sys/netinet/ip_input.c 2016/08/01 03:15:30 1.339 @@ -1,4 +1,4 @@ -/* $NetBSD: ip_input.c,v 1.319.4.7 2016/10/05 20:56:09 skrll Exp $ */ +/* $NetBSD: ip_input.c,v 1.339 2016/08/01 03:15:30 ozaki-r Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -91,7 +91,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ip_input.c,v 1.319.4.7 2016/10/05 20:56:09 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ip_input.c,v 1.339 2016/08/01 03:15:30 ozaki-r Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -225,7 +225,7 @@ pfil_head_t * inet_pfil_hook __read_mo ipid_state_t * ip_ids __read_mostly; percpu_t * ipstat_percpu __read_mostly; -static percpu_t *ipforward_rt_percpu __cacheline_aligned; +static struct route ipforward_rt __cacheline_aligned; uint16_t ip_id; @@ -345,10 +345,6 @@ ip_init(void) #endif /* MBUFTRACE */ ipstat_percpu = percpu_alloc(sizeof(uint64_t) * IP_NSTATS); - - ipforward_rt_percpu = percpu_alloc(sizeof(struct route)); - if (ipforward_rt_percpu == NULL) - panic("failed to allocate ipforward_rt_percpu"); } static struct in_ifaddr * @@ -382,8 +378,7 @@ ip_match_our_address(struct ifnet *ifp, continue; if (checkif && ia->ia_ifp != ifp) continue; - if ((ia->ia_ifp->if_flags & IFF_UP) != 0 && - (ia->ia4_flags & IN_IFF_DETACHED) == 0) + if ((ia->ia_ifp->if_flags & IFF_UP) != 0) break; else (*downmatch)++; @@ -403,7 +398,7 @@ ip_match_our_address_broadcast(struct if if (ifa->ifa_addr->sa_family != AF_INET) continue; ia = ifatoia(ifa); - if (ia->ia4_flags & (IN_IFF_NOTREADY | IN_IFF_DETACHED)) + if (ia->ia4_flags & IN_IFF_NOTREADY) continue; if (in_hosteq(ip->ip_dst, ia->ia_broadaddr.sin_addr) || in_hosteq(ip->ip_dst, ia->ia_netbroadcast) || @@ -1168,14 +1163,11 @@ ip_rtaddr(struct in_addr dst) struct sockaddr dst; struct sockaddr_in dst4; } u; - struct route *ro; sockaddr_in_init(&u.dst4, &dst, 0); SOFTNET_LOCK(); - ro = percpu_getref(ipforward_rt_percpu); - rt = rtcache_lookup(ro, &u.dst); - percpu_putref(ipforward_rt_percpu); + rt = rtcache_lookup(&ipforward_rt, &u.dst); SOFTNET_UNLOCK(); if (rt == NULL) return NULL; @@ -1308,7 +1300,6 @@ ip_forward(struct mbuf *m, int srcrt, st struct sockaddr_in dst4; } u; uint64_t *ips; - struct route *ro; KASSERTMSG(cpu_softintr_p(), "ip_forward: not in the software " "interrupt handler; synchronization assumptions violated"); @@ -1340,9 +1331,7 @@ ip_forward(struct mbuf *m, int srcrt, st sockaddr_in_init(&u.dst4, &ip->ip_dst, 0); - ro = percpu_getref(ipforward_rt_percpu); - if ((rt = rtcache_lookup(ro, &u.dst)) == NULL) { - percpu_putref(ipforward_rt_percpu); + if ((rt = rtcache_lookup(&ipforward_rt, &u.dst)) == NULL) { icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_NET, dest, 0); SOFTNET_UNLOCK(); return; @@ -1387,7 +1376,7 @@ ip_forward(struct mbuf *m, int srcrt, st } } - error = ip_output(m, NULL, ro, + error = ip_output(m, NULL, &ipforward_rt, (IP_FORWARDING | (ip_directedbcast ? IP_ALLOWBROADCAST : 0)), NULL, NULL); @@ -1409,19 +1398,17 @@ ip_forward(struct mbuf *m, int srcrt, st if (mcopy) { #ifdef GATEWAY if (mcopy->m_flags & M_CANFASTFWD) - ipflow_create(ro, mcopy); + ipflow_create(&ipforward_rt, mcopy); #endif m_freem(mcopy); } - percpu_putref(ipforward_rt_percpu); SOFTNET_UNLOCK(); return; redirect: error: if (mcopy == NULL) { - percpu_putref(ipforward_rt_percpu); SOFTNET_UNLOCK(); return; } @@ -1445,7 +1432,7 @@ error: type = ICMP_UNREACH; code = ICMP_UNREACH_NEEDFRAG; - if ((rt = rtcache_validate(ro)) != NULL) + if ((rt = rtcache_validate(&ipforward_rt)) != NULL) destmtu = rt->rt_ifp->if_mtu; #ifdef IPSEC if (ipsec_used) @@ -1463,12 +1450,10 @@ error: */ if (mcopy) m_freem(mcopy); - percpu_putref(ipforward_rt_percpu); SOFTNET_UNLOCK(); return; } icmp_error(mcopy, type, code, dest, destmtu); - percpu_putref(ipforward_rt_percpu); SOFTNET_UNLOCK(); }