Date: Mon, 9 Nov 2015 10:35:34 +0000 (UTC) From: "Alexander V. Chernikov" <melifaro@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r290604 - head/sys/netinet Message-ID: <201511091035.tA9AZYbP037863@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: melifaro Date: Mon Nov 9 10:35:33 2015 New Revision: 290604 URL: https://svnweb.freebsd.org/changeset/base/290604 Log: Decompose arp_ifinit() into arp_add_ifa_lle() and arp_announce_ifaddr(). Rename arp_ifinit2() into arp_announce_ifaddr(). Eliminate zeroing ifa_rtrequest: it was used for calling arp_rtrequest() which was responsible for handling route cloning requests. It became obsolete since r186119 (L2/L3 split). Modified: head/sys/netinet/if_ether.c head/sys/netinet/if_ether.h head/sys/netinet/ip_carp.c Modified: head/sys/netinet/if_ether.c ============================================================================== --- head/sys/netinet/if_ether.c Mon Nov 9 10:11:14 2015 (r290603) +++ head/sys/netinet/if_ether.c Mon Nov 9 10:35:33 2015 (r290604) @@ -1091,26 +1091,13 @@ arp_mark_lle_reachable(struct llentry *l la->la_preempt = V_arp_maxtries; } -void -arp_ifinit(struct ifnet *ifp, struct ifaddr *ifa) +/* + * Add pernament link-layer record for given interface address. + */ +static __noinline void +arp_add_ifa_lle(struct ifnet *ifp, const struct sockaddr *dst) { struct llentry *lle, *lle_tmp; - struct sockaddr_in *dst_in; - struct sockaddr *dst; - - if (ifa->ifa_carp != NULL) - return; - - ifa->ifa_rtrequest = NULL; - - dst_in = IA_SIN(ifa); - dst = (struct sockaddr *)dst_in; - - if (ntohl(IA_SIN(ifa)->sin_addr.s_addr) == INADDR_ANY) - return; - - arprequest(ifp, &IA_SIN(ifa)->sin_addr, - &IA_SIN(ifa)->sin_addr, IF_LLADDR(ifp)); /* * Interface address LLE record is considered static @@ -1144,12 +1131,30 @@ arp_ifinit(struct ifnet *ifp, struct ifa } void -arp_ifinit2(struct ifnet *ifp, struct ifaddr *ifa, u_char *enaddr) +arp_ifinit(struct ifnet *ifp, struct ifaddr *ifa) { - 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 = NULL; + const struct sockaddr_in *dst_in; + const struct sockaddr *dst; + + if (ifa->ifa_carp != NULL) + return; + + dst = ifa->ifa_addr; + dst_in = (const struct sockaddr_in *)dst; + + if (ntohl(dst_in->sin_addr.s_addr) == INADDR_ANY) + return; + arp_announce_ifaddr(ifp, dst_in->sin_addr, IF_LLADDR(ifp)); + + arp_add_ifa_lle(ifp, dst); +} + +void +arp_announce_ifaddr(struct ifnet *ifp, struct in_addr addr, u_char *enaddr) +{ + + if (ntohl(addr.s_addr) != INADDR_ANY) + arprequest(ifp, &addr, &addr, enaddr); } /* Modified: head/sys/netinet/if_ether.h ============================================================================== --- head/sys/netinet/if_ether.h Mon Nov 9 10:11:14 2015 (r290603) +++ head/sys/netinet/if_ether.h Mon Nov 9 10:35:33 2015 (r290604) @@ -119,7 +119,7 @@ int arpresolve(struct ifnet *ifp, int is void arprequest(struct ifnet *, const struct in_addr *, const struct in_addr *, u_char *); void arp_ifinit(struct ifnet *, struct ifaddr *); -void arp_ifinit2(struct ifnet *, struct ifaddr *, u_char *); +void arp_announce_ifaddr(struct ifnet *, struct in_addr addr, u_char *); #endif #endif Modified: head/sys/netinet/ip_carp.c ============================================================================== --- head/sys/netinet/ip_carp.c Mon Nov 9 10:11:14 2015 (r290603) +++ head/sys/netinet/ip_carp.c Mon Nov 9 10:35:33 2015 (r290604) @@ -1009,10 +1009,14 @@ static void carp_send_arp(struct carp_softc *sc) { struct ifaddr *ifa; + struct in_addr addr; - CARP_FOREACH_IFA(sc, ifa) - if (ifa->ifa_addr->sa_family == AF_INET) - arp_ifinit2(sc->sc_carpdev, ifa, LLADDR(&sc->sc_addr)); + CARP_FOREACH_IFA(sc, ifa) { + if (ifa->ifa_addr->sa_family != AF_INET) + continue; + addr = ((struct sockaddr_in *)ifa->ifa_addr)->sin_addr; + arp_announce_ifaddr(sc->sc_carpdev, addr, LLADDR(&sc->sc_addr)); + } } int
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201511091035.tA9AZYbP037863>