提交 dbd50f23 编写于 作者: X Xin Long 提交者: Jakub Kicinski

net: move the hsize check to the else block in skb_segment

After commit 89319d38 ("net: Add frag_list support to skb_segment"),
it goes to process frag_list when !hsize in skb_segment(). However, when
using skb frag_list, sg normally should not be set. In this case, hsize
will be set with len right before !hsize check, then it won't go to
frag_list processing code.

So the right thing to do is move the hsize check to the else block, so
that it won't affect the !hsize check for frag_list processing.

v1->v2:
  - change to do "hsize <= 0" check instead of "!hsize", and also move
    "hsize < 0" into else block, to save some cycles, as Alex suggested.
Signed-off-by: NXin Long <lucien.xin@gmail.com>
Reviewed-by: NAlexander Duyck <alexanderduyck@fb.com>
Signed-off-by: NJakub Kicinski <kuba@kernel.org>
上级 20efd2c7
...@@ -3894,12 +3894,8 @@ struct sk_buff *skb_segment(struct sk_buff *head_skb, ...@@ -3894,12 +3894,8 @@ struct sk_buff *skb_segment(struct sk_buff *head_skb,
} }
hsize = skb_headlen(head_skb) - offset; hsize = skb_headlen(head_skb) - offset;
if (hsize < 0)
hsize = 0;
if (hsize > len || !sg)
hsize = len;
if (!hsize && i >= nfrags && skb_headlen(list_skb) && if (hsize <= 0 && i >= nfrags && skb_headlen(list_skb) &&
(skb_headlen(list_skb) == len || sg)) { (skb_headlen(list_skb) == len || sg)) {
BUG_ON(skb_headlen(list_skb) > len); BUG_ON(skb_headlen(list_skb) > len);
...@@ -3942,6 +3938,11 @@ struct sk_buff *skb_segment(struct sk_buff *head_skb, ...@@ -3942,6 +3938,11 @@ struct sk_buff *skb_segment(struct sk_buff *head_skb,
skb_release_head_state(nskb); skb_release_head_state(nskb);
__skb_push(nskb, doffset); __skb_push(nskb, doffset);
} else { } else {
if (hsize > len || !sg)
hsize = len;
else if (hsize < 0)
hsize = 0;
nskb = __alloc_skb(hsize + doffset + headroom, nskb = __alloc_skb(hsize + doffset + headroom,
GFP_ATOMIC, skb_alloc_rx_flag(head_skb), GFP_ATOMIC, skb_alloc_rx_flag(head_skb),
NUMA_NO_NODE); NUMA_NO_NODE);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册