diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2016-07-01 04:01:40 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2016-07-01 04:01:40 +0200 |
commit | d172fddcd5da9014ced3b6d73009a5da2d247cc5 (patch) | |
tree | 9467cfb920a58afeca715cfbeed2305593a013d2 /src | |
parent | dcf5fd45130e58ebfc4e727925b5f725a273776f (diff) |
receive: error conditions are unlikely
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/receive.c | 6 |
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; } |