diff --git a/sys/net/if.c b/sys/net/if.c --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1708,18 +1708,18 @@ } /* - * Locate an interface based on a complete address. + * Locate an interface on the specified fib based on a complete address. */ -/*ARGSUSED*/ struct ifaddr * -ifa_ifwithaddr(const struct sockaddr *addr) +ifa_ifwithaddr_fib(const struct sockaddr *addr, int fibnum) { struct ifnet *ifp; struct ifaddr *ifa; NET_EPOCH_ASSERT(); - CK_STAILQ_FOREACH(ifp, &V_ifnet, if_link) { + if ((fibnum != RT_ALL_FIBS) && (ifp->if_fib != fibnum)) + continue; CK_STAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { if (ifa->ifa_addr->sa_family != addr->sa_family) continue; @@ -1740,18 +1740,35 @@ return (ifa); } +/* + * Locate an interface based on a complete address. + */ +struct ifaddr * +ifa_ifwithaddr(const struct sockaddr *addr) +{ + + return (ifa_ifwithaddr_fib(addr, RT_ALL_FIBS)); +} + int -ifa_ifwithaddr_check(const struct sockaddr *addr) +ifa_ifwithaddr_fib_check(const struct sockaddr *addr, int fibnum) { struct epoch_tracker et; int rc; NET_EPOCH_ENTER(et); - rc = (ifa_ifwithaddr(addr) != NULL); + rc = (ifa_ifwithaddr_fib(addr, fibnum) != NULL); NET_EPOCH_EXIT(et); return (rc); } +int +ifa_ifwithaddr_check(const struct sockaddr *addr) +{ + + return (ifa_ifwithaddr_fib_check(addr, RT_ALL_FIBS)); +} + /* * Locate an interface based on the broadcast address. */ diff --git a/sys/net/if_var.h b/sys/net/if_var.h --- a/sys/net/if_var.h +++ b/sys/net/if_var.h @@ -563,7 +563,9 @@ int ifa_del_loopback_route(struct ifaddr *, struct sockaddr *); int ifa_switch_loopback_route(struct ifaddr *, struct sockaddr *); +struct ifaddr *ifa_ifwithaddr_fib(const struct sockaddr *, int); struct ifaddr *ifa_ifwithaddr(const struct sockaddr *); +int ifa_ifwithaddr_fib_check(const struct sockaddr *, int); int ifa_ifwithaddr_check(const struct sockaddr *); struct ifaddr *ifa_ifwithbroadaddr(const struct sockaddr *, int); struct ifaddr *ifa_ifwithdstaddr(const struct sockaddr *, int);