summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYASUOKA Masahiko <yasuoka@cvs.openbsd.org>2014-10-28 11:02:39 +0000
committerYASUOKA Masahiko <yasuoka@cvs.openbsd.org>2014-10-28 11:02:39 +0000
commit32db03e6eeb5934bde3c193ce463cf88c7f1fa23 (patch)
tree920efca5837da47a4b2f5976cdff10af90000043
parent5838d93fc38a9fe3cf95e9f0fe598cddfbb4e5e2 (diff)
Select a proper source address when the bound address is
INADDR_BROADCAST the same as INADDR_ANY. ok mpi
-rw-r--r--sys/netinet/in_pcb.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c
index 6a6cb1c12bd..d8e1f74ef13 100644
--- a/sys/netinet/in_pcb.c
+++ b/sys/netinet/in_pcb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: in_pcb.c,v 1.160 2014/10/14 09:52:26 mpi Exp $ */
+/* $OpenBSD: in_pcb.c,v 1.161 2014/10/28 11:02:38 yasuoka Exp $ */
/* $NetBSD: in_pcb.c,v 1.25 1996/02/13 23:41:53 christos Exp $ */
/*
@@ -799,10 +799,11 @@ in_selectsrc(struct in_addr **insrc, struct sockaddr_in *sin,
struct in_ifaddr *ia = NULL;
/*
- * If the source address is not specified but the socket(if any)
- * is already bound, use the bound address.
+ * If the socket(if any) is already bound, use that bound address
+ * unless it is INADDR_ANY or INADDR_BROADCAST.
*/
- if (laddr && laddr->s_addr != INADDR_ANY) {
+ if (laddr && laddr->s_addr != INADDR_ANY &&
+ laddr->s_addr != INADDR_BROADCAST) {
*insrc = laddr;
return (0);
}