aboutsummaryrefslogtreecommitdiff
path: root/sys/netinet
diff options
context:
space:
mode:
authorBruce M Simpson <bms@FreeBSD.org>2007-03-13 22:12:23 +0000
committerBruce M Simpson <bms@FreeBSD.org>2007-03-13 22:12:23 +0000
commit238790e9e8666f6e45eda36d42e130c7e513fc48 (patch)
tree94449cce569b1b00562916e5155f97f5f0b51f4d /sys/netinet
parent10e7d3e737e4a89d8f2926e2f7d9087123160989 (diff)
Notes
Diffstat (limited to 'sys/netinet')
-rw-r--r--sys/netinet/udp_usrreq.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c
index 064f1e2f321f..493f1fd8a555 100644
--- a/sys/netinet/udp_usrreq.c
+++ b/sys/netinet/udp_usrreq.c
@@ -745,7 +745,7 @@ udp_output(inp, m, addr, control, td)
return EMSGSIZE;
}
- src.sin_addr.s_addr = INADDR_ANY;
+ src.sin_family = 0;
if (control != NULL) {
/*
* XXX: Currently, we assume all the optional information
@@ -795,7 +795,7 @@ udp_output(inp, m, addr, control, td)
return error;
}
- if (src.sin_addr.s_addr != INADDR_ANY ||
+ if (src.sin_family == AF_INET ||
addr != NULL) {
INP_INFO_WLOCK(&udbinfo);
unlock_udbinfo = 1;
@@ -807,10 +807,17 @@ udp_output(inp, m, addr, control, td)
mac_create_mbuf_from_inpcb(inp, m);
#endif
+ /*
+ * If the IP_SENDSRCADDR control message was specified, override the
+ * source address for this datagram. Its use is invalidated if the
+ * address thus specified is incomplete or clobbers other inpcbs.
+ */
laddr = inp->inp_laddr;
lport = inp->inp_lport;
- if (src.sin_addr.s_addr != INADDR_ANY) {
- if (lport == 0) {
+ if (src.sin_family == AF_INET) {
+ if ((lport == 0) ||
+ (laddr.s_addr == INADDR_ANY &&
+ src.sin_addr.s_addr == INADDR_ANY)) {
error = EINVAL;
goto release;
}