aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Dunwoodie <ncon@mail.noconroy.net>2019-09-22 18:30:29 +0200
committerMatt Dunwoodie <ncon@mail.noconroy.net>2019-09-22 21:03:53 +0200
commit6dba30770c1daa0edfe71445f515d9c06d0e2bd3 (patch)
tree1ac2e19b83154949c4374e775b91108e2283b66c
parentFix cookie send now we don't have wg_output_deliver_mbuf (diff)
downloadwireguard-openbsd-6dba30770c1daa0edfe71445f515d9c06d0e2bd3.tar.xz
wireguard-openbsd-6dba30770c1daa0edfe71445f515d9c06d0e2bd3.zip
Use solock rather than NET_LOCK
-rw-r--r--src/if_wg.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/if_wg.c b/src/if_wg.c
index 0c7f74b..992cc9f 100644
--- a/src/if_wg.c
+++ b/src/if_wg.c
@@ -427,9 +427,7 @@ wg_mbuf_ratelimit(struct wg_softc *sc, struct mbuf *m)
peernam.m_len = ip->sa.sa_len;
so = AF_VAL(ip->sa.sa_family, sc->sc_so4, sc->sc_so6);
- /* TODO solock */
- NET_RLOCK();
- so = AF_VAL(p->p_ip.sa.sa_family, sc->sc_so4, sc->sc_so6);
+ int s = solock(so);
if (so) {
if ((error = so->so_proto->pr_usrreq(so, PRU_SEND, m,
&peernam, NULL, NULL)) != 0)
@@ -437,7 +435,7 @@ wg_mbuf_ratelimit(struct wg_softc *sc, struct mbuf *m)
} else {
m_freem(m);
}
- NET_RUNLOCK();
+ sounlock(so, s);
}
/* If we get to here, we either have a valid packet, or we are under
@@ -1031,9 +1029,8 @@ wg_output_deliver(struct mbuf *m)
peernam.m_data = (caddr_t) &p->p_ip;
peernam.m_len = p->p_ip.sa.sa_len;
- /* TODO solock */
- NET_RLOCK();
so = AF_VAL(p->p_ip.sa.sa_family, sc->sc_so4, sc->sc_so6);
+ int s = solock(so);
if (so) {
if ((error = so->so_proto->pr_usrreq(so, PRU_SEND, m,
&peernam, NULL, NULL)) != 0)
@@ -1041,7 +1038,7 @@ wg_output_deliver(struct mbuf *m)
} else {
m_freem(m);
}
- NET_RUNLOCK();
+ sounlock(so, s);
} else {
DPRINTF(sc, "did not output packet\n");
}
@@ -1183,6 +1180,7 @@ wg_bind_port(struct wg_softc *sc)
sin = mtod(&hostnam, struct sockaddr_in *);
/* This just seems dirty */
+ soassertlocked(sc->sc_so4);
inp = sotoinpcb(sc->sc_so4);
inp->inp_lport = 0;
inp->inp_laddr = (struct in_addr) { 0 };
@@ -1200,6 +1198,7 @@ wg_bind_port(struct wg_softc *sc)
#ifdef INET6
sin6 = mtod(&hostnam, struct sockaddr_in6 *);
+ soassertlocked(sc->sc_so6);
inp = sotoinpcb(sc->sc_so6);
inp->inp_lport = 0;
inp->inp_laddr6 = (struct in6_addr) { .s6_addr = { 0 } };