Is it the right way of operating on skb->data

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

 



Hello there,

I am writing a new transport protocol in 2.4.17 basing on UDP
implementation. The protocol has options right after the 'main'
header just like the TCP has.

My question: is it apropriate and safe to deal with those options
the way I do:

1. Sending:
modified net/ipv4/udp.c : udp_getfrag_nosum(const void *p, char * to,
unsigned int offset, unsigned int fraglen) /I'll do checksum later on/

(called by IP module) to not only copy to the destination pointer 'to' the
main header and iovec (using copy_from_user), but also my options in
between.
My concern here is I am not really sure how much memory IP allocated for
this packet (for 'to'), so how much of options can I add. I am not
supposed to touch IP...


2. Receiving: modified net/ipv4/udp.c : udp_rcv(struct sk_buff *skb)
After parsing skb->data to get my options, I just move the payload in the
memory and decrease skb->len:

memmove(skb->data + sizeof(struct udpphdr),
        skb->data + sizeof(struct udphdr) + opts_len,
        skb->len - sizeof(struct udphdr) - opts_len);

skb->len -= opts_len;


Everything /seems/ to work fine (a test user application works and there
are no kernel warnings, too). Is it ok, though?
Thanks!

-marek


--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
IRC Channel:   irc.openprojects.net / #kernelnewbies
Web Page:      http://www.kernelnewbies.org/


[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