* [PATCH net-next] core: adjust checks for calling skb_copy_bits in skb_try_coalesce
@ 2012-09-20 3:19 roy.qing.li
2012-09-20 5:20 ` Eric Dumazet
0 siblings, 1 reply; 6+ messages in thread
From: roy.qing.li @ 2012-09-20 3:19 UTC (permalink / raw)
To: netdev, edumazet
From: Li RongQing <roy.qing.li@gmail.com>
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.
Cc: Eric Dumazet <edumazet@google.com>
Signed-off-by: Li RongQing <roy.qing.li@gmail.com>
---
net/core/skbuff.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index fe00d12..f0b9446 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -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;
--
1.7.4.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH net-next] core: adjust checks for calling skb_copy_bits in skb_try_coalesce
2012-09-20 3:19 [PATCH net-next] core: adjust checks for calling skb_copy_bits in skb_try_coalesce roy.qing.li
@ 2012-09-20 5:20 ` Eric Dumazet
2012-09-20 5:40 ` RongQing Li
0 siblings, 1 reply; 6+ messages in thread
From: Eric Dumazet @ 2012-09-20 5:20 UTC (permalink / raw)
To: roy.qing.li; +Cc: netdev, edumazet
On Thu, 2012-09-20 at 11:19 +0800, roy.qing.li@gmail.com wrote:
> From: Li RongQing <roy.qing.li@gmail.com>
>
> 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.
>
> Cc: Eric Dumazet <edumazet@google.com>
> Signed-off-by: Li RongQing <roy.qing.li@gmail.com>
> ---
> net/core/skbuff.c | 8 ++++----
> 1 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/net/core/skbuff.c b/net/core/skbuff.c
> index fe00d12..f0b9446 100644
> --- a/net/core/skbuff.c
> +++ b/net/core/skbuff.c
> @@ -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;
This is not needed at all.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net-next] core: adjust checks for calling skb_copy_bits in skb_try_coalesce
2012-09-20 5:20 ` Eric Dumazet
@ 2012-09-20 5:40 ` RongQing Li
2012-09-20 5:53 ` Eric Dumazet
0 siblings, 1 reply; 6+ messages in thread
From: RongQing Li @ 2012-09-20 5:40 UTC (permalink / raw)
To: Eric Dumazet; +Cc: netdev, edumazet
>> 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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net-next] core: adjust checks for calling skb_copy_bits in skb_try_coalesce
2012-09-20 5:40 ` RongQing Li
@ 2012-09-20 5:53 ` Eric Dumazet
2012-09-20 5:57 ` RongQing Li
0 siblings, 1 reply; 6+ messages in thread
From: Eric Dumazet @ 2012-09-20 5:53 UTC (permalink / raw)
To: RongQing Li; +Cc: netdev, edumazet
On Thu, 2012-09-20 at 13:40 +0800, RongQing Li wrote:
> >> 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.
>
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.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net-next] core: adjust checks for calling skb_copy_bits in skb_try_coalesce
2012-09-20 5:53 ` Eric Dumazet
@ 2012-09-20 5:57 ` RongQing Li
2012-09-20 7:00 ` Eric Dumazet
0 siblings, 1 reply; 6+ messages in thread
From: RongQing Li @ 2012-09-20 5:57 UTC (permalink / raw)
To: Eric Dumazet; +Cc: netdev, edumazet
> 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.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net-next] core: adjust checks for calling skb_copy_bits in skb_try_coalesce
2012-09-20 5:57 ` RongQing Li
@ 2012-09-20 7:00 ` Eric Dumazet
0 siblings, 0 replies; 6+ messages in thread
From: Eric Dumazet @ 2012-09-20 7:00 UTC (permalink / raw)
To: RongQing Li; +Cc: netdev, edumazet
On Thu, 2012-09-20 at 13:57 +0800, RongQing Li wrote:
>
> I am wrong, thanks.
Thanks for taking a look at this stuff ;)
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2012-09-20 7:00 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-20 3:19 [PATCH net-next] core: adjust checks for calling skb_copy_bits in skb_try_coalesce roy.qing.li
2012-09-20 5:20 ` Eric Dumazet
2012-09-20 5:40 ` RongQing Li
2012-09-20 5:53 ` Eric Dumazet
2012-09-20 5:57 ` RongQing Li
2012-09-20 7:00 ` Eric Dumazet
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox