-/* $OpenBSD: ip_var.h,v 1.104 2022/09/03 22:43:38 mvs Exp $ */
+/* $OpenBSD: ip_var.h,v 1.105 2022/09/13 09:05:02 mvs Exp $ */
/* $NetBSD: ip_var.h,v 1.16 1996/02/13 23:43:20 christos Exp $ */
/*
struct mbuf *);
int rip_attach(struct socket *, int);
int rip_detach(struct socket *);
+void rip_lock(struct socket *);
+void rip_unlock(struct socket *);
int rip_bind(struct socket *so, struct mbuf *, struct proc *);
int rip_connect(struct socket *, struct mbuf *);
int rip_disconnect(struct socket *);
-/* $OpenBSD: raw_ip.c,v 1.147 2022/09/03 22:43:38 mvs Exp $ */
+/* $OpenBSD: raw_ip.c,v 1.148 2022/09/13 09:05:02 mvs Exp $ */
/* $NetBSD: raw_ip.c,v 1.25 1996/02/18 18:58:33 christos Exp $ */
/*
const struct pr_usrreqs rip_usrreqs = {
.pru_attach = rip_attach,
.pru_detach = rip_detach,
+ .pru_lock = rip_lock,
+ .pru_unlock = rip_unlock,
.pru_bind = rip_bind,
.pru_connect = rip_connect,
.pru_disconnect = rip_disconnect,
else
n = m_copym(m, 0, M_COPYALL, M_NOWAIT);
if (n != NULL) {
+ int ret;
+
if (inp->inp_flags & INP_CONTROLOPTS ||
inp->inp_socket->so_options & SO_TIMESTAMP)
ip_savecontrol(inp, &opts, ip, n);
- if (sbappendaddr(inp->inp_socket,
+
+ mtx_enter(&inp->inp_mtx);
+ ret = sbappendaddr(inp->inp_socket,
&inp->inp_socket->so_rcv,
- sintosa(&ripsrc), n, opts) == 0) {
+ sintosa(&ripsrc), n, opts);
+ mtx_leave(&inp->inp_mtx);
+
+ if (ret == 0) {
/* should notify about lost packet */
m_freem(n);
m_freem(opts);
return (0);
}
+void
+rip_lock(struct socket *so)
+{
+ struct inpcb *inp = sotoinpcb(so);
+
+ NET_ASSERT_LOCKED();
+ mtx_enter(&inp->inp_mtx);
+}
+
+void
+rip_unlock(struct socket *so)
+{
+ struct inpcb *inp = sotoinpcb(so);
+
+ NET_ASSERT_LOCKED();
+ mtx_leave(&inp->inp_mtx);
+}
+
int
rip_bind(struct socket *so, struct mbuf *nam, struct proc *p)
{
-/* $OpenBSD: ip6_var.h,v 1.102 2022/09/03 22:43:38 mvs Exp $ */
+/* $OpenBSD: ip6_var.h,v 1.103 2022/09/13 09:05:02 mvs Exp $ */
/* $KAME: ip6_var.h,v 1.33 2000/06/11 14:59:20 jinmei Exp $ */
/*
struct mbuf *);
int rip6_attach(struct socket *, int);
int rip6_detach(struct socket *);
+void rip6_lock(struct socket *);
+void rip6_unlock(struct socket *);
int rip6_bind(struct socket *, struct mbuf *, struct proc *);
int rip6_connect(struct socket *, struct mbuf *);
int rip6_disconnect(struct socket *);
-/* $OpenBSD: raw_ip6.c,v 1.168 2022/09/03 22:43:38 mvs Exp $ */
+/* $OpenBSD: raw_ip6.c,v 1.169 2022/09/13 09:05:02 mvs Exp $ */
/* $KAME: raw_ip6.c,v 1.69 2001/03/04 15:55:44 itojun Exp $ */
/*
const struct pr_usrreqs rip6_usrreqs = {
.pru_attach = rip6_attach,
.pru_detach = rip6_detach,
+ .pru_lock = rip6_lock,
+ .pru_unlock = rip6_unlock,
.pru_bind = rip6_bind,
.pru_connect = rip6_connect,
.pru_disconnect = rip6_disconnect,
else
n = m_copym(m, 0, M_COPYALL, M_NOWAIT);
if (n != NULL) {
+ int ret;
+
if (in6p->inp_flags & IN6P_CONTROLOPTS)
ip6_savecontrol(in6p, n, &opts);
/* strip intermediate headers */
m_adj(n, *offp);
- if (sbappendaddr(in6p->inp_socket,
+
+ mtx_enter(&in6p->inp_mtx);
+ ret = sbappendaddr(in6p->inp_socket,
&in6p->inp_socket->so_rcv,
- sin6tosa(&rip6src), n, opts) == 0) {
+ sin6tosa(&rip6src), n, opts);
+ mtx_leave(&in6p->inp_mtx);
+
+ if (ret == 0) {
/* should notify about lost packet */
m_freem(n);
m_freem(opts);
return (0);
}
+void
+rip6_lock(struct socket *so)
+{
+ struct inpcb *in6p = sotoinpcb(so);
+
+ NET_ASSERT_LOCKED();
+ mtx_enter(&in6p->inp_mtx);
+}
+
+void
+rip6_unlock(struct socket *so)
+{
+ struct inpcb *in6p = sotoinpcb(so);
+
+ NET_ASSERT_LOCKED();
+ mtx_leave(&in6p->inp_mtx);
+}
+
int
rip6_bind(struct socket *so, struct mbuf *nam, struct proc *p)
{