Skip to contentSkip to conversation

net: exit immediately when off = 0 in skb_headers_offset_update()

PATCH In review Miaohe Lin 2 participants 2 messages Aug 27, 2020

Subsystems (2)
lore
Share & tools
lore

Miaohe Lin

author
#0 lore raw

PATCH 1/1 net: exit immediately when off = 0 in skb_headers_offset_update()

In the case of off = 0, skb_headers_offset_update() do nothing indeed.

---
 net/core/skbuff.c | 2 ++
 1 file changed, 2 insertions(+)
net/core/skbuff.c +2 -0
index 18ed56316e56..f67f0da20a5b 100644
@@ -1459,6 +1459,8 @@ EXPORT_SYMBOL(skb_clone);
 
 void skb_headers_offset_update(struct sk_buff *skb, int off)
 {
+	if (unlikely(off == 0))
+		return;
 	/* Only adjust this if it actually is csum_start rather than csum */
 	if (skb->ip_summed == CHECKSUM_PARTIAL)
 		skb->csum_start += off;
Signature · 1 line
2.19.1
#1 lore raw
Quoted 13 lines · Miaohe Lin

In the case of off = 0, skb_headers_offset_update() do nothing indeed.

---
 net/core/skbuff.c | 2 ++
 1 file changed, 2 insertions(+)
net/core/skbuff.c +0 -0
index 18ed56316e56..f67f0da20a5b 100644

net/core/skbuff.c EXPORT_SYMBOL(skb_clone); · line 1463

Quoted 5 lines
net/core/skbuff.c +2 -0
@@ -1459,6 +1459,8 @@ EXPORT_SYMBOL(skb_clone);
 
 void skb_headers_offset_update(struct sk_buff *skb, int off)
 {
+       if (unlikely(off == 0))
+               return;

If this is unlikely, I doubt adding a test is going to save anything.

This will instead add a conditional test for the 'likely' cases.