* skb_cow() vs skb_cow_head() - what exactly is "header"?
@ 2018-12-29 18:26 Radu Rendec
2019-01-01 17:53 ` David Miller
0 siblings, 1 reply; 3+ messages in thread
From: Radu Rendec @ 2018-12-29 18:26 UTC (permalink / raw)
To: netdev
Hello,
I'm working on some application-specific NIC driver. On the TX path, it
must remove a custom tag that sits between the Ethernet type field and
the actual Ethernet payload; then it must add a different tag in front
of the Ethernet header (the MAC DA field) before it hands over the frame
to the hardware for delivery.
I'm wondering if skb_cow_head() is enough to safely modify the skb as
described above, or I should use skb_cow() instead. I've been going
through the skbuff code and I still can't figure out the difference.
Comment blocks around the definitions of skb_cow(), skb_cow_head() and
SKB_DATAREF_SHIFT mention a "header" part and a "payload" part of the
skb, but it's still unclear to me which is what. As far as I understand,
there is only "data" and it sits between the headroom and tailroom. If
the skb is fragmented, additional data is stored in separate pages (in
frags[]) or skbs (in frag_list).
Last but not least, is there any *recent* documentation that explains
the subtleties of skbs? Most of the documentation I could find is very
old and/or covers only the basic concepts, such as head/data/tail/end.
Thank you in advance,
Radu Rendec
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: skb_cow() vs skb_cow_head() - what exactly is "header"?
2018-12-29 18:26 skb_cow() vs skb_cow_head() - what exactly is "header"? Radu Rendec
@ 2019-01-01 17:53 ` David Miller
2019-01-06 14:22 ` Radu Rendec
0 siblings, 1 reply; 3+ messages in thread
From: David Miller @ 2019-01-01 17:53 UTC (permalink / raw)
To: radu.rendec; +Cc: netdev
From: Radu Rendec <radu.rendec@gmail.com>
Date: Sat, 29 Dec 2018 13:26:34 -0500
> I'm working on some application-specific NIC driver. On the TX path, it
> must remove a custom tag that sits between the Ethernet type field and
> the actual Ethernet payload; then it must add a different tag in front
> of the Ethernet header (the MAC DA field) before it hands over the frame
> to the hardware for delivery.
>
> I'm wondering if skb_cow_head() is enough to safely modify the skb as
> described above, or I should use skb_cow() instead.
skb_cow_head() should be sufficient. This is what the DSA layer tagging
code uses, and it is doing something similar if not exactly like what you
are doing.
See net/dsa/tag_dsa.c:dsa_xmit().
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: skb_cow() vs skb_cow_head() - what exactly is "header"?
2019-01-01 17:53 ` David Miller
@ 2019-01-06 14:22 ` Radu Rendec
0 siblings, 0 replies; 3+ messages in thread
From: Radu Rendec @ 2019-01-06 14:22 UTC (permalink / raw)
To: David Miller; +Cc: netdev
On Tue, 2019-01-01 at 09:53 -0800, David Miller wrote:
> From: Radu Rendec <radu.rendec@gmail.com
> Date: Sat, 29 Dec 2018 13:26:34 -0500
>
> > I'm working on some application-specific NIC driver. On the TX path, it
> > must remove a custom tag that sits between the Ethernet type field and
> > the actual Ethernet payload; then it must add a different tag in front
> > of the Ethernet header (the MAC DA field) before it hands over the frame
> > to the hardware for delivery.
>
> > I'm wondering if skb_cow_head() is enough to safely modify the skb as
> > described above, or I should use skb_cow() instead.
>
> skb_cow_head() should be sufficient. This is what the DSA layer tagging
> code uses, and it is doing something similar if not exactly like what you
> are doing.
>
> See net/dsa/tag_dsa.c:dsa_xmit().
David, thank you - this is very helpful! Indeed, my use case is very
similar to DSA, but not identical, so unfortunately I can't use DSA.
However, my other question is still unanswered: what exactly is the
"header"? In the case of a fragmented skb, is it the entire "main" skb
(i.e. skb->data, without the fragments) or just a portion of it? Does
the "header" concept still apply to linear skb's?
Thanks,
Radu Rendec
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-01-06 14:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-12-29 18:26 skb_cow() vs skb_cow_head() - what exactly is "header"? Radu Rendec
2019-01-01 17:53 ` David Miller
2019-01-06 14:22 ` Radu Rendec
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).