diff options
author | Alexander V. Chernikov <melifaro@FreeBSD.org> | 2021-02-16 20:00:46 +0000 |
---|---|---|
committer | Alexander V. Chernikov <melifaro@FreeBSD.org> | 2021-02-16 20:00:46 +0000 |
commit | 9fdbf7eef5c006002769add15b1ebb8fa8d9e220 (patch) | |
tree | ed9ff841b298eb736f0cfa0dc5f8f523ea379f5c | |
parent | cc7b73065302005ebc4a19503188c8d6d5eb923d (diff) | |
download | src-9fdbf7eef5c0.tar.gz src-9fdbf7eef5c0.zip |
Make in_localip_more() fib-aware.
It fixes loopback route installation for the interfaces
in the different fibs using the same prefix.
Reviewed By: donner
PR: 189088
Differential Revision: https://reviews.freebsd.org/D28673
MFC after: 1 week
-rw-r--r-- | sys/netinet/in.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/sys/netinet/in.c b/sys/netinet/in.c index eb58c3453cfc..bcf071a81e0e 100644 --- a/sys/netinet/in.c +++ b/sys/netinet/in.c @@ -163,18 +163,23 @@ in_ifhasaddr(struct ifnet *ifp, struct in_addr in) * the supplied one but with same IP address value. */ static struct in_ifaddr * -in_localip_more(struct in_ifaddr *ia) +in_localip_more(struct in_ifaddr *original_ia) { struct rm_priotracker in_ifa_tracker; - in_addr_t in = IA_SIN(ia)->sin_addr.s_addr; - struct in_ifaddr *it; + in_addr_t original_addr = IA_SIN(original_ia)->sin_addr.s_addr; + uint32_t original_fib = original_ia->ia_ifa.ifa_ifp->if_fib; + struct in_ifaddr *ia; IN_IFADDR_RLOCK(&in_ifa_tracker); - LIST_FOREACH(it, INADDR_HASH(in), ia_hash) { - if (it != ia && IA_SIN(it)->sin_addr.s_addr == in) { - ifa_ref(&it->ia_ifa); + LIST_FOREACH(ia, INADDR_HASH(original_addr), ia_hash) { + in_addr_t addr = IA_SIN(ia)->sin_addr.s_addr; + uint32_t fib = ia->ia_ifa.ifa_ifp->if_fib; + if (!V_rt_add_addr_allfibs && (original_fib != fib)) + continue; + if ((original_ia != ia) && (original_addr == addr)) { + ifa_ref(&ia->ia_ifa); IN_IFADDR_RUNLOCK(&in_ifa_tracker); - return (it); + return (ia); } } IN_IFADDR_RUNLOCK(&in_ifa_tracker); @@ -1007,11 +1012,6 @@ in_scrubprefix(struct in_ifaddr *target, u_int flags) if (ia_need_loopback_route(target) && (flags & LLE_STATIC)) { struct in_ifaddr *eia; - /* - * XXXME: add fib-aware in_localip. - * We definitely don't want to switch between - * prefixes in different fibs. - */ eia = in_localip_more(target); if (eia != NULL) { |