skbuff: clear tx zero-copy flag
Subsystems (3)
PATCH 1/1 skbuff: clear tx zero-copy flag
Hello Dave,
This patch clears tx zero-copy flag as needed.
---
net/core/skbuff.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
net/core/skbuff.c +3 -0
@@ -677,6 +677,7 @@ struct sk_buff *skb_clone(struct sk_buff *skb, gfp_t gfp_mask)if (skb_shinfo (skb)->tx_flags &SKBTX_DEV_ZEROCOPY ) {if (skb_copy_ubufs (skb, gfp_mask))return NULL ; +skb_shinfo (skb)->tx_flags &= ~SKBTX_DEV_ZEROCOPY ; } n = skb +1 ;
@@ -801,6 +802,7 @@ struct sk_buff *pskb_copy(struct sk_buff *skb, gfp_t gfp_mask)kfree (n); goto out; } +skb_shinfo (skb)->tx_flags &= ~SKBTX_DEV_ZEROCOPY ; }for (i =0 ; i <skb_shinfo (skb)->nr_frags; i++) {skb_shinfo (n)->frags[i] =skb_shinfo (skb)->frags[i];
@@ -893,6 +895,7 @@ int pskb_expand_head(struct sk_buff *skb, int nhead, int ntail,if (skb_shinfo (skb)->tx_flags &SKBTX_DEV_ZEROCOPY ) {if (skb_copy_ubufs (skb, gfp_mask)) goto nofrags; +skb_shinfo (skb)->tx_flags &= ~SKBTX_DEV_ZEROCOPY ; }for (i =0 ; i <skb_shinfo (skb)->nr_frags; i++)get_page (skb_shinfo (skb)->frags[i].page);
From: Shirley Ma <[email protected]>
Date: Sat, 09 Jul 2011 00:12:46 -0700
Quoted 3 lines
This patch clears tx zero-copy flag as needed.
Signed-off-by Shirley Ma <[email protected]>
Applied, thanks.
Quoted 4 lines · Shirley Ma
This patch clears tx zero-copy flag as needed.
Sign-off-by Shirley Ma <[email protected]>
I think we also need to copy and clear this flag on the splice read path as that takes a direct page reference.
I hope there isn't any other path that does this.
Cheers,
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Quoted 4 lines · Herbert Xu
Quoted 3 lines · Shirley Ma
This patch clears tx zero-copy flag as needed.
Quoted 8 lines
Quoted 1 line
Sign-off-by Shirley Ma <[email protected]>I think we also need to copy and clear this flag on the splice read path as that takes a direct page reference.
I hope there isn't any other path that does this.
Cheers,
When there's a way for an skb to get into the host networking stack, (e.g. when tap gains zero copy support) we'll need to handle that.
However macvtap passes an skb directly to the lower device, so as long as macvtap is the only user of that interface, we are fine I think - there's no way for an skb to get from macvtap to splice read path I think.
Right?
Quoted 4 lines
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Quoted 8 lines · Michael S. Tsirkin
However macvtap passes an skb directly to the lower device, so as long as macvtap is the only user of that interface, we are fine I think - there's no way for an skb to get from macvtap to splice read path I think.
Right?
Yes, as long as you can guarantee that the skb never loops back then you should be fine.
However, does macvtap really bypass everything, including the qdisc layer? The qdisc layer is certainly capable of looping the skb back with the redirect action.
Cheers,
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Quoted 10 lines · Herbert Xu
Quoted 8 lines · Michael S. Tsirkin
However macvtap passes an skb directly to the lower device, so as long as macvtap is the only user of that interface, we are fine I think - there's no way for an skb to get from macvtap to splice read path I think.
Right?
Quoted 8 lines
Yes, as long as you can guarantee that the skb never loops back then you should be fine.
However, does macvtap really bypass everything, including the qdisc layer? The qdisc layer is certainly capable of looping the skb back with the redirect action.
Cheers,
No, I don't think macvtap bypasses the qdisc. Is the action in question here?
static int tcf_mirred(struct sk_buff *skb,
const struct tc_action *a,
struct tcf_result *res)
if yes that seems to always clone an skb, which in turn does the copy so we are fine?
Quoted 4 lines
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Quoted 3 lines · Michael S. Tsirkin
if yes that seems to always clone an skb, which in turn does the copy so we are fine?
Yes you're right, it should be safe.
However, I think we should add a WARN_ON to the splice skb path so that should a packet find its way through a path that we haven't thought of then at least we'll know about it.
Thanks,
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
David Miller
maintainerFrom: Herbert Xu <[email protected]>
Date: Mon, 25 Jul 2011 17:57:11 +0800
Quoted 3 lines
However, I think we should add a
WARN_ONto the splice skb path so that should a packet find its way through a path that we haven't thought of then at least we'll know about it.
Good idea.
Quoted 8 lines · David Miller
From: Herbert Xu <[email protected]>
Date: Mon, 25 Jul 2011 17:57:11 +0800Quoted 3 lines
However, I think we should add a
WARN_ONto the splice skb path so that should a packet find its way through a path that we haven't thought of then at least we'll know about it.Good idea.
Another place like this is skb_split, I think.
Signature · 1 line
MST