aboutsummaryrefslogtreecommitdiffstatshomepage
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
commit81f031c868999005b0da3a875f462fda9c7b11ad (patch)
treeeb3bacebcce9dfaf9ec4d2b938c0e4f4165e57db /src/device.c
parentdevice: our use of queues means this check is worthless (diff)
downloadwireguard-monolithic-historical-81f031c868999005b0da3a875f462fda9c7b11ad.tar.xz
wireguard-monolithic-historical-81f031c868999005b0da3a875f462fda9c7b11ad.zip
device: no need to take lock for integer comparison
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;