Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[VLAN]: Add a net argument to proc init and cleanup calls.

All proc files will be created in each net, so prepare them for
this change now, not to mess it with real creation patch.

The net != &init_net checks in them are for git-bisect sanity,
but I will drop them soon.

Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Acked-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Pavel Emelyanov and committed by
David S. Miller
cd1c7014 d9ed0f0e

+22 -15
+7 -8
net/8021q/vlan.c
··· 642 642 if (err < 0) 643 643 goto err_assign; 644 644 645 + err = vlan_proc_init(net); 646 + if (err < 0) 647 + goto err_proc; 648 + 645 649 return 0; 646 650 651 + err_proc: 652 + /* nothing */ 647 653 err_assign: 648 654 kfree(vn); 649 655 err_alloc: ··· 661 655 struct vlan_net *vn; 662 656 663 657 vn = net_generic(net, vlan_net_id); 658 + vlan_proc_cleanup(net); 664 659 kfree(vn); 665 660 } 666 661 ··· 681 674 if (err < 0) 682 675 goto err0; 683 676 684 - err = vlan_proc_init(); 685 - if (err < 0) 686 - goto err1; 687 - 688 677 err = register_netdevice_notifier(&vlan_notifier_block); 689 678 if (err < 0) 690 679 goto err2; ··· 696 693 err3: 697 694 unregister_netdevice_notifier(&vlan_notifier_block); 698 695 err2: 699 - vlan_proc_cleanup(); 700 - err1: 701 696 unregister_pernet_gen_device(vlan_net_id, &vlan_net_ops); 702 697 err0: 703 698 return err; ··· 715 714 /* This table must be empty if there are no module references left. */ 716 715 for (i = 0; i < VLAN_GRP_HASH_SIZE; i++) 717 716 BUG_ON(!hlist_empty(&vlan_group_hash[i])); 718 - 719 - vlan_proc_cleanup(); 720 717 721 718 unregister_pernet_gen_device(vlan_net_id, &vlan_net_ops); 722 719
+9 -3
net/8021q/vlanproc.c
··· 138 138 * Clean up /proc/net/vlan entries 139 139 */ 140 140 141 - void vlan_proc_cleanup(void) 141 + void vlan_proc_cleanup(struct net *net) 142 142 { 143 + if (net != &init_net) 144 + return; 145 + 143 146 if (proc_vlan_conf) 144 147 remove_proc_entry(name_conf, proc_vlan_dir); 145 148 ··· 158 155 * Create /proc/net/vlan entries 159 156 */ 160 157 161 - int __init vlan_proc_init(void) 158 + int vlan_proc_init(struct net *net) 162 159 { 160 + if (net != &init_net) 161 + return 0; 162 + 163 163 proc_vlan_dir = proc_mkdir(name_root, init_net.proc_net); 164 164 if (!proc_vlan_dir) 165 165 goto err; ··· 175 169 176 170 err: 177 171 pr_err("%s: can't create entry in proc filesystem!\n", __func__); 178 - vlan_proc_cleanup(); 172 + vlan_proc_cleanup(net); 179 173 return -ENOBUFS; 180 174 } 181 175
+6 -4
net/8021q/vlanproc.h
··· 2 2 #define __BEN_VLAN_PROC_INC__ 3 3 4 4 #ifdef CONFIG_PROC_FS 5 - int vlan_proc_init(void); 5 + struct net; 6 + 7 + int vlan_proc_init(struct net *net); 6 8 int vlan_proc_rem_dev(struct net_device *vlandev); 7 9 int vlan_proc_add_dev(struct net_device *vlandev); 8 - void vlan_proc_cleanup(void); 10 + void vlan_proc_cleanup(struct net *net); 9 11 10 12 #else /* No CONFIG_PROC_FS */ 11 13 12 - #define vlan_proc_init() (0) 13 - #define vlan_proc_cleanup() do {} while (0) 14 + #define vlan_proc_init(net) (0) 15 + #define vlan_proc_cleanup(net) do {} while (0) 14 16 #define vlan_proc_add_dev(dev) ({(void)(dev), 0; }) 15 17 #define vlan_proc_rem_dev(dev) ({(void)(dev), 0; }) 16 18 #endif