summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorasomers <asomers@FreeBSD.org>2014-09-16 15:28:19 +0000
committerasomers <asomers@FreeBSD.org>2014-09-16 15:28:19 +0000
commitc1b1b15f4155d86948b424f21d5a470db722acb6 (patch)
treeefb87570ceb0b3db8b37c997ab699becf72b48ea
parent996f057a5f8091b1ba6d27f03320e2c8d62a02c9 (diff)
downloadFreeBSD-src-c1b1b15f4155d86948b424f21d5a470db722acb6.zip
FreeBSD-src-c1b1b15f4155d86948b424f21d5a470db722acb6.tar.gz
Fix source address selection on unbound sockets in the presence of multiple
fibs. Use the mbuf's or the socket's fib instead of RT_ALL_FIBS. Fixes PR 187553. Also fixes netperf's UDP_STREAM test on a nondefault fib. sys/netinet/ip_output.c In ip_output, lookup the source address using the mbuf's fib instead of RT_ALL_FIBS. sys/netinet/in_pcb.c in in_pcbladdr, lookup the source address using the socket's fib, because we don't seem to have the mbuf fib. They should be the same, though. tests/sys/net/fibs_test.sh Clear the expected failure on udp_dontroute. PR: 187553 CR: https://reviews.freebsd.org/D772 MFC after: 3 weeks Sponsored by: Spectra Logic
-rw-r--r--sys/netinet/in_pcb.c9
-rw-r--r--sys/netinet/ip_output.c8
-rwxr-xr-xtests/sys/netinet/fibs_test.sh1
3 files changed, 9 insertions, 9 deletions
diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c
index 4af57dc..a0a1b30 100644
--- a/sys/netinet/in_pcb.c
+++ b/sys/netinet/in_pcb.c
@@ -793,10 +793,10 @@ in_pcbladdr(struct inpcb *inp, struct in_addr *faddr, struct in_addr *laddr,
struct ifnet *ifp;
ia = ifatoia(ifa_ifwithdstaddr((struct sockaddr *)sin,
- RT_ALL_FIBS));
+ inp->inp_socket->so_fibnum));
if (ia == NULL)
ia = ifatoia(ifa_ifwithnet((struct sockaddr *)sin, 0,
- RT_ALL_FIBS));
+ inp->inp_socket->so_fibnum));
if (ia == NULL) {
error = ENETUNREACH;
goto done;
@@ -911,10 +911,11 @@ 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), RT_ALL_FIBS));
+ ia = ifatoia(ifa_ifwithdstaddr(sintosa(&sain),
+ inp->inp_socket->so_fibnum));
if (ia == NULL)
ia = ifatoia(ifa_ifwithnet(sintosa(&sain), 0,
- RT_ALL_FIBS));
+ inp->inp_socket->so_fibnum));
if (ia == NULL)
ia = ifatoia(ifa_ifwithaddr(sintosa(&sain)));
diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c
index 61e6dc8..7079650 100644
--- a/sys/netinet/ip_output.c
+++ b/sys/netinet/ip_output.c
@@ -236,9 +236,9 @@ again:
*/
if (flags & IP_SENDONES) {
if ((ia = ifatoia(ifa_ifwithbroadaddr(sintosa(dst),
- RT_ALL_FIBS))) == NULL &&
+ M_GETFIB(m)))) == NULL &&
(ia = ifatoia(ifa_ifwithdstaddr(sintosa(dst),
- RT_ALL_FIBS))) == NULL) {
+ M_GETFIB(m)))) == NULL) {
IPSTAT_INC(ips_noroute);
error = ENETUNREACH;
goto bad;
@@ -251,9 +251,9 @@ again:
isbroadcast = 1;
} else if (flags & IP_ROUTETOIF) {
if ((ia = ifatoia(ifa_ifwithdstaddr(sintosa(dst),
- RT_ALL_FIBS))) == NULL &&
+ M_GETFIB(m)))) == NULL &&
(ia = ifatoia(ifa_ifwithnet(sintosa(dst), 0,
- RT_ALL_FIBS))) == NULL) {
+ M_GETFIB(m)))) == NULL) {
IPSTAT_INC(ips_noroute);
error = ENETUNREACH;
goto bad;
diff --git a/tests/sys/netinet/fibs_test.sh b/tests/sys/netinet/fibs_test.sh
index 72ebcfc..2dc3169 100755
--- a/tests/sys/netinet/fibs_test.sh
+++ b/tests/sys/netinet/fibs_test.sh
@@ -366,7 +366,6 @@ udp_dontroute_head()
udp_dontroute_body()
{
- atf_expect_fail "kern/187553 Source address selection for UDP packets with SO_DONTROUTE uses the default FIB"
# Configure the TAP interface to use an RFC5737 nonrouteable address
# and a non-default fib
ADDR0="192.0.2.2"
OpenPOWER on IntegriCloud