Date: Mon, 29 Oct 2007 21:47:00 GMT From: Kip Macy <kmacy@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 128306 for review Message-ID: <200710292147.l9TLl0dG053594@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=128306 Change 128306 by kmacy@kmacy:storage:toestack on 2007/10/29 21:46:43 let arpresolve take a null mbuf remove code duplication in arp_ifinit and arp_ifinit2 hook arp update with arp_update eventhandler Affected files ... .. //depot/projects/toestack/sys/netinet/if_ether.c#6 edit Differences ... ==== //depot/projects/toestack/sys/netinet/if_ether.c#6 (text+ko) ==== @@ -362,15 +362,17 @@ struct sockaddr_dl *sdl; int error; - if (m->m_flags & M_BCAST) { /* broadcast */ - (void)memcpy(desten, ifp->if_broadcastaddr, ifp->if_addrlen); - return (0); + if (m) { + if (m->m_flags & M_BCAST) { /* broadcast */ + (void)memcpy(desten, ifp->if_broadcastaddr, ifp->if_addrlen); + return (0); + } + if (m->m_flags & M_MCAST && ifp->if_type != IFT_ARCNET) {/* multicast */ + ETHER_MAP_IP_MULTICAST(&SIN(dst)->sin_addr, desten); + return (0); + } } - if (m->m_flags & M_MCAST && ifp->if_type != IFT_ARCNET) {/* multicast */ - ETHER_MAP_IP_MULTICAST(&SIN(dst)->sin_addr, desten); - return (0); - } - + if (rt0 != NULL) { error = rt_check(&rt, &rt0, dst); if (error) { @@ -413,7 +415,8 @@ sdl->sdl_family == AF_LINK && sdl->sdl_alen != 0) { bcopy(LLADDR(sdl), desten, sdl->sdl_alen); - + EVENTHANDLER_INVOKE(arp_update, rt); + /* * If entry has an expiry time and it is approaching, * send an ARP request. @@ -449,10 +452,12 @@ * response yet. Replace the held mbuf with this * latest one. */ - if (la->la_hold) - m_freem(la->la_hold); - la->la_hold = m; - + if (m) { + if (la->la_hold) + m_freem(la->la_hold); + la->la_hold = m; + } + KASSERT(rt->rt_expire > 0, ("sending ARP request for static entry")); /* @@ -936,12 +941,12 @@ } } -void -arp_ifinit(struct ifnet *ifp, struct ifaddr *ifa) +static __inline +arp_ifinit_internal(struct ifnet *ifp, struct ifaddr *ifa, u_char *enaddr) { if (ntohl(IA_SIN(ifa)->sin_addr.s_addr) != INADDR_ANY) arprequest(ifp, &IA_SIN(ifa)->sin_addr, - &IA_SIN(ifa)->sin_addr, IF_LLADDR(ifp)); + &IA_SIN(ifa)->sin_addr, enaddr); ifa->ifa_rtrequest = arp_rtrequest; ifa->ifa_flags |= RTF_CLONING; } @@ -949,11 +954,13 @@ void arp_ifinit2(struct ifnet *ifp, struct ifaddr *ifa, u_char *enaddr) { - if (ntohl(IA_SIN(ifa)->sin_addr.s_addr) != INADDR_ANY) - arprequest(ifp, &IA_SIN(ifa)->sin_addr, - &IA_SIN(ifa)->sin_addr, enaddr); - ifa->ifa_rtrequest = arp_rtrequest; - ifa->ifa_flags |= RTF_CLONING; + arp_ifinit_internal(ifp, ifa, enaddr); +} + +void +arp_ifinit(struct ifnet *ifp, struct ifaddr *ifa) +{ + arp_ifinit_internal(ifp, ifa, IF_LLADDR(ifp)); } static void
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200710292147.l9TLl0dG053594>