aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2016-11-15 20:19:20 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2016-11-15 20:19:20 +0100
commit1550e9ba597946c88e3e7e3e8dcf33c13dd76e5b (patch)
treeb21cb0e2fbfeb28f294832e266bdbfa2398b1d7b
parenttests: trim output (diff)
downloadwireguard-monolithic-historical-1550e9ba597946c88e3e7e3e8dcf33c13dd76e5b.tar.xz
wireguard-monolithic-historical-1550e9ba597946c88e3e7e3e8dcf33c13dd76e5b.zip
various: nits from willy
-rw-r--r--src/data.c6
-rw-r--r--src/device.c2
-rw-r--r--src/hashtables.c4
-rw-r--r--src/receive.c2
4 files changed, 6 insertions, 8 deletions
diff --git a/src/data.c b/src/data.c
index b6d20b8..dd7f0cb 100644
--- a/src/data.c
+++ b/src/data.c
@@ -439,11 +439,9 @@ void packet_consume_data(struct sk_buff *skb, size_t offset, struct wireguard_de
ret = -EINVAL;
rcu_read_lock();
keypair = noise_keypair_get((struct noise_keypair *)index_hashtable_lookup(&wg->index_hashtable, INDEX_HASHTABLE_KEYPAIR, idx));
- if (unlikely(!keypair)) {
- rcu_read_unlock();
- goto err;
- }
rcu_read_unlock();
+ if (unlikely(!keypair))
+ goto err;
#ifdef CONFIG_WIREGUARD_PARALLEL
if (cpumask_weight(cpu_online_mask) > 1) {
unsigned int cpu = choose_cpu(idx);
diff --git a/src/device.c b/src/device.c
index 564d09b..5a294ec 100644
--- a/src/device.c
+++ b/src/device.c
@@ -121,8 +121,8 @@ static netdev_tx_t xmit(struct sk_buff *skb, struct net_device *dev)
read_unlock_bh(&peer->endpoint_lock);
if (unlikely(ret)) {
net_dbg_ratelimited("No valid endpoint has been configured or discovered for device\n");
- peer_put(peer);
skb_unsendable(skb, dev);
+ peer_put(peer);
return -EHOSTUNREACH;
}
diff --git a/src/hashtables.c b/src/hashtables.c
index 8616015..d2a9cf9 100644
--- a/src/hashtables.c
+++ b/src/hashtables.c
@@ -68,7 +68,7 @@ void index_hashtable_init(struct index_hashtable *table)
__le32 index_hashtable_insert(struct index_hashtable *table, struct index_hashtable_entry *entry)
{
struct index_hashtable_entry *existing_entry;
- uint64_t rand;
+ unsigned long rand = get_random_long();
spin_lock(&table->lock);
hlist_del_init_rcu(&entry->index_hash);
@@ -78,7 +78,7 @@ __le32 index_hashtable_insert(struct index_hashtable *table, struct index_hashta
search_unused_slot:
/* First we try to find an unused slot, randomly, while unlocked. */
- rand = get_random_long();
+ ++rand;
entry->index = (__force __le32)siphash24((uint8_t *)&rand, sizeof(rand), table->key);
hlist_for_each_entry_rcu(existing_entry, index_bucket(table, entry->index), index_hash) {
if (existing_entry->index == entry->index)
diff --git a/src/receive.c b/src/receive.c
index 76a1960..0878872 100644
--- a/src/receive.c
+++ b/src/receive.c
@@ -265,9 +265,9 @@ static void receive_data_packet(struct sk_buff *skb, struct wireguard_peer *peer
peer_put(routed_peer); /* We don't need the extra reference. */
if (unlikely(routed_peer != peer)) {
- net_dbg_skb_ratelimited("Packet has unallowed src IP (%pISc) from peer %Lu (%pISpfsc)\n", skb, peer->internal_id, &peer->endpoint.addr_storage);
++dev->stats.rx_errors;
++dev->stats.rx_frame_errors;
+ net_dbg_skb_ratelimited("Packet has unallowed src IP (%pISc) from peer %Lu (%pISpfsc)\n", skb, peer->internal_id, &peer->endpoint.addr_storage);
goto packet_processed;
}