Commit 4bfb0513 authored by Jason Wang's avatar Jason Wang Committed by David S. Miller

tuntap: purge socket error queue on detach

Commit eda29772
(tun: Support software transmit time stamping) will queue skbs into error queue
when tx stamping is enabled. But it forgets to purge the error queue during
detach. This patch fixes this.

Cc: Richard Cochran <richardcochran@gmail.com>
Acked-by: default avatarRichard Cochran <richardcochran@gmail.com>
Signed-off-by: default avatarJason Wang <jasowang@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent df95fc44
...@@ -409,6 +409,12 @@ static struct tun_struct *tun_enable_queue(struct tun_file *tfile) ...@@ -409,6 +409,12 @@ static struct tun_struct *tun_enable_queue(struct tun_file *tfile)
return tun; return tun;
} }
static void tun_queue_purge(struct tun_file *tfile)
{
skb_queue_purge(&tfile->sk.sk_receive_queue);
skb_queue_purge(&tfile->sk.sk_error_queue);
}
static void __tun_detach(struct tun_file *tfile, bool clean) static void __tun_detach(struct tun_file *tfile, bool clean)
{ {
struct tun_file *ntfile; struct tun_file *ntfile;
...@@ -435,7 +441,7 @@ static void __tun_detach(struct tun_file *tfile, bool clean) ...@@ -435,7 +441,7 @@ static void __tun_detach(struct tun_file *tfile, bool clean)
synchronize_net(); synchronize_net();
tun_flow_delete_by_queue(tun, tun->numqueues + 1); tun_flow_delete_by_queue(tun, tun->numqueues + 1);
/* Drop read queue */ /* Drop read queue */
skb_queue_purge(&tfile->sk.sk_receive_queue); tun_queue_purge(tfile);
tun_set_real_num_queues(tun); tun_set_real_num_queues(tun);
} else if (tfile->detached && clean) { } else if (tfile->detached && clean) {
tun = tun_enable_queue(tfile); tun = tun_enable_queue(tfile);
...@@ -487,12 +493,12 @@ static void tun_detach_all(struct net_device *dev) ...@@ -487,12 +493,12 @@ static void tun_detach_all(struct net_device *dev)
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
tfile = rtnl_dereference(tun->tfiles[i]); tfile = rtnl_dereference(tun->tfiles[i]);
/* Drop read queue */ /* Drop read queue */
skb_queue_purge(&tfile->sk.sk_receive_queue); tun_queue_purge(tfile);
sock_put(&tfile->sk); sock_put(&tfile->sk);
} }
list_for_each_entry_safe(tfile, tmp, &tun->disabled, next) { list_for_each_entry_safe(tfile, tmp, &tun->disabled, next) {
tun_enable_queue(tfile); tun_enable_queue(tfile);
skb_queue_purge(&tfile->sk.sk_receive_queue); tun_queue_purge(tfile);
sock_put(&tfile->sk); sock_put(&tfile->sk);
} }
BUG_ON(tun->numdisabled != 0); BUG_ON(tun->numdisabled != 0);
......
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