From d172fddcd5da9014ced3b6d73009a5da2d247cc5 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Fri, 1 Jul 2016 04:01:40 +0200 Subject: receive: error conditions are unlikely Signed-off-by: Jason A. Donenfeld --- src/receive.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') 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; } -- cgit v1.2.3