diff options
author | Peter Hessler <phessler@cvs.openbsd.org> | 2018-04-28 07:44:45 +0000 |
---|---|---|
committer | Peter Hessler <phessler@cvs.openbsd.org> | 2018-04-28 07:44:45 +0000 |
commit | 2d0986da26aeb1388449be262d02449fa58adf3e (patch) | |
tree | 6434e5c8e61f356c81859a8eb0dfef528e230397 /sys/net | |
parent | 356327a519a213c5d0b435c6d4488b3c5f0b3efc (diff) |
add the socket lock around our use of sockets
Diffstat (limited to 'sys/net')
-rw-r--r-- | sys/net/bfd.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/sys/net/bfd.c b/sys/net/bfd.c index 9a7771a93d0..52bd4388826 100644 --- a/sys/net/bfd.c +++ b/sys/net/bfd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bfd.c,v 1.65 2017/09/08 05:36:53 deraadt Exp $ */ +/* $OpenBSD: bfd.c,v 1.66 2018/04/28 07:44:44 phessler Exp $ */ /* * Copyright (c) 2016 Peter Hessler <phessler@openbsd.org> @@ -436,6 +436,7 @@ bfd_listener(struct bfd_config *bfd, unsigned int port) struct socket *so; struct mbuf *m = NULL, *mopt = NULL; int *ip, error; + int s; /* sa_family and sa_len must be equal */ if (src->sa_family != dst->sa_family || src->sa_len != dst->sa_len) @@ -452,7 +453,9 @@ bfd_listener(struct bfd_config *bfd, unsigned int port) mopt->m_len = sizeof(int); ip = mtod(mopt, int *); *ip = MAXTTL; + s = solock(so); error = sosetopt(so, IPPROTO_IP, IP_MINTTL, mopt); + sounlock(s); m_freem(mopt); if (error) { printf("%s: sosetopt error %d\n", @@ -477,7 +480,9 @@ bfd_listener(struct bfd_config *bfd, unsigned int port) break; } + s = solock(so); error = sobind(so, m, p); + sounlock(s); if (error) { printf("%s: sobind error %d\n", __func__, error); @@ -513,6 +518,7 @@ bfd_sender(struct bfd_config *bfd, unsigned int port) struct sockaddr_in6 *sin6; struct sockaddr_in *sin; int error, *ip; + int s; /* sa_family and sa_len must be equal */ if (src->sa_family != dst->sa_family || src->sa_len != dst->sa_len) @@ -527,7 +533,9 @@ bfd_sender(struct bfd_config *bfd, unsigned int port) mopt->m_len = sizeof(int); ip = mtod(mopt, int *); *ip = IP_PORTRANGE_HIGH; + s = solock(so); error = sosetopt(so, IPPROTO_IP, IP_PORTRANGE, mopt); + sounlock(s); m_freem(mopt); if (error) { printf("%s: sosetopt error %d\n", @@ -539,7 +547,9 @@ bfd_sender(struct bfd_config *bfd, unsigned int port) mopt->m_len = sizeof(int); ip = mtod(mopt, int *); *ip = MAXTTL; + s = solock(so); error = sosetopt(so, IPPROTO_IP, IP_TTL, mopt); + sounlock(s); m_freem(mopt); if (error) { printf("%s: sosetopt error %d\n", @@ -551,7 +561,9 @@ bfd_sender(struct bfd_config *bfd, unsigned int port) mopt->m_len = sizeof(int); ip = mtod(mopt, int *); *ip = IPTOS_PREC_INTERNETCONTROL; + s = solock(so); error = sosetopt(so, IPPROTO_IP, IP_TOS, mopt); + sounlock(s); m_freem(mopt); if (error) { printf("%s: sosetopt error %d\n", @@ -576,7 +588,9 @@ bfd_sender(struct bfd_config *bfd, unsigned int port) break; } + s = solock(so); error = sobind(so, m, p); + sounlock(s); if (error) { printf("%s: sobind error %d\n", __func__, error); @@ -597,7 +611,9 @@ bfd_sender(struct bfd_config *bfd, unsigned int port) break; } + s = solock(so); error = soconnect(so, m); + sounlock(s); if (error && error != ECONNREFUSED) { printf("%s: soconnect error %d\n", __func__, error); |