Re: setsockopt() in kernel

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

 



>can you post the URL to the sourcecode of this animal?

I'm afraid all I can do is cut n'paste the relevant sections below.

oh well; I'll assume that you're a good boy and whatever you're doing is
GPL licensed anyway (as the kernel license requires). If not you need
really good/expensive laywers ;)

LOL! Denny Crane! Sorry if this reference makes no sense. I just don't have a web server where to host this stuff. Plus, I'm a little shy posting my half baked attempts. It's bad enough to admit I need help on this mailing list.



>to be honest I wonder why they sort of seem to duplicate firewall rules,
>and aren't using the firewall engine which provides hooks in all the
>right places...

That's a very good question. I'll try to an answer on that.

...

I was told the module is built this way so that it can work even if netfilter support has been removed from the kernel. I don't know whether it's a valid concern or not.


>also you really shouldn't call setsockopt() in the kernel, it highly
>depends on the arguments being in userspace....

Right, I figured that much. So how can I do the equivalent in kernel space?

it really depends on what you do

Let me verify some of my assumptions with you if you have time:

1- After this line of code:
bytes = (*orig_ops.tdi_tcp_ops.recvmsg)(sock, msg, size, flags, scm);
'msg' will contain the incoming data as received from the socket

2- According to 'man recvmsg', the msghdr struct may contain some ancillary data in *msg_control.

3- As per 'man 7 ip', some of that ancillary data may be of type pktinfo, which would contain the 'ipi_spec_dst' local address I'm looking for.

4- I have to request the ancillary data to be there, because in the default behavior, it does not show up. I'm getting this from 'man setsockopt'. I'm not sure of the format of the 'optval' param. The IP manpage says: "The argument is a flag that tells the socket whether the IP_PKTINFO message should be passed or not." Do they mean a zero or non-zero int? And clearly I should 'setsockopt' (or its kernel equivalent) before the call to recvmsg().



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