Getting destination socket address

From: Andreas Gaupmann (andreas.gaupmann@private)
Date: Mon Feb 06 2006 - 03:46:30 PST


Hello!

In a kernel module that registers the hook function socket_sendmsg() I am 
trying to filter outbound datagrams over sockets of the family AF_INET and 
AF_INET6. The family of the socket is determined by using the first paramter 
of socket_sendmsg().

In the security.h the description of socket_sendmsg() is as follows:
 * @socket_sendmsg:
 *      Check permission before transmitting a message to another socket.
 *      @sock contains the socket structure.
 *      @msg contains the message to be transmitted.
 *      @size contains the size of message.
 *      Return 0 if permission is granted.

What exactly is "the message to be transmitted"? Sometimes msg->msg_name 
contains a pointer to a valid sockaddr_in or sockaddr_in6 structure but other 
times its NULL. Nevertheless, msg->msg_iov is initialized and contains some 
application layer data.

What is the explanation for msg->msg_name not being initialized all the time? 
Is this field filled after the discussed hook function has already been 
called?
How can the destination socket of the message be determined despite 
msg->msg_name equal to NULL?

Any help and clarification on this is welcome.

Regards
Andreas Gaupmann



This archive was generated by hypermail 2.1.3 : Mon Feb 06 2006 - 03:47:37 PST