summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormelifaro <melifaro@FreeBSD.org>2015-11-09 10:35:33 +0000
committermelifaro <melifaro@FreeBSD.org>2015-11-09 10:35:33 +0000
commit90aacc3eb3f432db004a9ee2b93ce58c0ac7a188 (patch)
tree7cf9586dd8a7f503c743a143724be1df8764fdc7
parenta0ced91366c8e5d12333b1c0cc8cb100fd209fa2 (diff)
downloadFreeBSD-src-90aacc3eb3f432db004a9ee2b93ce58c0ac7a188.zip
FreeBSD-src-90aacc3eb3f432db004a9ee2b93ce58c0ac7a188.tar.gz
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).
-rw-r--r--sys/netinet/if_ether.c51
-rw-r--r--sys/netinet/if_ether.h2
-rw-r--r--sys/netinet/ip_carp.c10
3 files changed, 36 insertions, 27 deletions
diff --git a/sys/netinet/if_ether.c b/sys/netinet/if_ether.c
index fd005c7..dfba0b2 100644
--- a/sys/netinet/if_ether.c
+++ b/sys/netinet/if_ether.c
@@ -1091,26 +1091,13 @@ arp_mark_lle_reachable(struct llentry *la)
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 ifaddr *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);
}
/*
diff --git a/sys/netinet/if_ether.h b/sys/netinet/if_ether.h
index f23da5b..1583ca5 100644
--- a/sys/netinet/if_ether.h
+++ b/sys/netinet/if_ether.h
@@ -119,7 +119,7 @@ int arpresolve(struct ifnet *ifp, int is_gw, struct mbuf *m,
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
diff --git a/sys/netinet/ip_carp.c b/sys/netinet/ip_carp.c
index c09d895..849d7d2 100644
--- a/sys/netinet/ip_carp.c
+++ b/sys/netinet/ip_carp.c
@@ -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
OpenPOWER on IntegriCloud