core: adjust checks for calling skb_copy_bits in skb_try_coalesce
Subsystems (2)
PATCH 1/1 core: adjust checks for calling skb_copy_bits in skb_try_coalesce
From: Li RongQing <[email protected]>
Ensure that frags and frags_list of dst skb are empty if need to call skb_copy_bits, or else it will break the data sequence.
--- net/core/skbuff.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
net/core/skbuff.c +4 -4
@@ -3455,15 +3455,15 @@ bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,if (skb_cloned (to))return false; -if (len <=skb_tailroom (to)) { +if (skb_has_frag_list (to) ||skb_has_frag_list (from)) +return false; + +if (len <=skb_tailroom (to) && !skb_shinfo (to)->nr_frags) {BUG_ON (skb_copy_bits (from,0 ,skb_put (to, len), len)); *delta_truesize =0 ;return true; } -if (skb_has_frag_list (to) ||skb_has_frag_list (from)) -return false; -if (skb_headlen (from) !=0 ) {struct page *page;unsigned int offset;
Signature · 1 line
1.7.4.1
Quoted 25 lines · On Thu, 2012-09-20 at 11:19 +0800, [email protected] wrote:
From: Li RongQing <[email protected]>
Ensure that frags and
frags_listof dst skb are empty if need to callskb_copy_bits, or else it will break the data sequence.Cc Eric Dumazet <[email protected]>Signed-off-by Li RongQing <[email protected]>--- net/core/skbuff.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)net/core/skbuff.c +4
-1@@ -3455,15 +3455,15 @@ bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,if (skb_cloned (to))return false; -if (len <=skb_tailroom (to)) { +if (skb_has_frag_list (to) ||skb_has_frag_list (from)) +return false; + +if (len <=skb_tailroom (to) && !skb_shinfo (to)->nr_frags) {BUG_ON (skb_copy_bits (from,0 ,skb_put (to, len), len));
net/core/skbuff.c bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from, · line 3469
Quoted 10 lines
net/core/skbuff.c +0
-3*delta_truesize =0 ;return true; } -if (skb_has_frag_list (to) ||skb_has_frag_list (from)) -return false; -if (skb_headlen (from) !=0 ) {struct page *page;unsigned int offset;
This is not needed at all.
Quoted 5 lines
Quoted 1 line
unsigned int offset;This is not needed at all.
I think the below modification maybe needed,
if (len <= skb_tailroom(to) && !skb_shinfo(to)->nr_frags) { ..
}
First skb A is added to skb TO frags, since the len is larger than skb_tailroot(TO), but second len of skb B is less than skb_tailroot(To) which will call skb_copy_bits.
Of cause, this kinds of cases maybe only exist on my mind.
-Roy
Quoted 11 lines · RongQing Li
Quoted 5 lines
Quoted 1 line
unsigned int offset;This is not needed at all.
I think the below modification maybe needed,
if (len <=skb_tailroom(to)&& !skb_shinfo(to)->nr_frags) { ..
}
Quoted 6 lines
First skb A is added to skb TO frags, since the len is larger than
skb_tailroot(TO), but second len of skb B is less thanskb_tailroot(To)which will callskb_copy_bits.Of cause, this kinds of cases maybe only exist on my mind.
Did you read skb_tailroom(to) definition by any chance ?
static inline int skb_tailroom(const struct sk_buff *skb)
{
return skb_is_nonlinear(skb) ? 0 : skb->end - skb->tail;
}Current code is fine, because if @to is linear, its ... linear.
Quoted 11 lines
Did you read
skb_tailroom(to)definition by any chance ?static inline int
skb_tailroom(const struct sk_buff *skb){ return skb_is_nonlinear(skb) ? 0 : skb->end - skb->tail; }Current code is fine, because if @to is linear, its ... linear.
I am wrong, thanks.
Quoted 2 lines · RongQing Li
I am wrong, thanks.
Thanks for taking a look at this stuff ;)