Commit 2259fef0 authored by Eric W. Biederman's avatar Eric W. Biederman Committed by David S. Miller

macvtap: Don't leak unreceived packets when we delete a macvtap device.

To avoid leaking packets in the receive queue.  Add a socket destructor
that will run whenever destroy a macvtap socket.
Signed-off-by: default avatarEric W. Biederman <ebiederm@xmission.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 047af9cf
...@@ -339,6 +339,11 @@ static void macvtap_sock_write_space(struct sock *sk) ...@@ -339,6 +339,11 @@ static void macvtap_sock_write_space(struct sock *sk)
wake_up_interruptible_poll(wqueue, POLLOUT | POLLWRNORM | POLLWRBAND); wake_up_interruptible_poll(wqueue, POLLOUT | POLLWRNORM | POLLWRBAND);
} }
static void macvtap_sock_destruct(struct sock *sk)
{
skb_queue_purge(&sk->sk_receive_queue);
}
static int macvtap_open(struct inode *inode, struct file *file) static int macvtap_open(struct inode *inode, struct file *file)
{ {
struct net *net = current->nsproxy->net_ns; struct net *net = current->nsproxy->net_ns;
...@@ -369,6 +374,7 @@ static int macvtap_open(struct inode *inode, struct file *file) ...@@ -369,6 +374,7 @@ static int macvtap_open(struct inode *inode, struct file *file)
q->sock.ops = &macvtap_socket_ops; q->sock.ops = &macvtap_socket_ops;
sock_init_data(&q->sock, &q->sk); sock_init_data(&q->sock, &q->sk);
q->sk.sk_write_space = macvtap_sock_write_space; q->sk.sk_write_space = macvtap_sock_write_space;
q->sk.sk_destruct = macvtap_sock_destruct;
q->flags = IFF_VNET_HDR | IFF_NO_PI | IFF_TAP; q->flags = IFF_VNET_HDR | IFF_NO_PI | IFF_TAP;
q->vnet_hdr_sz = sizeof(struct virtio_net_hdr); q->vnet_hdr_sz = sizeof(struct virtio_net_hdr);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment