How the kernel knows how much headroom/tailroom to assign, when it required to create SKB to send through net-device interface?

StackOverflow https://stackoverflow.com/questions/22374860

質問

I have a scenario in which the kernel builds SKB which came to my .do_start_xmit hook, without enough headroom for my extra headers. Actually, it happens when the previous .do_start_xmit hook call, returned with an error (not 0). From that moment, the kernel keep trying to send SKBs (32-words length of data) without enough headroom for my extra headers. Until that error, the kernel made perfect SKBs with enough headroom for everything I needed.

Where is the configuration in which from it the kernel takes the values to set the size of headroom/tailroom of SKB, when sending a ping (for example) from one userspace to another?

役に立ちましたか?

解決

You can set your "net_device" "needed_headroom" / "needed_tailroom" field, at your NIC driver init time, like

dev->needed_headroom += EXTRA_HEADER_LENGTH;

The basic logic is, when networking stack is about to allocate a SKB to transmit via a interface, it take into consideration the value of "needed_headroom" ( in fact, a macro LL_RESERVED_SPACE (dev ) ), and the SKB would have that large headroom reserved. This way, your NIC driver could assume that most packet reach into "do_start_xmit()" should have enough headroom --- most, not all, a headroom check is still needed.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top