summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--share/man/man9/ifnet.920
-rw-r--r--sys/net/if.c22
-rw-r--r--sys/net/if_var.h11
-rw-r--r--sys/net/route.c26
-rw-r--r--sys/net/rtsock.c3
-rw-r--r--sys/netinet/in_pcb.c11
-rw-r--r--sys/netinet/ip_options.c7
-rw-r--r--sys/netinet/ip_output.c12
-rw-r--r--sys/netinet6/nd6.c2
-rw-r--r--sys/sys/param.h2
10 files changed, 57 insertions, 59 deletions
diff --git a/share/man/man9/ifnet.9 b/share/man/man9/ifnet.9
index ae21072..7aef4de 100644
--- a/share/man/man9/ifnet.9
+++ b/share/man/man9/ifnet.9
@@ -77,9 +77,9 @@
.Ft "struct ifaddr *"
.Fn ifa_ifwithaddr "struct sockaddr *addr"
.Ft "struct ifaddr *"
-.Fn ifa_ifwithdstaddr "struct sockaddr *addr"
+.Fn ifa_ifwithdstaddr "struct sockaddr *addr" "int fib"
.Ft "struct ifaddr *"
-.Fn ifa_ifwithnet "struct sockaddr *addr" "int ignore_ptp"
+.Fn ifa_ifwithnet "struct sockaddr *addr" "int ignore_ptp" "int fib"
.Ft "struct ifaddr *"
.Fn ifaof_ifpforaddr "struct sockaddr *addr" "struct ifnet *ifp"
.Ft void
@@ -1389,7 +1389,16 @@ returns an interface address for a point-to-point interface whose
remote
.Pq Dq destination
address is
-.Fa addr .
+.Fa addr
+and a fib is
+.Fa fib .
+If
+.Fa fib
+is
+.Dv RT_ALL_FIBS ,
+then the first interface address matching
+.Fa addr
+will be returned.
.Pp
.Fn ifa_ifwithnet
returns the most specific interface address which matches the
@@ -1401,7 +1410,10 @@ address whose remote address is
if one is found.
If
.Fa ignore_ptp
-is true, skip point-to-point interface addresses.
+is true, skip point-to-point interface addresses. The
+.Fa fib
+parameter is handled the same way as by
+.Fn ifa_ifwithdstaddr .
.Pp
.Fn ifaof_ifpforaddr
returns the most specific address configured on interface
diff --git a/sys/net/if.c b/sys/net/if.c
index 06993e3..017af33 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -1694,13 +1694,15 @@ ifa_ifwithaddr_check(struct sockaddr *addr)
*/
/* ARGSUSED */
struct ifaddr *
-ifa_ifwithbroadaddr(struct sockaddr *addr)
+ifa_ifwithbroadaddr(struct sockaddr *addr, int fibnum)
{
struct ifnet *ifp;
struct ifaddr *ifa;
IFNET_RLOCK_NOSLEEP();
TAILQ_FOREACH(ifp, &V_ifnet, if_link) {
+ if ((fibnum != RT_ALL_FIBS) && (ifp->if_fib != fibnum))
+ continue;
IF_ADDR_RLOCK(ifp);
TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) {
if (ifa->ifa_addr->sa_family != addr->sa_family)
@@ -1727,7 +1729,7 @@ done:
*/
/*ARGSUSED*/
struct ifaddr *
-ifa_ifwithdstaddr_fib(struct sockaddr *addr, int fibnum)
+ifa_ifwithdstaddr(struct sockaddr *addr, int fibnum)
{
struct ifnet *ifp;
struct ifaddr *ifa;
@@ -1757,19 +1759,12 @@ done:
return (ifa);
}
-struct ifaddr *
-ifa_ifwithdstaddr(struct sockaddr *addr)
-{
-
- return (ifa_ifwithdstaddr_fib(addr, RT_ALL_FIBS));
-}
-
/*
* Find an interface on a specific network. If many, choice
* is most specific found.
*/
struct ifaddr *
-ifa_ifwithnet_fib(struct sockaddr *addr, int ignore_ptp, int fibnum)
+ifa_ifwithnet(struct sockaddr *addr, int ignore_ptp, int fibnum)
{
struct ifnet *ifp;
struct ifaddr *ifa;
@@ -1867,13 +1862,6 @@ done:
return (ifa);
}
-struct ifaddr *
-ifa_ifwithnet(struct sockaddr *addr, int ignore_ptp)
-{
-
- return (ifa_ifwithnet_fib(addr, ignore_ptp, RT_ALL_FIBS));
-}
-
/*
* Find an interface address specific to an interface best matching
* a given address.
diff --git a/sys/net/if_var.h b/sys/net/if_var.h
index 3bffefe..09f41b8 100644
--- a/sys/net/if_var.h
+++ b/sys/net/if_var.h
@@ -513,13 +513,10 @@ int ifa_switch_loopback_route(struct ifaddr *, struct sockaddr *, int fib);
struct ifaddr *ifa_ifwithaddr(struct sockaddr *);
int ifa_ifwithaddr_check(struct sockaddr *);
-struct ifaddr *ifa_ifwithbroadaddr(struct sockaddr *);
-struct ifaddr *ifa_ifwithdstaddr(struct sockaddr *);
-struct ifaddr *ifa_ifwithdstaddr_fib(struct sockaddr *, int);
-struct ifaddr *ifa_ifwithnet(struct sockaddr *, int);
-struct ifaddr *ifa_ifwithnet_fib(struct sockaddr *, int, int);
-struct ifaddr *ifa_ifwithroute(int, struct sockaddr *, struct sockaddr *);
-struct ifaddr *ifa_ifwithroute_fib(int, struct sockaddr *, struct sockaddr *, u_int);
+struct ifaddr *ifa_ifwithbroadaddr(struct sockaddr *, int);
+struct ifaddr *ifa_ifwithdstaddr(struct sockaddr *, int);
+struct ifaddr *ifa_ifwithnet(struct sockaddr *, int, int);
+struct ifaddr *ifa_ifwithroute(int, struct sockaddr *, struct sockaddr *, u_int);
struct ifaddr *ifaof_ifpforaddr(struct sockaddr *, struct ifnet *);
int ifa_preferred(struct ifaddr *, struct ifaddr *);
diff --git a/sys/net/route.c b/sys/net/route.c
index 547418a..2e0bb99 100644
--- a/sys/net/route.c
+++ b/sys/net/route.c
@@ -570,7 +570,7 @@ rtredirect_fib(struct sockaddr *dst,
}
/* verify the gateway is directly reachable */
- if ((ifa = ifa_ifwithnet_fib(gateway, 0, fibnum)) == NULL) {
+ if ((ifa = ifa_ifwithnet(gateway, 0, fibnum)) == NULL) {
error = ENETUNREACH;
goto out;
}
@@ -700,18 +700,8 @@ rtioctl_fib(u_long req, caddr_t data, u_int fibnum)
#endif /* INET */
}
-/*
- * For both ifa_ifwithroute() routines, 'ifa' is returned referenced.
- */
-struct ifaddr *
-ifa_ifwithroute(int flags, struct sockaddr *dst, struct sockaddr *gateway)
-{
-
- return (ifa_ifwithroute_fib(flags, dst, gateway, RT_DEFAULT_FIB));
-}
-
struct ifaddr *
-ifa_ifwithroute_fib(int flags, struct sockaddr *dst, struct sockaddr *gateway,
+ifa_ifwithroute(int flags, struct sockaddr *dst, struct sockaddr *gateway,
u_int fibnum)
{
struct ifaddr *ifa;
@@ -727,7 +717,7 @@ ifa_ifwithroute_fib(int flags, struct sockaddr *dst, struct sockaddr *gateway,
*/
ifa = NULL;
if (flags & RTF_HOST)
- ifa = ifa_ifwithdstaddr_fib(dst, fibnum);
+ ifa = ifa_ifwithdstaddr(dst, fibnum);
if (ifa == NULL)
ifa = ifa_ifwithaddr(gateway);
} else {
@@ -736,10 +726,10 @@ ifa_ifwithroute_fib(int flags, struct sockaddr *dst, struct sockaddr *gateway,
* or host, the gateway may still be on the
* other end of a pt to pt link.
*/
- ifa = ifa_ifwithdstaddr_fib(gateway, fibnum);
+ ifa = ifa_ifwithdstaddr(gateway, fibnum);
}
if (ifa == NULL)
- ifa = ifa_ifwithnet_fib(gateway, 0, fibnum);
+ ifa = ifa_ifwithnet(gateway, 0, fibnum);
if (ifa == NULL) {
struct rtentry *rt = rtalloc1_fib(gateway, 0, RTF_RNH_LOCKED, fibnum);
if (rt == NULL)
@@ -853,7 +843,7 @@ rt_getifa_fib(struct rt_addrinfo *info, u_int fibnum)
*/
if (info->rti_ifp == NULL && ifpaddr != NULL &&
ifpaddr->sa_family == AF_LINK &&
- (ifa = ifa_ifwithnet_fib(ifpaddr, 0, fibnum)) != NULL) {
+ (ifa = ifa_ifwithnet(ifpaddr, 0, fibnum)) != NULL) {
info->rti_ifp = ifa->ifa_ifp;
ifa_free(ifa);
}
@@ -867,10 +857,10 @@ rt_getifa_fib(struct rt_addrinfo *info, u_int fibnum)
if (sa != NULL && info->rti_ifp != NULL)
info->rti_ifa = ifaof_ifpforaddr(sa, info->rti_ifp);
else if (dst != NULL && gateway != NULL)
- info->rti_ifa = ifa_ifwithroute_fib(flags, dst, gateway,
+ info->rti_ifa = ifa_ifwithroute(flags, dst, gateway,
fibnum);
else if (sa != NULL)
- info->rti_ifa = ifa_ifwithroute_fib(flags, sa, sa,
+ info->rti_ifa = ifa_ifwithroute(flags, sa, sa,
fibnum);
}
if ((ifa = info->rti_ifa) != NULL) {
diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c
index 10baeb2..a4d8148 100644
--- a/sys/net/rtsock.c
+++ b/sys/net/rtsock.c
@@ -752,7 +752,8 @@ route_output(struct mbuf *m, struct socket *so, ...)
rt->rt_ifp->if_type == IFT_PROPVIRTUAL) {
struct ifaddr *ifa;
- ifa = ifa_ifwithnet(info.rti_info[RTAX_DST], 1);
+ ifa = ifa_ifwithnet(info.rti_info[RTAX_DST], 1,
+ RT_ALL_FIBS);
if (ifa != NULL)
rt_maskedcopy(ifa->ifa_addr,
&laddr,
diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c
index 32d2d05..4af57dc 100644
--- a/sys/netinet/in_pcb.c
+++ b/sys/netinet/in_pcb.c
@@ -792,9 +792,11 @@ in_pcbladdr(struct inpcb *inp, struct in_addr *faddr, struct in_addr *laddr,
struct in_ifaddr *ia;
struct ifnet *ifp;
- ia = ifatoia(ifa_ifwithdstaddr((struct sockaddr *)sin));
+ ia = ifatoia(ifa_ifwithdstaddr((struct sockaddr *)sin,
+ RT_ALL_FIBS));
if (ia == NULL)
- ia = ifatoia(ifa_ifwithnet((struct sockaddr *)sin, 0));
+ ia = ifatoia(ifa_ifwithnet((struct sockaddr *)sin, 0,
+ RT_ALL_FIBS));
if (ia == NULL) {
error = ENETUNREACH;
goto done;
@@ -909,9 +911,10 @@ in_pcbladdr(struct inpcb *inp, struct in_addr *faddr, struct in_addr *laddr,
sain.sin_len = sizeof(struct sockaddr_in);
sain.sin_addr.s_addr = faddr->s_addr;
- ia = ifatoia(ifa_ifwithdstaddr(sintosa(&sain)));
+ ia = ifatoia(ifa_ifwithdstaddr(sintosa(&sain), RT_ALL_FIBS));
if (ia == NULL)
- ia = ifatoia(ifa_ifwithnet(sintosa(&sain), 0));
+ ia = ifatoia(ifa_ifwithnet(sintosa(&sain), 0,
+ RT_ALL_FIBS));
if (ia == NULL)
ia = ifatoia(ifa_ifwithaddr(sintosa(&sain)));
diff --git a/sys/netinet/ip_options.c b/sys/netinet/ip_options.c
index 8911992..94bec4e 100644
--- a/sys/netinet/ip_options.c
+++ b/sys/netinet/ip_options.c
@@ -227,8 +227,11 @@ dropit:
if (opt == IPOPT_SSRR) {
#define INA struct in_ifaddr *
#define SA struct sockaddr *
- if ((ia = (INA)ifa_ifwithdstaddr((SA)&ipaddr)) == NULL)
- ia = (INA)ifa_ifwithnet((SA)&ipaddr, 0);
+ ia = (INA)ifa_ifwithdstaddr((SA)&ipaddr,
+ RT_ALL_FIBS);
+ if (ia == NULL)
+ ia = (INA)ifa_ifwithnet((SA)&ipaddr, 0,
+ RT_ALL_FIBS);
} else
/* XXX MRT 0 for routing */
ia = ip_rtaddr(ipaddr.sin_addr, M_GETFIB(m));
diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c
index b5edea0..61e6dc8 100644
--- a/sys/netinet/ip_output.c
+++ b/sys/netinet/ip_output.c
@@ -235,8 +235,10 @@ again:
* or the destination address of a ptp interface.
*/
if (flags & IP_SENDONES) {
- if ((ia = ifatoia(ifa_ifwithbroadaddr(sintosa(dst)))) == NULL &&
- (ia = ifatoia(ifa_ifwithdstaddr(sintosa(dst)))) == NULL) {
+ if ((ia = ifatoia(ifa_ifwithbroadaddr(sintosa(dst),
+ RT_ALL_FIBS))) == NULL &&
+ (ia = ifatoia(ifa_ifwithdstaddr(sintosa(dst),
+ RT_ALL_FIBS))) == NULL) {
IPSTAT_INC(ips_noroute);
error = ENETUNREACH;
goto bad;
@@ -248,8 +250,10 @@ again:
ip->ip_ttl = 1;
isbroadcast = 1;
} else if (flags & IP_ROUTETOIF) {
- if ((ia = ifatoia(ifa_ifwithdstaddr(sintosa(dst)))) == NULL &&
- (ia = ifatoia(ifa_ifwithnet(sintosa(dst), 0))) == NULL) {
+ if ((ia = ifatoia(ifa_ifwithdstaddr(sintosa(dst),
+ RT_ALL_FIBS))) == NULL &&
+ (ia = ifatoia(ifa_ifwithnet(sintosa(dst), 0,
+ RT_ALL_FIBS))) == NULL) {
IPSTAT_INC(ips_noroute);
error = ENETUNREACH;
goto bad;
diff --git a/sys/netinet6/nd6.c b/sys/netinet6/nd6.c
index 54366ee..e48cb8a 100644
--- a/sys/netinet6/nd6.c
+++ b/sys/netinet6/nd6.c
@@ -945,7 +945,7 @@ nd6_is_new_addr_neighbor(struct sockaddr_in6 *addr, struct ifnet *ifp)
* If the address is assigned on the node of the other side of
* a p2p interface, the address should be a neighbor.
*/
- dstaddr = ifa_ifwithdstaddr((struct sockaddr *)addr);
+ dstaddr = ifa_ifwithdstaddr((struct sockaddr *)addr, RT_ALL_FIBS);
if (dstaddr != NULL) {
if (dstaddr->ifa_ifp == ifp) {
ifa_free(dstaddr);
diff --git a/sys/sys/param.h b/sys/sys/param.h
index 8ddd333..b141c0a 100644
--- a/sys/sys/param.h
+++ b/sys/sys/param.h
@@ -58,7 +58,7 @@
* in the range 5 to 9.
*/
#undef __FreeBSD_version
-#define __FreeBSD_version 1100031 /* Master, propagated to newvers */
+#define __FreeBSD_version 1100032 /* Master, propagated to newvers */
/*
* __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,
OpenPOWER on IntegriCloud