The struct sk_buff is really HARD to understand (at least for me, when you deal with it at the first time).
Before anyone say I should google the web before asking questions, please understand I DID that, but with no luck. There are some GOOD but OLD AND OBSOLETE documentation and papers out there, and looking the sources at GIT and even browsing the sources http://lxr.free-electrons.com just makes everything more and more confuse.
I'm going to ask more than I need to make any final conclusions in this page more complete so anyone who get's here will (hopefully) have his/her questions answered.
Can you explain me those members of the struct sk_buff?
mac_header, network_header, transport_header
They seem to be offsets. But counting from where? From head?
To tell everyone my struct has no mac_header, for example, what should I do? Because the source of skb_mac_header_was_set() Returns this: skb->mac_header != (typeof(skb->mac_header))~0U
But there is no skb_network_header_was_set() function; and there is one for transport_header... Crazyness!
len
Background:
What I am trying to do is this: i'm editing packets in a netfilter hook, and when I'm done, I'm rebuilding the entire headers (UDP/TCP, IP4/IP6, Ethernet)... As I may have included/removed new option in those headers, their size change, the skb->data moves... and that's why I need to deal with those members.
My module works in every netfilter hook (PREROUTING, POSTROUTING, FORWARD, INPUT)...