summaryrefslogtreecommitdiffhomepage
path: root/src/device.c
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2017-10-12 03:56:53 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2017-10-17 19:26:07 +0200
commit9e39e0662985c6f08f2c238d1624fa285e26a0ab (patch)
treeffdb7adcc930725fc2c05f19b24571f8e732ae47 /src/device.c
parent4b5cf429645d06d95774fb3288de74aa1f74fc46 (diff)
device: no need to take lock for integer comparison
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src/device.c')
-rw-r--r--src/device.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/device.c b/src/device.c
index 9abc031..a1c497b 100644
--- a/src/device.c
+++ b/src/device.c
@@ -108,6 +108,7 @@ static netdev_tx_t xmit(struct sk_buff *skb, struct net_device *dev)
struct wireguard_peer *peer;
struct sk_buff *next;
struct sk_buff_head packets;
+ sa_family_t family;
int ret;
if (unlikely(skb_examine_untrusted_ip_hdr(skb) != skb->protocol)) {
@@ -123,10 +124,8 @@ static netdev_tx_t xmit(struct sk_buff *skb, struct net_device *dev)
goto err;
}
- read_lock_bh(&peer->endpoint_lock);
- ret = peer->endpoint.addr.sa_family != AF_INET && peer->endpoint.addr.sa_family != AF_INET6;
- read_unlock_bh(&peer->endpoint_lock);
- if (unlikely(ret)) {
+ family = READ_ONCE(peer->endpoint.addr.sa_family);
+ if (unlikely(family != AF_INET && family != AF_INET6)) {
ret = -EDESTADDRREQ;
net_dbg_ratelimited("%s: No valid endpoint has been configured or discovered for peer %Lu\n", dev->name, peer->internal_id);
goto err_peer;