summaryrefslogtreecommitdiffstats
path: root/sys/netinet/raw_ip.c
diff options
context:
space:
mode:
authorsmh <smh@FreeBSD.org>2014-05-26 22:54:15 +0000
committersmh <smh@FreeBSD.org>2014-05-26 22:54:15 +0000
commit873b20c0ff82983e12fd6594ed634830f455f3ab (patch)
treee10bdf700d603324de6d65a642970053a8a04fd2 /sys/netinet/raw_ip.c
parent5f95900ee1af25b2f5313c465d77e2420e9562b6 (diff)
downloadFreeBSD-src-873b20c0ff82983e12fd6594ed634830f455f3ab.zip
FreeBSD-src-873b20c0ff82983e12fd6594ed634830f455f3ab.tar.gz
MFC r264879
Fix jailed raw sockets not setting the correct source address by calling in_pcbladdr instead of prison_get_ip4. Sponsored by: Multiplay
Diffstat (limited to 'sys/netinet/raw_ip.c')
-rw-r--r--sys/netinet/raw_ip.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/sys/netinet/raw_ip.c b/sys/netinet/raw_ip.c
index eddc69e..b8da2f4 100644
--- a/sys/netinet/raw_ip.c
+++ b/sys/netinet/raw_ip.c
@@ -453,26 +453,26 @@ rip_output(struct mbuf *m, struct socket *so, u_long dst)
ip->ip_p = inp->inp_ip_p;
ip->ip_len = htons(m->m_pkthdr.len);
ip->ip_src = inp->inp_laddr;
+ ip->ip_dst.s_addr = dst;
if (jailed(inp->inp_cred)) {
/*
* prison_local_ip4() would be good enough but would
* let a source of INADDR_ANY pass, which we do not
- * want to see from jails. We do not go through the
- * pain of in_pcbladdr() for raw sockets.
+ * want to see from jails.
*/
- if (ip->ip_src.s_addr == INADDR_ANY)
- error = prison_get_ip4(inp->inp_cred,
- &ip->ip_src);
- else
+ if (ip->ip_src.s_addr == INADDR_ANY) {
+ error = in_pcbladdr(inp, &ip->ip_dst, &ip->ip_src,
+ inp->inp_cred);
+ } else {
error = prison_local_ip4(inp->inp_cred,
&ip->ip_src);
+ }
if (error != 0) {
INP_RUNLOCK(inp);
m_freem(m);
return (error);
}
}
- ip->ip_dst.s_addr = dst;
ip->ip_ttl = inp->inp_ip_ttl;
} else {
if (m->m_pkthdr.len > IP_MAXPACKET) {
OpenPOWER on IntegriCloud