I'm writing an kernel network module and when I receive an Ethernet DIX frame, which is represented as continuous sequence of bytes, I have to properly put all content of recieved packet into sk_buff. How should I do it?
I tried to build and transfer my frame like this
struct sk_buff* skb = netdev_alloc_skb(dev,len);
skb_reserve(skb,len);
void* temp = skb_push(skb,len);
memcpy(temp,data,len);
netif_rx(skb);
But in wireshark I see that Linux treat it like a Linux cooked capture rather than Ethernet sniffed frame
http://vger.kernel.org/~davem/skb_data.html
One incorrect thing is that you are running skb_reserve for data length. skb_put extends the used data area of the buffer so you are doing it twice. Also try with skb_put. Try code below:
Or you can try this (not tested):
NET_IP_ALIGN -> you can read about it here https://elixir.bootlin.com/linux/v5.4.1/source/include/linux/skbuff.h#L2588
You can also compare the pointer returned from skb_put and skb_push and see the difference between these two.