mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-23 23:21:46 +00:00
tun: export underlying socket
Tun device looks similar to a packet socket in that both pass complete frames from/to userspace. This patch fills in enough fields in the socket underlying tun driver to support sendmsg/recvmsg operations, and message flags MSG_TRUNC and MSG_DONTWAIT, and exports access to this socket to modules. Regular read/write behaviour is unchanged. This way, code using raw sockets to inject packets into a physical device, can support injecting packets into host network stack almost without modification. First user of this interface will be vhost virtualization accelerator. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Acked-by: Herbert Xu <herbert@gondor.apana.org.au> Acked-by: David S. Miller <davem@davemloft.net> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
ad72c347e5
commit
05c2828c72
2 changed files with 96 additions and 19 deletions
|
@ -86,4 +86,18 @@ struct tun_filter {
|
|||
__u8 addr[0][ETH_ALEN];
|
||||
};
|
||||
|
||||
#ifdef __KERNEL__
|
||||
#if defined(CONFIG_TUN) || defined(CONFIG_TUN_MODULE)
|
||||
struct socket *tun_get_socket(struct file *);
|
||||
#else
|
||||
#include <linux/err.h>
|
||||
#include <linux/errno.h>
|
||||
struct file;
|
||||
struct socket;
|
||||
static inline struct socket *tun_get_socket(struct file *f)
|
||||
{
|
||||
return ERR_PTR(-EINVAL);
|
||||
}
|
||||
#endif /* CONFIG_TUN */
|
||||
#endif /* __KERNEL__ */
|
||||
#endif /* __IF_TUN_H */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue