sk_buff free 2 bytes in headroom

Yurij Goncharuk <[email protected]> Mon, 14 Feb 2022 13:35:55 +0300
Newsgroups gmane.linux.newbie
Message-ID <[email protected]>
Hello!

During NIC driver writing I read and understand about main struct sk_buff fields like headroom, data, tailroom, end, len, data_len. Main sources like: LWN(https://lwn.net/Articles/89597/) and Dave M posts(http://vger.kernel.org/%7Edavem/skb_data.html) told about there is 2 bytes alignment used for IP header performance. This alignment should be used in every RX routine in NIC driver.

In my case when I've received struct sk_buff in start_xmit() I have struct sk_buff with 2 free bytes in headroom(skb_headroom(skb)). This 2 bytes I use for my purposes (skb_push(skb, 2)).

I'm worried of 3 things:

	• I've checked about 2 free bytes in headroom against several distros and find them in. This probably means that struct skb which passes to start_xmit() already aligned during TX. Is it true?
	• If it's true, why NET_IP_ALIGN macro during pr_info in start_xmit() print 0?
	• Can I check for free 2 bytes in headroom without module loading via sysctl, getconf or something else?

/*-----------------------*
Best regards!
Yurij Goncharuk
[email protected]
/*-----------------------*