summaryrefslogtreecommitdiffstats
path: root/sys/netinet6/raw_ip6.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/netinet6/raw_ip6.c')
-rw-r--r--sys/netinet6/raw_ip6.c45
1 files changed, 38 insertions, 7 deletions
diff --git a/sys/netinet6/raw_ip6.c b/sys/netinet6/raw_ip6.c
index 2dcec0c..5fbd7c9 100644
--- a/sys/netinet6/raw_ip6.c
+++ b/sys/netinet6/raw_ip6.c
@@ -182,9 +182,16 @@ rip6_input(mp, offp, proto)
} else
#endif /*IPSEC*/
if (n) {
- if (last->in6p_flags & IN6P_CONTROLOPTS ||
- last->in6p_socket->so_options & SO_TIMESTAMP)
+ if (last->in6p_flags & IN6P_CONTROLOPTS)
ip6_savecontrol(last, &opts, ip6, n);
+ else {
+ SOCK_LOCK(last->in6p_socket);
+ if (last->in6p_socket->so_options & SO_TIMESTAMP) {
+ SOCK_UNLOCK(last->in6p_socket);
+ ip6_savecontrol(last, &opts, ip6, n);
+ } else
+ SOCK_UNLOCK(last->in6p_socket);
+ }
/* strip intermediate headers */
m_adj(n, *offp);
if (sbappendaddr(&last->in6p_socket->so_rcv,
@@ -194,8 +201,11 @@ rip6_input(mp, offp, proto)
if (opts)
m_freem(opts);
rip6stat.rip6s_fullsock++;
- } else
+ } else {
+ SOCK_LOCK(last->in6p_socket);
sorwakeup(last->in6p_socket);
+ SOCK_UNLOCK(last->in6p_socket);
+ }
opts = NULL;
}
}
@@ -213,9 +223,16 @@ rip6_input(mp, offp, proto)
} else
#endif /*IPSEC*/
if (last) {
- if (last->in6p_flags & IN6P_CONTROLOPTS ||
- last->in6p_socket->so_options & SO_TIMESTAMP)
+ if (last->in6p_flags & IN6P_CONTROLOPTS)
ip6_savecontrol(last, &opts, ip6, m);
+ else {
+ SOCK_LOCK(last->in6p_socket);
+ if (last->in6p_socket->so_options & SO_TIMESTAMP) {
+ SOCK_UNLOCK(last->in6p_socket);
+ ip6_savecontrol(last, &opts, ip6, m);
+ } else
+ SOCK_UNLOCK(last->in6p_socket);
+ }
/* strip intermediate headers */
m_adj(m, *offp);
if (sbappendaddr(&last->in6p_socket->so_rcv,
@@ -224,8 +241,11 @@ rip6_input(mp, offp, proto)
if (opts)
m_freem(opts);
rip6stat.rip6s_fullsock++;
- } else
+ } else {
+ SOCK_LOCK(last->in6p_socket);
sorwakeup(last->in6p_socket);
+ SOCK_UNLOCK(last->in6p_socket);
+ }
} else {
rip6stat.rip6s_nosock++;
if (m->m_flags & M_MCAST)
@@ -591,7 +611,9 @@ rip6_detach(struct socket *so)
static int
rip6_abort(struct socket *so)
{
+ SOCK_LOCK(so);
soisdisconnected(so);
+ SOCK_UNLOCK(so);
return rip6_detach(so);
}
@@ -600,8 +622,12 @@ rip6_disconnect(struct socket *so)
{
struct inpcb *inp = sotoinpcb(so);
- if ((so->so_state & SS_ISCONNECTED) == 0)
+ SOCK_LOCK(so);
+ if ((so->so_state & SS_ISCONNECTED) == 0) {
+ SOCK_UNLOCK(so);
return ENOTCONN;
+ }
+ SOCK_UNLOCK(so);
inp->in6p_faddr = in6addr_any;
return rip6_abort(so);
}
@@ -669,7 +695,9 @@ rip6_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
return (error ? error : EADDRNOTAVAIL);
inp->in6p_laddr = *in6a;
inp->in6p_faddr = addr->sin6_addr;
+ SOCK_LOCK(so);
soisconnected(so);
+ SOCK_UNLOCK(so);
return 0;
}
@@ -689,7 +717,9 @@ rip6_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *nam,
struct sockaddr_in6 *dst;
/* always copy sockaddr to avoid overwrites */
+ SOCK_LOCK(so);
if (so->so_state & SS_ISCONNECTED) {
+ SOCK_UNLOCK(so);
if (nam) {
m_freem(m);
return EISCONN;
@@ -702,6 +732,7 @@ rip6_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *nam,
sizeof(struct in6_addr));
dst = &tmp;
} else {
+ SOCK_UNLOCK(so);
if (nam == NULL) {
m_freem(m);
return ENOTCONN;
OpenPOWER on IntegriCloud