setsockopt() in kernel

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

 



Hi,

I'm pretty new to kernel development and I'm currently attempting to modify a loadable kernel module. This module intercepts some of the networking calls (connect, accept, sendmsg, recvmsg, etc), presents them to a security engine and either completes or denies the calls based on the engine's decision. This is done on RH3, kernel 2.4.21-4.

My trouble stems from determining the destination IP addr in an incoming UDP packet. I understand the information should be available in the msghdr struct that is returned from the 5 parameter version of sock->ops->recvmsg() function (as used in net/socket.c but defined God knows where).

I further gather that I must provide some space/memory in msghdr when calling recvmsg() to receive the ancillary data (IP_PKTINFO) that will eventually contain the ipi_spec_dst local IP address I'm looking for.

Finally, I think I need to call the equivalent to the userspace setsockopt() to tell the socket I want this ancillary data. But, I don't think I can use that system call in kernel space, right? Is sys_setsockopt() the way to go? Whatever I try, I keep getting error -14 (EFAULT?) which seems to be a show stopper.

Could someone tell me whether I'm in the right direction or how to piece this all together?

Many thanks,
JP



--
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