aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2011-10-20 00:27:24 -0400
committerDavid S. Miller <davem@davemloft.net>2011-10-21 02:53:07 -0400
commit2259fef0bb80a8fc842b5690b89a640464df2859 (patch)
tree47ea67b829da2e1596a28f32536cf83e9dfbf436 /drivers/net
parent047af9cfedfa357e1497e327eaa893253ca51971 (diff)
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: Eric W. Biederman <ebiederm@xmission.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/macvtap.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
index 1d9c9c209672..515aa873929e 100644
--- a/drivers/net/macvtap.c
+++ b/drivers/net/macvtap.c
@@ -339,6 +339,11 @@ static void macvtap_sock_write_space(struct sock *sk)
339 wake_up_interruptible_poll(wqueue, POLLOUT | POLLWRNORM | POLLWRBAND); 339 wake_up_interruptible_poll(wqueue, POLLOUT | POLLWRNORM | POLLWRBAND);
340} 340}
341 341
342static void macvtap_sock_destruct(struct sock *sk)
343{
344 skb_queue_purge(&sk->sk_receive_queue);
345}
346
342static int macvtap_open(struct inode *inode, struct file *file) 347static int macvtap_open(struct inode *inode, struct file *file)
343{ 348{
344 struct net *net = current->nsproxy->net_ns; 349 struct net *net = current->nsproxy->net_ns;
@@ -369,6 +374,7 @@ static int macvtap_open(struct inode *inode, struct file *file)
369 q->sock.ops = &macvtap_socket_ops; 374 q->sock.ops = &macvtap_socket_ops;
370 sock_init_data(&q->sock, &q->sk); 375 sock_init_data(&q->sock, &q->sk);
371 q->sk.sk_write_space = macvtap_sock_write_space; 376 q->sk.sk_write_space = macvtap_sock_write_space;
377 q->sk.sk_destruct = macvtap_sock_destruct;
372 q->flags = IFF_VNET_HDR | IFF_NO_PI | IFF_TAP; 378 q->flags = IFF_VNET_HDR | IFF_NO_PI | IFF_TAP;
373 q->vnet_hdr_sz = sizeof(struct virtio_net_hdr); 379 q->vnet_hdr_sz = sizeof(struct virtio_net_hdr);
374 380