Commit bec3cfdc authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

net: skb_segment() provides list head and tail

Its unfortunate we have to walk again skb list to find the tail
after segmentation, even if data is probably hot in cpu caches.

skb_segment() can store the tail of the list into segs->prev,
and validate_xmit_skb_list() can immediately get the tail.
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 45d9cc7c
...@@ -2724,22 +2724,25 @@ struct sk_buff *validate_xmit_skb_list(struct sk_buff *skb, struct net_device *d ...@@ -2724,22 +2724,25 @@ struct sk_buff *validate_xmit_skb_list(struct sk_buff *skb, struct net_device *d
{ {
struct sk_buff *next, *head = NULL, *tail; struct sk_buff *next, *head = NULL, *tail;
while (skb) { for (; skb != NULL; skb = next) {
next = skb->next; next = skb->next;
skb->next = NULL; skb->next = NULL;
/* in case skb wont be segmented, point to itself */
skb->prev = skb;
skb = validate_xmit_skb(skb, dev); skb = validate_xmit_skb(skb, dev);
if (skb) { if (!skb)
struct sk_buff *end = skb; continue;
while (end->next) if (!head)
end = end->next; head = skb;
if (!head) else
head = skb; tail->next = skb;
else /* If skb was segmented, skb->prev points to
tail->next = skb; * the last segment. If not, it still contains skb.
tail = end; */
} tail = skb->prev;
skb = next;
} }
return head; return head;
} }
......
...@@ -3083,6 +3083,11 @@ struct sk_buff *skb_segment(struct sk_buff *head_skb, ...@@ -3083,6 +3083,11 @@ struct sk_buff *skb_segment(struct sk_buff *head_skb,
} }
} while ((offset += len) < head_skb->len); } while ((offset += len) < head_skb->len);
/* Some callers want to get the end of the list.
* Put it in segs->prev to avoid walking the list.
* (see validate_xmit_skb_list() for example)
*/
segs->prev = tail;
return segs; return segs;
err: err:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment