summaryrefslogtreecommitdiff
path: root/sys/netinet/raw_ip.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/netinet/raw_ip.c')
-rw-r--r--sys/netinet/raw_ip.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/sys/netinet/raw_ip.c b/sys/netinet/raw_ip.c
index 5992ce16f132..4d1ebadbb565 100644
--- a/sys/netinet/raw_ip.c
+++ b/sys/netinet/raw_ip.c
@@ -257,6 +257,7 @@ rip_input(struct mbuf *m, int off)
if (inp->inp_ip_p != proto)
continue;
#ifdef INET6
+ /* XXX inp locking */
if ((inp->inp_vflag & INP_IPV4) == 0)
continue;
#endif
@@ -264,11 +265,9 @@ rip_input(struct mbuf *m, int off)
continue;
if (inp->inp_faddr.s_addr != ip->ip_src.s_addr)
continue;
- INP_RLOCK(inp);
- if (jailed(inp->inp_socket->so_cred) &&
- (htonl(prison_getip(inp->inp_socket->so_cred)) !=
+ if (jailed(inp->inp_cred) &&
+ (htonl(prison_getip(inp->inp_cred)) !=
ip->ip_dst.s_addr)) {
- INP_RUNLOCK(inp);
continue;
}
if (last) {
@@ -280,12 +279,14 @@ rip_input(struct mbuf *m, int off)
/* XXX count dropped packet */
INP_RUNLOCK(last);
}
+ INP_RLOCK(inp);
last = inp;
}
LIST_FOREACH(inp, &ripcbinfo.ipi_hashbase[0], inp_hash) {
if (inp->inp_ip_p && inp->inp_ip_p != proto)
continue;
#ifdef INET6
+ /* XXX inp locking */
if ((inp->inp_vflag & INP_IPV4) == 0)
continue;
#endif
@@ -295,11 +296,9 @@ rip_input(struct mbuf *m, int off)
if (inp->inp_faddr.s_addr &&
inp->inp_faddr.s_addr != ip->ip_src.s_addr)
continue;
- INP_RLOCK(inp);
- if (jailed(inp->inp_socket->so_cred) &&
- (htonl(prison_getip(inp->inp_socket->so_cred)) !=
+ if (jailed(inp->inp_cred) &&
+ (htonl(prison_getip(inp->inp_cred)) !=
ip->ip_dst.s_addr)) {
- INP_RUNLOCK(inp);
continue;
}
if (last) {
@@ -311,6 +310,7 @@ rip_input(struct mbuf *m, int off)
/* XXX count dropped packet */
INP_RUNLOCK(last);
}
+ INP_RLOCK(inp);
last = inp;
}
INP_INFO_RUNLOCK(&ripcbinfo);
@@ -360,9 +360,9 @@ rip_output(struct mbuf *m, struct socket *so, u_long dst)
ip->ip_off = 0;
ip->ip_p = inp->inp_ip_p;
ip->ip_len = m->m_pkthdr.len;
- if (jailed(inp->inp_socket->so_cred))
+ if (jailed(inp->inp_cred))
ip->ip_src.s_addr =
- htonl(prison_getip(inp->inp_socket->so_cred));
+ htonl(prison_getip(inp->inp_cred));
else
ip->ip_src = inp->inp_laddr;
ip->ip_dst.s_addr = dst;
@@ -374,9 +374,9 @@ rip_output(struct mbuf *m, struct socket *so, u_long dst)
}
INP_RLOCK(inp);
ip = mtod(m, struct ip *);
- if (jailed(inp->inp_socket->so_cred)) {
+ if (jailed(inp->inp_cred)) {
if (ip->ip_src.s_addr !=
- htonl(prison_getip(inp->inp_socket->so_cred))) {
+ htonl(prison_getip(inp->inp_cred))) {
INP_RUNLOCK(inp);
m_freem(m);
return (EPERM);