Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 457c4cbc authored by Eric W. Biederman's avatar Eric W. Biederman Committed by David S. Miller
Browse files

[NET]: Make /proc/net per network namespace



This patch makes /proc/net per network namespace.  It modifies the global
variables proc_net and proc_net_stat to be per network namespace.
The proc_net file helpers are modified to take a network namespace argument,
and all of their callers are fixed to pass &init_net for that argument.
This ensures that all of the /proc/net files are only visible and
usable in the initial network namespace until the code behind them
has been updated to be handle multiple network namespaces.

Making /proc/net per namespace is necessary as at least some files
in /proc/net depend upon the set of network devices which is per
network namespace, and even more files in /proc/net have contents
that are relevant to a single network namespace.

Signed-off-by: default avatarEric W. Biederman <ebiederm@xmission.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 07feaebf
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
#include <linux/fs.h>
#endif
#include <linux/isdnif.h>
#include <net/net_namespace.h>
#include "isdn_divert.h"


@@ -284,12 +285,12 @@ divert_dev_init(void)
	init_waitqueue_head(&rd_queue);

#ifdef CONFIG_PROC_FS
	isdn_proc_entry = proc_mkdir("net/isdn", NULL);
	isdn_proc_entry = proc_mkdir("isdn", init_net.proc_net);
	if (!isdn_proc_entry)
		return (-1);
	isdn_divert_entry = create_proc_entry("divert", S_IFREG | S_IRUGO, isdn_proc_entry);
	if (!isdn_divert_entry) {
		remove_proc_entry("net/isdn", NULL);
		remove_proc_entry("isdn", init_net.proc_net);
		return (-1);
	}
	isdn_divert_entry->proc_fops = &isdn_fops; 
@@ -309,7 +310,7 @@ divert_dev_deinit(void)

#ifdef CONFIG_PROC_FS
	remove_proc_entry("divert", isdn_proc_entry);
	remove_proc_entry("net/isdn", NULL);
	remove_proc_entry("isdn", init_net.proc_net);
#endif	/* CONFIG_PROC_FS */

	return (0);
+3 −2
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/proc_fs.h>
#include <net/net_namespace.h>

#include "platform.h"
#include "di_defs.h"
@@ -86,7 +87,7 @@ proc_read(char *page, char **start, off_t off, int count, int *eof,

static int DIVA_INIT_FUNCTION create_proc(void)
{
	proc_net_eicon = proc_mkdir("net/eicon", NULL);
	proc_net_eicon = proc_mkdir("eicon", init_net.proc_net);

	if (proc_net_eicon) {
		if ((proc_didd =
@@ -102,7 +103,7 @@ static int DIVA_INIT_FUNCTION create_proc(void)
static void remove_proc(void)
{
	remove_proc_entry(DRIVERLNAME, proc_net_eicon);
	remove_proc_entry("net/eicon", NULL);
	remove_proc_entry("eicon", init_net.proc_net);
}

static int DIVA_INIT_FUNCTION divadidd_init(void)
+3 −2
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@
#include <linux/proc_fs.h>
#include <linux/pci.h>
#include <linux/smp_lock.h>
#include <net/net_namespace.h>

#include "hysdn_defs.h"

@@ -392,7 +393,7 @@ hysdn_procconf_init(void)
	hysdn_card *card;
	unsigned char conf_name[20];

	hysdn_proc_entry = proc_mkdir(PROC_SUBDIR_NAME, proc_net);
	hysdn_proc_entry = proc_mkdir(PROC_SUBDIR_NAME, init_net.proc_net);
	if (!hysdn_proc_entry) {
		printk(KERN_ERR "HYSDN: unable to create hysdn subdir\n");
		return (-1);
@@ -437,5 +438,5 @@ hysdn_procconf_release(void)
		card = card->next;	/* point to next card */
	}

	remove_proc_entry(PROC_SUBDIR_NAME, proc_net);
	remove_proc_entry(PROC_SUBDIR_NAME, init_net.proc_net);
}
+4 −3
Original line number Diff line number Diff line
@@ -75,6 +75,7 @@
#include <linux/if_vlan.h>
#include <linux/if_bonding.h>
#include <net/route.h>
#include <net/net_namespace.h>
#include "bonding.h"
#include "bond_3ad.h"
#include "bond_alb.h"
@@ -3144,7 +3145,7 @@ static void bond_create_proc_dir(void)
{
	int len = strlen(DRV_NAME);

	for (bond_proc_dir = proc_net->subdir; bond_proc_dir;
	for (bond_proc_dir = init_net.proc_net->subdir; bond_proc_dir;
	     bond_proc_dir = bond_proc_dir->next) {
		if ((bond_proc_dir->namelen == len) &&
		    !memcmp(bond_proc_dir->name, DRV_NAME, len)) {
@@ -3153,7 +3154,7 @@ static void bond_create_proc_dir(void)
	}

	if (!bond_proc_dir) {
		bond_proc_dir = proc_mkdir(DRV_NAME, proc_net);
		bond_proc_dir = proc_mkdir(DRV_NAME, init_net.proc_net);
		if (bond_proc_dir) {
			bond_proc_dir->owner = THIS_MODULE;
		} else {
@@ -3188,7 +3189,7 @@ static void bond_destroy_proc_dir(void)
			bond_proc_dir->owner = NULL;
		}
	} else {
		remove_proc_entry(DRV_NAME, proc_net);
		remove_proc_entry(DRV_NAME, init_net.proc_net);
		bond_proc_dir = NULL;
	}
}
+3 −2
Original line number Diff line number Diff line
@@ -83,6 +83,7 @@

#include <net/ip.h>
#include <net/arp.h>
#include <net/net_namespace.h>

#include <linux/bpqether.h>

@@ -594,7 +595,7 @@ static int bpq_device_event(struct notifier_block *this,unsigned long event, voi
static int __init bpq_init_driver(void)
{
#ifdef CONFIG_PROC_FS
	if (!proc_net_fops_create("bpqether", S_IRUGO, &bpq_info_fops)) {
	if (!proc_net_fops_create(&init_net, "bpqether", S_IRUGO, &bpq_info_fops)) {
		printk(KERN_ERR
			"bpq: cannot create /proc/net/bpqether entry.\n");
		return -ENOENT;
@@ -618,7 +619,7 @@ static void __exit bpq_cleanup_driver(void)

	unregister_netdevice_notifier(&bpq_dev_notifier);

	proc_net_remove("bpqether");
	proc_net_remove(&init_net, "bpqether");

	rtnl_lock();
	while (!list_empty(&bpq_devices)) {
Loading