Date: Mon, 3 Feb 2014 11:20:32 +0000 (UTC) From: "Andrey V. Elsukov" <ae@FreeBSD.org> To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r261434 - in user/ae/inet6/sys: netinet6 vm Message-ID: <201402031120.s13BKWUp044502@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ae Date: Mon Feb 3 11:20:32 2014 New Revision: 261434 URL: http://svnweb.freebsd.org/changeset/base/261434 Log: Merge from head/ up to r260860. Modified: user/ae/inet6/sys/netinet6/in6.c user/ae/inet6/sys/netinet6/in6_ifattach.c user/ae/inet6/sys/netinet6/in6_var.h user/ae/inet6/sys/netinet6/nd6_rtr.c user/ae/inet6/sys/vm/vm_pageout.c Directory Properties: user/ae/inet6/ (props changed) user/ae/inet6/sys/ (props changed) Modified: user/ae/inet6/sys/netinet6/in6.c ============================================================================== --- user/ae/inet6/sys/netinet6/in6.c Mon Feb 3 10:31:43 2014 (r261433) +++ user/ae/inet6/sys/netinet6/in6.c Mon Feb 3 11:20:32 2014 (r261434) @@ -967,6 +967,27 @@ in6_update_ifa(struct ifnet *ifp, struct return (error); } +/* + * Fill in basic IPv6 address request info + */ +void +in6_prepare_ifra(struct in6_aliasreq *ifra, const struct in6_addr *addr, + const struct in6_addr *mask) +{ + + memset(ifra, 0, sizeof(struct in6_aliasreq)); + + ifra->ifra_addr.sin6_family = AF_INET6; + ifra->ifra_addr.sin6_len = sizeof(struct sockaddr_in6); + if (addr != NULL) + ifra->ifra_addr.sin6_addr = *addr; + + ifra->ifra_prefixmask.sin6_family = AF_INET6; + ifra->ifra_prefixmask.sin6_len = sizeof(struct sockaddr_in6); + if (mask != NULL) + ifra->ifra_prefixmask.sin6_addr = *mask; +} + static int in6_validate_ifra(struct ifnet *ifp, struct in6_aliasreq *ifra, struct in6_ifaddr *ia, int flags) @@ -1085,53 +1106,53 @@ in6_validate_ifra(struct ifnet *ifp, str return (0); } - /* - * If this is a new address, allocate a new ifaddr and link it - * into chains. - */ + +/* + * Allocate a new ifaddr and link it into chains. + */ static struct in6_ifaddr * in6_alloc_ifa(struct ifnet *ifp, struct in6_aliasreq *ifra, int flags) { struct in6_ifaddr *ia; + /* + * When in6_alloc_ifa() is called in a process of a received + * RA, it is called under an interrupt context. So, we should + * call malloc with M_NOWAIT. + */ + ia = (struct in6_ifaddr *)ifa_alloc(sizeof(*ia), M_NOWAIT); + if (ia == NULL) + return (NULL); + LIST_INIT(&ia->ia6_memberships); + /* Initialize the address and masks, and put time stamp */ + ia->ia_ifa.ifa_addr = (struct sockaddr *)&ia->ia_addr; + ia->ia_addr.sin6_family = AF_INET6; + ia->ia_addr.sin6_len = sizeof(ia->ia_addr); + ia->ia6_createtime = time_uptime; + if ((ifp->if_flags & (IFF_POINTOPOINT | IFF_LOOPBACK)) != 0) { /* - * When in6_update_ifa() is called in a process of a received - * RA, it is called under an interrupt context. So, we should - * call malloc with M_NOWAIT. + * XXX: some functions expect that ifa_dstaddr is not + * NULL for p2p interfaces. */ - ia = (struct in6_ifaddr *)ifa_alloc(sizeof(*ia), M_NOWAIT); - if (ia == NULL) - return (NULL); - LIST_INIT(&ia->ia6_memberships); - /* Initialize the address and masks, and put time stamp */ - ia->ia_ifa.ifa_addr = (struct sockaddr *)&ia->ia_addr; - ia->ia_addr.sin6_family = AF_INET6; - ia->ia_addr.sin6_len = sizeof(ia->ia_addr); - ia->ia6_createtime = time_uptime; - if ((ifp->if_flags & (IFF_POINTOPOINT | IFF_LOOPBACK)) != 0) { - /* - * XXX: some functions expect that ifa_dstaddr is not - * NULL for p2p interfaces. - */ - ia->ia_ifa.ifa_dstaddr = - (struct sockaddr *)&ia->ia_dstaddr; - } else { - ia->ia_ifa.ifa_dstaddr = NULL; - } - ia->ia_ifa.ifa_netmask = (struct sockaddr *)&ia->ia_prefixmask; - ia->ia_ifp = ifp; - ifa_ref(&ia->ia_ifa); /* if_addrhead */ - IF_ADDR_WLOCK(ifp); - TAILQ_INSERT_TAIL(&ifp->if_addrhead, &ia->ia_ifa, ifa_link); - IF_ADDR_WUNLOCK(ifp); - - ifa_ref(&ia->ia_ifa); /* in6_ifaddrhead */ - IN6_IFADDR_WLOCK(); - TAILQ_INSERT_TAIL(&V_in6_ifaddrhead, ia, ia_link); - LIST_INSERT_HEAD(IN6ADDR_HASH(&ifra->ifra_addr.sin6_addr), - ia, ia6_hash); - IN6_IFADDR_WUNLOCK(); - + ia->ia_ifa.ifa_dstaddr = + (struct sockaddr *)&ia->ia_dstaddr; + } else { + ia->ia_ifa.ifa_dstaddr = NULL; + } + ia->ia_ifa.ifa_netmask = (struct sockaddr *)&ia->ia_prefixmask; + ia->ia_ifp = ifp; + ifa_ref(&ia->ia_ifa); /* if_addrhead */ + IF_ADDR_WLOCK(ifp); + TAILQ_INSERT_TAIL(&ifp->if_addrhead, &ia->ia_ifa, ifa_link); + IF_ADDR_WUNLOCK(ifp); + + ifa_ref(&ia->ia_ifa); /* in6_ifaddrhead */ + IN6_IFADDR_WLOCK(); + TAILQ_INSERT_TAIL(&V_in6_ifaddrhead, ia, ia_link); + LIST_INSERT_HEAD(IN6ADDR_HASH(&ifra->ifra_addr.sin6_addr), + ia, ia6_hash); + IN6_IFADDR_WUNLOCK(); + return (ia); } @@ -1236,11 +1257,6 @@ in6_setup_ifa(struct ifnet *ifp, struct /* Add local address to lltable, if necessary (ex. on p2p link). */ in6_ifaddloop(&(ia->ia_ifa)); - /* - * Beyond this point, we should call in6_purgeaddr upon an error, - * not just go to unlink. - */ - /* Join necessary multicast groups. */ in6m_sol = NULL; if ((ifp->if_flags & IFF_MULTICAST) != 0) { Modified: user/ae/inet6/sys/netinet6/in6_ifattach.c ============================================================================== --- user/ae/inet6/sys/netinet6/in6_ifattach.c Mon Feb 3 10:31:43 2014 (r261433) +++ user/ae/inet6/sys/netinet6/in6_ifattach.c Mon Feb 3 11:20:32 2014 (r261434) @@ -459,16 +459,8 @@ in6_ifattach_linklocal(struct ifnet *ifp /* * configure link-local address. */ - bzero(&ifra, sizeof(ifra)); + in6_prepare_ifra(&ifra, NULL, &in6mask64); - /* - * in6_update_ifa() does not use ifra_name, but we accurately set it - * for safety. - */ - strncpy(ifra.ifra_name, if_name(ifp), sizeof(ifra.ifra_name)); - - ifra.ifra_addr.sin6_family = AF_INET6; - ifra.ifra_addr.sin6_len = sizeof(struct sockaddr_in6); ifra.ifra_addr.sin6_addr.s6_addr32[0] = htonl(0xfe800000); if ((ifp->if_flags & IFF_LOOPBACK) != 0) { ifra.ifra_addr.sin6_addr.s6_addr32[3] = IPV6_ADDR_INT32_ONE; @@ -479,9 +471,6 @@ in6_ifattach_linklocal(struct ifnet *ifp return (-1); } } - ifra.ifra_prefixmask.sin6_len = sizeof(struct sockaddr_in6); - ifra.ifra_prefixmask.sin6_family = AF_INET6; - ifra.ifra_prefixmask.sin6_addr = in6mask64; /* link-local addresses should NEVER expire. */ ifra.ifra_lifetime.ia6t_vltime = ND6_INFINITE_LIFETIME; ifra.ifra_lifetime.ia6t_pltime = ND6_INFINITE_LIFETIME; @@ -553,17 +542,7 @@ in6_ifattach_loopback(struct ifnet *ifp) struct in6_aliasreq ifra; int error; - bzero(&ifra, sizeof(ifra)); - - /* - * in6_update_ifa() does not use ifra_name, but we accurately set it - * for safety. - */ - strncpy(ifra.ifra_name, if_name(ifp), sizeof(ifra.ifra_name)); - - ifra.ifra_prefixmask.sin6_len = sizeof(struct sockaddr_in6); - ifra.ifra_prefixmask.sin6_family = AF_INET6; - ifra.ifra_prefixmask.sin6_addr = in6mask128; + in6_prepare_ifra(&ifra, &in6addr_loopback, &in6mask128); /* * Always initialize ia_dstaddr (= broadcast address) to loopback @@ -573,10 +552,6 @@ in6_ifattach_loopback(struct ifnet *ifp) ifra.ifra_dstaddr.sin6_family = AF_INET6; ifra.ifra_dstaddr.sin6_addr = in6addr_loopback; - ifra.ifra_addr.sin6_len = sizeof(struct sockaddr_in6); - ifra.ifra_addr.sin6_family = AF_INET6; - ifra.ifra_addr.sin6_addr = in6addr_loopback; - /* the loopback address should NEVER expire. */ ifra.ifra_lifetime.ia6t_vltime = ND6_INFINITE_LIFETIME; ifra.ifra_lifetime.ia6t_pltime = ND6_INFINITE_LIFETIME; Modified: user/ae/inet6/sys/netinet6/in6_var.h ============================================================================== --- user/ae/inet6/sys/netinet6/in6_var.h Mon Feb 3 10:31:43 2014 (r261433) +++ user/ae/inet6/sys/netinet6/in6_var.h Mon Feb 3 11:20:32 2014 (r261434) @@ -799,6 +799,8 @@ int in6_control(struct socket *, u_long, struct thread *); int in6_update_ifa(struct ifnet *, struct in6_aliasreq *, struct in6_ifaddr *, int); +void in6_prepare_ifra(struct in6_aliasreq *, const struct in6_addr *, + const struct in6_addr *); void in6_purgeaddr(struct ifaddr *); int in6if_do_dad(struct ifnet *); void in6_savemkludge(struct in6_ifaddr *); Modified: user/ae/inet6/sys/netinet6/nd6_rtr.c ============================================================================== --- user/ae/inet6/sys/netinet6/nd6_rtr.c Mon Feb 3 10:31:43 2014 (r261433) +++ user/ae/inet6/sys/netinet6/nd6_rtr.c Mon Feb 3 11:20:32 2014 (r261434) @@ -1829,19 +1829,9 @@ in6_ifadd(struct nd_prefixctl *pr, int m } /* make ifaddr */ + in6_prepare_ifra(&ifra, &pr->ndpr_prefix.sin6_addr, &mask); - bzero(&ifra, sizeof(ifra)); - /* - * in6_update_ifa() does not use ifra_name, but we accurately set it - * for safety. - */ - strncpy(ifra.ifra_name, if_name(ifp), sizeof(ifra.ifra_name)); - ifra.ifra_addr.sin6_family = AF_INET6; - ifra.ifra_addr.sin6_len = sizeof(struct sockaddr_in6); - /* prefix */ - ifra.ifra_addr.sin6_addr = pr->ndpr_prefix.sin6_addr; IN6_MASK_ADDR(&ifra.ifra_addr.sin6_addr, &mask); - /* interface ID */ ifra.ifra_addr.sin6_addr.s6_addr32[0] |= (ib->ia_addr.sin6_addr.s6_addr32[0] & ~mask.s6_addr32[0]); @@ -1853,12 +1843,6 @@ in6_ifadd(struct nd_prefixctl *pr, int m (ib->ia_addr.sin6_addr.s6_addr32[3] & ~mask.s6_addr32[3]); ifa_free(ifa); - /* new prefix mask. */ - ifra.ifra_prefixmask.sin6_len = sizeof(struct sockaddr_in6); - ifra.ifra_prefixmask.sin6_family = AF_INET6; - bcopy(&mask, &ifra.ifra_prefixmask.sin6_addr, - sizeof(ifra.ifra_prefixmask.sin6_addr)); - /* lifetimes. */ ifra.ifra_lifetime.ia6t_vltime = pr->ndpr_vltime; ifra.ifra_lifetime.ia6t_pltime = pr->ndpr_pltime; @@ -1923,11 +1907,10 @@ in6_tmpifadd(const struct in6_ifaddr *ia u_int32_t randid[2]; time_t vltime0, pltime0; - bzero(&ifra, sizeof(ifra)); - strncpy(ifra.ifra_name, if_name(ifp), sizeof(ifra.ifra_name)); - ifra.ifra_addr = ia0->ia_addr; - /* copy prefix mask */ - ifra.ifra_prefixmask = ia0->ia_prefixmask; + in6_prepare_ifra(&ifra, &ia0->ia_addr.sin6_addr, + &ia0->ia_prefixmask.sin6_addr); + + ifra.ifra_addr = ia0->ia_addr; /* XXX: do we need this ? */ /* clear the old IFID */ IN6_MASK_ADDR(&ifra.ifra_addr.sin6_addr, &ifra.ifra_prefixmask.sin6_addr); Modified: user/ae/inet6/sys/vm/vm_pageout.c ============================================================================== --- user/ae/inet6/sys/vm/vm_pageout.c Mon Feb 3 10:31:43 2014 (r261433) +++ user/ae/inet6/sys/vm/vm_pageout.c Mon Feb 3 11:20:32 2014 (r261434) @@ -1047,11 +1047,11 @@ vm_pageout_scan(struct vm_domain *vmd, i * level VM system not knowing anything about existing * references. */ - act_delta = 0; if ((m->aflags & PGA_REFERENCED) != 0) { vm_page_aflag_clear(m, PGA_REFERENCED); act_delta = 1; - } + } else + act_delta = 0; if (object->ref_count != 0) { act_delta += pmap_ts_referenced(m); } else { @@ -1064,7 +1064,7 @@ vm_pageout_scan(struct vm_domain *vmd, i * references, we reactivate the page or requeue it. */ if (act_delta != 0) { - if (object->ref_count) { + if (object->ref_count != 0) { vm_page_activate(m); m->act_count += act_delta + ACT_ADVANCE; } else { @@ -1361,11 +1361,12 @@ relock_queues: /* * Check to see "how much" the page has been used. */ - act_delta = 0; - if (m->aflags & PGA_REFERENCED) { + if ((m->aflags & PGA_REFERENCED) != 0) { vm_page_aflag_clear(m, PGA_REFERENCED); - act_delta += 1; - } + act_delta = 1; + } else + act_delta = 0; + /* * Unlocked object ref count check. Two races are possible. * 1) The ref was transitioning to zero and we saw non-zero, @@ -1380,20 +1381,18 @@ relock_queues: /* * Advance or decay the act_count based on recent usage. */ - if (act_delta) { + if (act_delta != 0) { m->act_count += ACT_ADVANCE + act_delta; if (m->act_count > ACT_MAX) m->act_count = ACT_MAX; - } else { + } else m->act_count -= min(m->act_count, ACT_DECLINE); - act_delta = m->act_count; - } /* * Move this page to the tail of the active or inactive * queue depending on usage. */ - if (act_delta == 0) { + if (m->act_count == 0) { /* Dequeue to avoid later lock recursion. */ vm_page_dequeue_locked(m); vm_page_deactivate(m);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201402031120.s13BKWUp044502>