Question

I'm just wondering if the MAC header is added into the sk_buff struct before the queuing step or after the queuing step? The reason I'm asking is that I'm doing some kernel programming in the htb queuing discipline and I'm trying to see/change the mac header. I'm testing it by putting printk() statements and then pinging another IP. However, I'm getting back the following information:

MAC length: 0 IP header length: 20 macHeaderset: 0 truesize: 768

It seems like that the packet is all going well, but the MAC header has not yet been added. So my question is, when does the MAC header get added, and how does the system know what to put as the MAC address in the mac header when it is added? (previously I thought the MAC header is added during routing via looking at the routing table)

Was it helpful?

Solution

After printing out the entire packet bytes in the queue and going through it, it looks like that the MAC header is indeed added before queueing, but for some reason the MAC header pointer in sk_buff is not updated.

EDIT: upon further review, the MAC header is added into the sk_buff struct before queuing, but the actual destination MAC address is not added until it reaches the outgoing hardware interface.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top