netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] add likely/unlikely to pskb_may_pull
@ 2003-07-30 23:18 Stephen Hemminger
  2003-07-30 23:53 ` David S. Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Stephen Hemminger @ 2003-07-30 23:18 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev

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.

diff -Nru a/include/linux/skbuff.h b/include/linux/skbuff.h
--- a/include/linux/skbuff.h	Wed Jul 30 15:50:31 2003
+++ b/include/linux/skbuff.h	Wed Jul 30 15:50:31 2003
@@ -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;
 }

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-07-30 23:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-07-30 23:18 [PATCH] add likely/unlikely to pskb_may_pull Stephen Hemminger
2003-07-30 23:53 ` David S. Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).