tun.c (7c0c3b1a8a175437991ccc898ed66ec5e4a96208) | tun.c (dd38bd853082355641d0034aaf368e13ef2438f8) |
---|---|
1/* 2 * TUN - Universal TUN/TAP device driver. 3 * Copyright (C) 1999-2002 Maxim Krasnyansky <maxk@qualcomm.com> 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 2 of the License, or 8 * (at your option) any later version. --- 414 unchanged lines hidden (view full) --- 423 else 424 tun_disable_queue(tun, tfile); 425 426 synchronize_net(); 427 tun_flow_delete_by_queue(tun, tun->numqueues + 1); 428 /* Drop read queue */ 429 skb_queue_purge(&tfile->sk.sk_receive_queue); 430 tun_set_real_num_queues(tun); | 1/* 2 * TUN - Universal TUN/TAP device driver. 3 * Copyright (C) 1999-2002 Maxim Krasnyansky <maxk@qualcomm.com> 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 2 of the License, or 8 * (at your option) any later version. --- 414 unchanged lines hidden (view full) --- 423 else 424 tun_disable_queue(tun, tfile); 425 426 synchronize_net(); 427 tun_flow_delete_by_queue(tun, tun->numqueues + 1); 428 /* Drop read queue */ 429 skb_queue_purge(&tfile->sk.sk_receive_queue); 430 tun_set_real_num_queues(tun); |
431 } else if (tfile->detached && clean) | 431 } else if (tfile->detached && clean) { |
432 tun = tun_enable_queue(tfile); | 432 tun = tun_enable_queue(tfile); |
433 sock_put(&tfile->sk); 434 } |
|
433 434 if (clean) { 435 if (tun && tun->numqueues == 0 && tun->numdisabled == 0 && 436 !(tun->flags & TUN_PERSIST)) 437 if (tun->dev->reg_state == NETREG_REGISTERED) 438 unregister_netdevice(tun->dev); 439 440 BUG_ON(!test_bit(SOCK_EXTERNALLY_ALLOCATED, --- 32 unchanged lines hidden (view full) --- 473 sock_put(&tfile->sk); 474 } 475 list_for_each_entry_safe(tfile, tmp, &tun->disabled, next) { 476 tun_enable_queue(tfile); 477 skb_queue_purge(&tfile->sk.sk_receive_queue); 478 sock_put(&tfile->sk); 479 } 480 BUG_ON(tun->numdisabled != 0); | 435 436 if (clean) { 437 if (tun && tun->numqueues == 0 && tun->numdisabled == 0 && 438 !(tun->flags & TUN_PERSIST)) 439 if (tun->dev->reg_state == NETREG_REGISTERED) 440 unregister_netdevice(tun->dev); 441 442 BUG_ON(!test_bit(SOCK_EXTERNALLY_ALLOCATED, --- 32 unchanged lines hidden (view full) --- 475 sock_put(&tfile->sk); 476 } 477 list_for_each_entry_safe(tfile, tmp, &tun->disabled, next) { 478 tun_enable_queue(tfile); 479 skb_queue_purge(&tfile->sk.sk_receive_queue); 480 sock_put(&tfile->sk); 481 } 482 BUG_ON(tun->numdisabled != 0); |
483 484 if (tun->flags & TUN_PERSIST) 485 module_put(THIS_MODULE); |
|
481} 482 483static int tun_attach(struct tun_struct *tun, struct file *file) 484{ 485 struct tun_file *tfile = file->private_data; 486 int err; 487 488 err = -EINVAL; --- 1380 unchanged lines hidden (view full) --- 1869 tun_debug(KERN_INFO, tun, "ignored: set checksum %s\n", 1870 arg ? "disabled" : "enabled"); 1871 break; 1872 1873 case TUNSETPERSIST: 1874 /* Disable/Enable persist mode. Keep an extra reference to the 1875 * module to prevent the module being unprobed. 1876 */ | 486} 487 488static int tun_attach(struct tun_struct *tun, struct file *file) 489{ 490 struct tun_file *tfile = file->private_data; 491 int err; 492 493 err = -EINVAL; --- 1380 unchanged lines hidden (view full) --- 1874 tun_debug(KERN_INFO, tun, "ignored: set checksum %s\n", 1875 arg ? "disabled" : "enabled"); 1876 break; 1877 1878 case TUNSETPERSIST: 1879 /* Disable/Enable persist mode. Keep an extra reference to the 1880 * module to prevent the module being unprobed. 1881 */ |
1877 if (arg) { | 1882 if (arg && !(tun->flags & TUN_PERSIST)) { |
1878 tun->flags |= TUN_PERSIST; 1879 __module_get(THIS_MODULE); | 1883 tun->flags |= TUN_PERSIST; 1884 __module_get(THIS_MODULE); |
1880 } else { | 1885 } 1886 if (!arg && (tun->flags & TUN_PERSIST)) { |
1881 tun->flags &= ~TUN_PERSIST; 1882 module_put(THIS_MODULE); 1883 } 1884 1885 tun_debug(KERN_INFO, tun, "persist %s\n", 1886 arg ? "enabled" : "disabled"); 1887 break; 1888 --- 377 unchanged lines hidden --- | 1887 tun->flags &= ~TUN_PERSIST; 1888 module_put(THIS_MODULE); 1889 } 1890 1891 tun_debug(KERN_INFO, tun, "persist %s\n", 1892 arg ? "enabled" : "disabled"); 1893 break; 1894 --- 377 unchanged lines hidden --- |