Skip to contentSkip to conversation

add likely/unlikely to pskb_may_pull

PATCH Applied Stephen Hemminger 2 participants 2 messages Jul 30, 2003

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 add likely/unlikely to pskb_may_pull

Code that deals with received headers needs to be robust and use pskb_may_pull in many places, but except in the case of DOS attacks, the packets are always correctly formed so optimize for that case.

include/linux/skbuff.h +2 -2
diff -Nru a/include/linux/skbuff.h b/include/linux/skbuff.h
@@ -904,9 +904,9 @@
 
 static inline int pskb_may_pull(struct sk_buff *skb, unsigned int len)
 {
-	if (len <= skb_headlen(skb))
+	if (likely(len <= skb_headlen(skb)))
 		return 1;
-	if (len > skb->len)
+	if (unlikely(len > skb->len))
 		return 0;
 	return __pskb_pull_tail(skb, len-skb_headlen(skb)) != NULL;
 }
#1 lore raw
Quoted 3 lines · On Wed, 30 Jul 2003 16:18:54 -0700 Stephen Hemminger <[email protected]>…

Code that deals with received headers needs to be robust and use pskb_may_pull in many places, but except in the case of DOS attacks, the packets are always correctly formed so optimize for that case.

Applied, thanks Stephen.