Adding a new network protocol layer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hey,

I would like to add a 4 bytes before IP header to every outgoing packet. So far I've found that it can be done from module, by dev_add_pack() with type set to ETH_P_ALL. I have than callback called when packet is received or has to be send and I can add required 4 bytes for outgoing packets. I'm doing it with:

# 14 is length of MAC header

skb_put(skb, 4);
memmove(skb->data+4+14, skb->data+14, skb->len-4-14);

... after this struct sk_buff looks correct (all pointers and len field), but what is being sent in the network is that packet without last 4 bytes. If I put in the end of callback additional line:

dev_queue_xmit(skb_clone(skb, GFP_ATOMIC));

than there are two packets sent, one shorter by 4 bytes and one correct. So I assume that sk_buff struct is filled correct. I was trying to clone skb, but it didn't help either. 

What to do to have whole packet being send? Or maybe such thing (adding bytes to packet) should be done in some other way like writing own device driver?

Tomasz Dalecki

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux