Mercurial > hg > dhcpcd
changeset 4533:33a7edb3a44a draft
arp: announce address from most preferred interface
Now we no longer sort interfaces, this is needed.
| author | Roy Marples <roy@marples.name> |
|---|---|
| date | Fri, 14 Jun 2019 17:03:55 +0100 |
| parents | 23730414d0a6 |
| children | 003dc9907bba |
| files | src/arp.c |
| diffstat | 1 files changed, 14 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/src/arp.c Fri Jun 14 15:22:43 2019 +0100 +++ b/src/arp.c Fri Jun 14 17:03:55 2019 +0100 @@ -512,22 +512,27 @@ void arp_announceaddr(struct dhcpcd_ctx *ctx, const struct in_addr *ia) { - struct interface *ifp; - struct ipv4_addr *iaf; + struct interface *ifp, *iff = NULL; + struct ipv4_addr *iap; TAILQ_FOREACH(ifp, ctx->ifaces, next) { - iaf = ipv4_iffindaddr(ifp, ia, NULL); + if (!ifp->active || ifp->carrier <= LINK_DOWN) + continue; + iap = ipv4_iffindaddr(ifp, ia, NULL); + if (iap == NULL) + continue; #ifdef IN_IFF_NOTUSEABLE - if (iaf && !(iaf->addr_flags & IN_IFF_NOTUSEABLE)) -#else - if (iaf) + if (!(iap->addr_flags & IN_IFF_NOTUSEABLE)) + continue; #endif - break; + if (iff != NULL && iff->metric < ifp->metric) + continue; + iff = ifp; } - if (ifp == NULL) + if (iff == NULL) return; - arp_ifannounceaddr(ifp, ia); + arp_ifannounceaddr(iff, ia); } struct arp_state *
