Re: [PATCHv6 1/3] tun: export underlying socket

From: Arnd Bergmann
Date: Tue Nov 03 2009 - 07:42:08 EST

On Tuesday 03 November 2009, Michael S. Tsirkin wrote:
> > What was your reason for changing?
> It turns out socket structure is really bound to specific a file, so we
> can not have 2 files referencing the same socket. Instead, as I say
> above, it's possible to make sendmsg/recvmsg work on tap file directly.

Ah, I see.

> I have implemented this (patch below), but decided to go with the simple
> thing first. Since no userspace-visible changes are involved, let's do
> this by small steps: it will be easier to figure out when vhost
> is upstream.

This may even make it easier for me to do the same with macvtap
if I resume work on that.

> @@ -416,8 +422,8 @@ int sock_map_fd(struct socket *sock, int flags)
> static struct socket *sock_from_file(struct file *file, int *err)
> {
> - if (file->f_op == &socket_file_ops)
> - return file->private_data; /* set in sock_map_fd */
> + if (file->f_op->get_socket)
> + return file->f_op->get_socket(file);
> *err = -ENOTSOCK;

Or maybe do both (socket_file_ops and get_socket), to avoid an indirect
function call.

Arnd <><
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at