summaryrefslogtreecommitdiff
path: root/sys/netinet6
diff options
context:
space:
mode:
authorAlexander Bluhm <bluhm@cvs.openbsd.org>2023-12-15 00:24:57 +0000
committerAlexander Bluhm <bluhm@cvs.openbsd.org>2023-12-15 00:24:57 +0000
commitbba9ea53078ee65837f73d198100360aca204c76 (patch)
tree4cab7ce33904037cea02ed3ab9b0e6ddf8d5ae81 /sys/netinet6
parent70156a9396485cb1e052359a2c421b7a2d71b260 (diff)
Use inpcb table mutex to set addresses.
Protect all remaining write access to inp_faddr and inp_laddr with inpcb table mutex. Document inpcb locking for foreign and local address and port and routing table id. Reading will be made MP safe by adding per socket rw-locks in a next step. OK sashan@ mvs@
Diffstat (limited to 'sys/netinet6')
-rw-r--r--sys/netinet6/in6_src.c4
-rw-r--r--sys/netinet6/raw_ip6.c13
2 files changed, 13 insertions, 4 deletions
diff --git a/sys/netinet6/in6_src.c b/sys/netinet6/in6_src.c
index 2272c828cb9..88ec081e954 100644
--- a/sys/netinet6/in6_src.c
+++ b/sys/netinet6/in6_src.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: in6_src.c,v 1.89 2023/12/03 20:36:24 bluhm Exp $ */
+/* $OpenBSD: in6_src.c,v 1.90 2023/12/15 00:24:56 bluhm Exp $ */
/* $KAME: in6_src.c,v 1.36 2001/02/06 04:08:17 itojun Exp $ */
/*
@@ -96,7 +96,7 @@ in6_pcbselsrc(const struct in6_addr **in6src, struct sockaddr_in6 *dstsock,
{
struct ip6_moptions *mopts = inp->inp_moptions6;
struct route_in6 *ro = &inp->inp_route6;
- struct in6_addr *laddr = &inp->inp_laddr6;
+ const struct in6_addr *laddr = &inp->inp_laddr6;
u_int rtableid = inp->inp_rtableid;
struct ifnet *ifp = NULL;
struct sockaddr *ip6_source = NULL;
diff --git a/sys/netinet6/raw_ip6.c b/sys/netinet6/raw_ip6.c
index afbb6c737f2..6379e79476e 100644
--- a/sys/netinet6/raw_ip6.c
+++ b/sys/netinet6/raw_ip6.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: raw_ip6.c,v 1.177 2023/12/03 20:36:24 bluhm Exp $ */
+/* $OpenBSD: raw_ip6.c,v 1.178 2023/12/15 00:24:56 bluhm Exp $ */
/* $KAME: raw_ip6.c,v 1.69 2001/03/04 15:55:44 itojun Exp $ */
/*
@@ -674,7 +674,10 @@ rip6_bind(struct socket *so, struct mbuf *nam, struct proc *p)
if ((error = in6_pcbaddrisavail(inp, addr, 0, p)))
return (error);
+ mtx_enter(&rawin6pcbtable.inpt_mtx);
inp->inp_laddr6 = addr->sin6_addr;
+ mtx_leave(&rawin6pcbtable.inpt_mtx);
+
return (0);
}
@@ -696,9 +699,12 @@ rip6_connect(struct socket *so, struct mbuf *nam)
if (error)
return (error);
+ mtx_enter(&rawin6pcbtable.inpt_mtx);
inp->inp_laddr6 = *in6a;
inp->inp_faddr6 = addr->sin6_addr;
+ mtx_leave(&rawin6pcbtable.inpt_mtx);
soisconnected(so);
+
return (0);
}
@@ -712,8 +718,11 @@ rip6_disconnect(struct socket *so)
if ((so->so_state & SS_ISCONNECTED) == 0)
return (ENOTCONN);
- inp->inp_faddr6 = in6addr_any;
so->so_state &= ~SS_ISCONNECTED; /* XXX */
+ mtx_enter(&rawin6pcbtable.inpt_mtx);
+ inp->inp_faddr6 = in6addr_any;
+ mtx_leave(&rawin6pcbtable.inpt_mtx);
+
return (0);
}