1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-20 11:11:24 +00:00

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
This commit is contained in:
Daniel Eischen 2011-01-08 22:33:46 +00:00
parent 5eea74f248
commit d79fdd98c3
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=217169

View File

@ -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);