diff options
author | deischen <deischen@FreeBSD.org> | 2011-01-08 22:33:46 +0000 |
---|---|---|
committer | deischen <deischen@FreeBSD.org> | 2011-01-08 22:33:46 +0000 |
commit | 6fbd535b5a16e2601294be6e8c66395aeb60e468 (patch) | |
tree | 543f9bd5683de360721e252e29677a180e240fac | |
parent | 0ed3bd02d8dc1c65a161d1e4c6047fdd53e2e08f (diff) | |
download | FreeBSD-src-6fbd535b5a16e2601294be6e8c66395aeb60e468.zip FreeBSD-src-6fbd535b5a16e2601294be6e8c66395aeb60e468.tar.gz |
Make sure to always do source address selection on
an unbound socket, regardless of any multicast options.
If an address is specified via a multicast option, then
let it override normal the source address selection.
This fixes a bug where source address selection was
not being performed when multicast options were present
but without an interface being specified.
Reviewed by: bz
MFC after: 1 day
-rw-r--r-- | sys/netinet/in_pcb.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c index d742887..28cc029 100644 --- a/sys/netinet/in_pcb.c +++ b/sys/netinet/in_pcb.c @@ -874,9 +874,10 @@ in_pcbconnect_setup(struct inpcb *inp, struct sockaddr *nam, } } if (laddr.s_addr == INADDR_ANY) { + error = in_pcbladdr(inp, &faddr, &laddr, cred); /* * If the destination address is multicast and an outgoing - * interface has been set as a multicast option, use the + * interface has been set as a multicast option, prefer the * address of that interface as our source address. */ if (IN_MULTICAST(ntohl(faddr.s_addr)) && @@ -893,16 +894,16 @@ in_pcbconnect_setup(struct inpcb *inp, struct sockaddr *nam, break; if (ia == NULL) { IN_IFADDR_RUNLOCK(); - return (EADDRNOTAVAIL); + error = EADDRNOTAVAIL; + } else { + laddr = ia->ia_addr.sin_addr; + IN_IFADDR_RUNLOCK(); + error = 0; } - laddr = ia->ia_addr.sin_addr; - IN_IFADDR_RUNLOCK(); } - } else { - error = in_pcbladdr(inp, &faddr, &laddr, cred); - if (error) - return (error); } + if (error) + return (error); } oinp = in_pcblookup_hash(inp->inp_pcbinfo, faddr, fport, laddr, lport, 0, NULL); |