Code:
My problem is I don't know how to compare the incoming 'struct socket *sock'
with the struct socket's in my linked list, I don't have a file desriptor to check
that I can tell. The socket ip and port can be the same on multiple sockets. The
only unique thing I know about a socket is the file descriptor, but I can't find a
good way to get access to it so I can match the userspace fd with the socket in my
list.
A simpler way to put it would be ... how do I get the file descriptor that matches a 'struct socket'? File descriptors are unique, so I just need to find a way to get the file descriptor for a particular socket. But file descriptors aren't passed beyond the socket systemcall's in socket.c.
(from socket.c syscall to connect)
err = sock->ops->connect(sock, (struct sockaddr *)&address, addrlen, sock->file->f_flags);
My proto_ops funcs won't receive file descriptor from this sock->ops->connect() call.
I can see that sockfd_lookup_light() (as shown in socket of net/socket.c) will get me a socket from a fd, but I basically want to get a fd from a socket.