aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2016-07-01 04:01:40 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2016-07-01 04:01:40 +0200
commit63bc97de5f163e313034fa62cb7ffcf7e9c9daad (patch)
tree61bc39daa13bb3aab13efe2580939a5338133b01 /src
parentReadme: the documentation moved to .io (diff)
downloadwireguard-monolithic-historical-63bc97de5f163e313034fa62cb7ffcf7e9c9daad.tar.xz
wireguard-monolithic-historical-63bc97de5f163e313034fa62cb7ffcf7e9c9daad.zip
receive: error conditions are unlikely
Diffstat (limited to 'src')
-rw-r--r--src/receive.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/receive.c b/src/receive.c
index 293b764..227b276 100644
--- a/src/receive.c
+++ b/src/receive.c
@@ -47,16 +47,16 @@ static inline int skb_data_offset(struct sk_buff *skb, size_t *data_offset, size
udp = udp_hdr(skb);
*data_offset = (u8 *)udp - skb->data;
- if (*data_offset + sizeof(struct udphdr) > skb->len) {
+ if (unlikely(*data_offset + sizeof(struct udphdr) > skb->len)) {
net_dbg_ratelimited("Packet isn't big enough to have UDP fields from %pISpfsc\n", &addr);
return -EINVAL;
}
*data_len = ntohs(udp->len);
- if (*data_len < sizeof(struct udphdr)) {
+ if (unlikely(*data_len < sizeof(struct udphdr))) {
net_dbg_ratelimited("UDP packet is reporting too small of a size from %pISpfsc\n", &addr);
return -EINVAL;
}
- if (*data_len > skb->len - *data_offset) {
+ if (unlikely(*data_len > skb->len - *data_offset)) {
net_dbg_ratelimited("UDP packet is lying about its size from %pISpfsc\n", &addr);
return -EINVAL;
}