};
int class_create_file_ns(const struct class *cls, const struct class_attribute *attr,
- const void *ns)
+ const struct ns_common *ns)
{
struct subsys_private *sp = class_to_subsys(cls);
int error;
EXPORT_SYMBOL_GPL(class_create_file_ns);
void class_remove_file_ns(const struct class *cls, const struct class_attribute *attr,
- const void *ns)
+ const struct ns_common *ns)
{
struct subsys_private *sp = class_to_subsys(cls);
kfree(p);
}
-static const void *device_namespace(const struct kobject *kobj)
+static const struct ns_common *device_namespace(const struct kobject *kobj)
{
const struct device *dev = kobj_to_dev(kobj);
- const void *ns = NULL;
if (dev->class && dev->class->namespace)
- ns = dev->class->namespace(dev);
+ return dev->class->namespace(dev);
- return ns;
+ return NULL;
}
static void device_get_ownership(const struct kobject *kobj, kuid_t *uid, kgid_t *gid)
return 0;
}
-static const void *net_namespace(const struct device *d)
+static const struct ns_common *net_namespace(const struct device *d)
{
const struct ib_core_device *coredev =
container_of(d, struct ib_core_device, dev);
+ struct net *net = read_pnet(&coredev->rdma_net);
- return read_pnet(&coredev->rdma_net);
+ return net ? to_ns_common(net) : NULL;
}
static struct class ib_class = {
#include <linux/jiffies.h>
#include <linux/lockdep.h>
#include <linux/inet.h>
+#include <net/net_namespace.h>
#include <rdma/ib_cache.h>
#include <linux/atomic.h>
scsi_remove_host(target->scsi_host);
srp_stop_rport_timers(target->rport);
srp_disconnect_target(target);
- kobj_ns_drop(KOBJ_NS_TYPE_NET, target->net);
+ kobj_ns_drop(KOBJ_NS_TYPE_NET, to_ns_common(target->net));
for (i = 0; i < target->ch_count; i++) {
ch = &target->ch[i];
srp_free_ch_ib(target, ch);
target = host_to_target(target_host);
- target->net = kobj_ns_grab_current(KOBJ_NS_TYPE_NET);
+ target->net = to_net_ns(kobj_ns_grab_current(KOBJ_NS_TYPE_NET));
target->io_class = SRP_REV16A_IB_IO_CLASS;
target->scsi_host = target_host;
target->srp_host = host;
* earlier in this function.
*/
if (target->state != SRP_TARGET_REMOVED)
- kobj_ns_drop(KOBJ_NS_TYPE_NET, target->net);
+ kobj_ns_drop(KOBJ_NS_TYPE_NET, to_ns_common(target->net));
scsi_host_put(target->scsi_host);
}
sysfs_attr_init(&bn->class_attr_bonding_masters.attr);
ret = netdev_class_create_file_ns(&bn->class_attr_bonding_masters,
- bn->net);
+ to_ns_common(bn->net));
/* Permit multiple loads of the module by ignoring failures to
* create the bonding_masters sysfs file. Bonding devices
* created by second or subsequent loads of the module will
/* Remove /sys/class/net/bonding_masters. */
void __net_exit bond_destroy_sysfs(struct bond_net *bn)
{
- netdev_class_remove_file_ns(&bn->class_attr_bonding_masters, bn->net);
+ netdev_class_remove_file_ns(&bn->class_attr_bonding_masters, to_ns_common(bn->net));
}
/* Initialize sysfs for each bond. This sets up and registers
static dev_t ipvtap_major;
static struct cdev ipvtap_cdev;
-static const void *ipvtap_net_namespace(const struct device *d)
+static const struct ns_common *ipvtap_net_namespace(const struct device *d)
{
const struct net_device *dev = to_net_dev(d->parent);
- return dev_net(dev);
+
+ return to_ns_common(dev_net(dev));
}
static struct class ipvtap_class = {
*/
static dev_t macvtap_major;
-static const void *macvtap_net_namespace(const struct device *d)
+static const struct ns_common *macvtap_net_namespace(const struct device *d)
{
const struct net_device *dev = to_net_dev(d->parent);
- return dev_net(dev);
+
+ return to_ns_common(dev_net(dev));
}
static struct class macvtap_class = {
*
* Return: 31-bit hash of ns + name (so it fits in an off_t)
*/
-static unsigned int kernfs_name_hash(const char *name, const void *ns)
+static unsigned int kernfs_name_hash(const char *name,
+ const struct ns_common *ns)
{
unsigned long hash = init_name_hash(ns);
unsigned int len = strlen(name);
}
static int kernfs_name_compare(unsigned int hash, const char *name,
- const void *ns, const struct kernfs_node *kn)
+ const struct ns_common *ns, const struct kernfs_node *kn)
{
if (hash < kn->hash)
return -1;
*/
static struct kernfs_node *kernfs_find_ns(struct kernfs_node *parent,
const unsigned char *name,
- const void *ns)
+ const struct ns_common *ns)
{
struct rb_node *node = parent->dir.children.rb_node;
bool has_ns = kernfs_ns_enabled(parent);
static struct kernfs_node *kernfs_walk_ns(struct kernfs_node *parent,
const unsigned char *path,
- const void *ns)
+ const struct ns_common *ns)
{
ssize_t len;
char *p, *name;
* Return: pointer to the found kernfs_node on success, %NULL on failure.
*/
struct kernfs_node *kernfs_find_and_get_ns(struct kernfs_node *parent,
- const char *name, const void *ns)
+ const char *name,
+ const struct ns_common *ns)
{
struct kernfs_node *kn;
struct kernfs_root *root = kernfs_root(parent);
* Return: pointer to the found kernfs_node on success, %NULL on failure.
*/
struct kernfs_node *kernfs_walk_and_get_ns(struct kernfs_node *parent,
- const char *path, const void *ns)
+ const char *path,
+ const struct ns_common *ns)
{
struct kernfs_node *kn;
struct kernfs_root *root = kernfs_root(parent);
struct kernfs_node *kernfs_create_dir_ns(struct kernfs_node *parent,
const char *name, umode_t mode,
kuid_t uid, kgid_t gid,
- void *priv, const void *ns)
+ void *priv,
+ const struct ns_common *ns)
{
struct kernfs_node *kn;
int rc;
struct kernfs_node *kn;
struct kernfs_root *root;
struct inode *inode = NULL;
- const void *ns = NULL;
+ const struct ns_common *ns = NULL;
root = kernfs_root(parent);
down_read(&root->kernfs_rwsem);
* Return: %0 on success, -ENOENT if such entry doesn't exist.
*/
int kernfs_remove_by_name_ns(struct kernfs_node *parent, const char *name,
- const void *ns)
+ const struct ns_common *ns)
{
struct kernfs_node *kn;
struct kernfs_root *root;
* Return: %0 on success, -errno on failure.
*/
int kernfs_rename_ns(struct kernfs_node *kn, struct kernfs_node *new_parent,
- const char *new_name, const void *new_ns)
+ const char *new_name, const struct ns_common *new_ns)
{
struct kernfs_node *old_parent;
struct kernfs_root *root;
return 0;
}
-static struct kernfs_node *kernfs_dir_pos(const void *ns,
+static struct kernfs_node *kernfs_dir_pos(const struct ns_common *ns,
struct kernfs_node *parent, loff_t hash, struct kernfs_node *pos)
{
if (pos) {
return pos;
}
-static struct kernfs_node *kernfs_dir_next_pos(const void *ns,
+static struct kernfs_node *kernfs_dir_next_pos(const struct ns_common *ns,
struct kernfs_node *parent, ino_t ino, struct kernfs_node *pos)
{
pos = kernfs_dir_pos(ns, parent, ino, pos);
struct kernfs_node *parent = kernfs_dentry_node(dentry);
struct kernfs_node *pos = file->private_data;
struct kernfs_root *root;
- const void *ns = NULL;
+ const struct ns_common *ns = NULL;
if (!dir_emit_dots(file, ctx))
return 0;
umode_t mode, kuid_t uid, kgid_t gid,
loff_t size,
const struct kernfs_ops *ops,
- void *priv, const void *ns,
+ void *priv, const struct ns_common *ns,
struct lock_class_key *key)
{
struct kernfs_node *kn;
* instance. If multiple tags become necessary, make the following
* an array and compare kernfs_node tag against every entry.
*/
- const void *ns;
+ const struct ns_common *ns;
/* anchored at kernfs_root->supers, protected by kernfs_rwsem */
struct list_head node;
*
* Return: the namespace tag associated with kernfs super_block @sb.
*/
-const void *kernfs_super_ns(struct super_block *sb)
+const struct ns_common *kernfs_super_ns(struct super_block *sb)
{
struct kernfs_super_info *info = kernfs_info(sb);
#include <linux/netdevice.h>
#include <linux/string.h>
#include <linux/nfs_fs.h>
+#include <net/net_namespace.h>
#include <linux/rcupdate.h>
#include <linux/lockd/lockd.h>
kfree(rcu_dereference_raw(c->identifier));
}
-static const void *nfs_netns_client_namespace(const struct kobject *kobj)
+static const struct ns_common *nfs_netns_client_namespace(const struct kobject *kobj)
{
- return container_of(kobj, struct nfs_netns_client, kobject)->net;
+ return to_ns_common(container_of(kobj, struct nfs_netns_client,
+ kobject)->net);
}
static struct kobj_attribute nfs_netns_client_id = __ATTR(identifier,
kfree(c);
}
-static const void *nfs_netns_namespace(const struct kobject *kobj)
+static const struct ns_common *nfs_netns_namespace(const struct kobject *kobj)
{
- return container_of(kobj, struct nfs_netns_client, nfs_net_kobj)->net;
+ return to_ns_common(container_of(kobj, struct nfs_netns_client,
+ nfs_net_kobj)->net);
}
static struct kobj_type nfs_netns_object_type = {
/* no-op: why? see lib/kobject.c kobject_cleanup() */
}
-static const void *nfs_netns_server_namespace(const struct kobject *kobj)
+static const struct ns_common *nfs_netns_server_namespace(const struct kobject *kobj)
{
- return container_of(kobj, struct nfs_server, kobj)->nfs_client->cl_net;
+ return to_ns_common(container_of(kobj, struct nfs_server,
+ kobj)->nfs_client->cl_net);
}
static struct kobj_type nfs_sb_ktype = {
* @kobj: object we're creating directory for
* @ns: the namespace tag to use
*/
-int sysfs_create_dir_ns(struct kobject *kobj, const void *ns)
+int sysfs_create_dir_ns(struct kobject *kobj, const struct ns_common *ns)
{
struct kernfs_node *parent, *kn;
kuid_t uid;
}
int sysfs_rename_dir_ns(struct kobject *kobj, const char *new_name,
- const void *new_ns)
+ const struct ns_common *new_ns)
{
struct kernfs_node *parent;
int ret;
}
int sysfs_move_dir_ns(struct kobject *kobj, struct kobject *new_parent_kobj,
- const void *new_ns)
+ const struct ns_common *new_ns)
{
struct kernfs_node *kn = kobj->sd;
struct kernfs_node *new_parent;
int sysfs_add_file_mode_ns(struct kernfs_node *parent,
const struct attribute *attr, umode_t mode, kuid_t uid,
- kgid_t gid, const void *ns)
+ kgid_t gid, const struct ns_common *ns)
{
struct kobject *kobj = parent->priv;
const struct sysfs_ops *sysfs_ops = kobj->ktype->sysfs_ops;
int sysfs_add_bin_file_mode_ns(struct kernfs_node *parent,
const struct bin_attribute *battr, umode_t mode, size_t size,
- kuid_t uid, kgid_t gid, const void *ns)
+ kuid_t uid, kgid_t gid, const struct ns_common *ns)
{
const struct attribute *attr = &battr->attr;
struct lock_class_key *key = NULL;
* @ns: namespace the new file should belong to
*/
int sysfs_create_file_ns(struct kobject *kobj, const struct attribute *attr,
- const void *ns)
+ const struct ns_common *ns)
{
kuid_t uid;
kgid_t gid;
* Hash the attribute name and namespace tag and kill the victim.
*/
void sysfs_remove_file_ns(struct kobject *kobj, const struct attribute *attr,
- const void *ns)
+ const struct ns_common *ns)
{
struct kernfs_node *parent = kobj->sd;
static int sysfs_init_fs_context(struct fs_context *fc)
{
struct kernfs_fs_context *kfc;
- struct net *netns;
+ struct ns_common *ns;
if (!(fc->sb_flags & SB_KERNMOUNT)) {
if (!kobj_ns_current_may_mount(KOBJ_NS_TYPE_NET))
if (!kfc)
return -ENOMEM;
- kfc->ns_tag = netns = kobj_ns_grab_current(KOBJ_NS_TYPE_NET);
+ kfc->ns_tag = ns = kobj_ns_grab_current(KOBJ_NS_TYPE_NET);
kfc->root = sysfs_root;
kfc->magic = SYSFS_MAGIC;
fc->fs_private = kfc;
fc->ops = &sysfs_fs_context_ops;
- if (netns) {
+ if (ns) {
+ struct net *netns = to_net_ns(ns);
+
put_user_ns(fc->user_ns);
fc->user_ns = get_user_ns(netns->user_ns);
}
static void sysfs_kill_sb(struct super_block *sb)
{
- void *ns = (void *)kernfs_super_ns(sb);
+ struct ns_common *ns = (struct ns_common *)kernfs_super_ns(sb);
kernfs_kill_sb(sb);
kobj_ns_drop(KOBJ_NS_TYPE_NET, ns);
void sysfs_delete_link(struct kobject *kobj, struct kobject *targ,
const char *name)
{
- const void *ns = NULL;
+ const struct ns_common *ns = NULL;
/*
* We don't own @target and it may be removed at any time.
* A helper function for the common rename symlink idiom.
*/
int sysfs_rename_link_ns(struct kobject *kobj, struct kobject *targ,
- const char *old, const char *new, const void *new_ns)
+ const char *old, const char *new,
+ const struct ns_common *new_ns)
{
struct kernfs_node *parent, *kn = NULL;
- const void *old_ns = NULL;
+ const struct ns_common *old_ns = NULL;
int result;
if (!kobj)
*/
int sysfs_add_file_mode_ns(struct kernfs_node *parent,
const struct attribute *attr, umode_t amode, kuid_t uid,
- kgid_t gid, const void *ns);
+ kgid_t gid, const struct ns_common *ns);
int sysfs_add_bin_file_mode_ns(struct kernfs_node *parent,
const struct bin_attribute *battr, umode_t mode, size_t size,
- kuid_t uid, kgid_t gid, const void *ns);
+ kuid_t uid, kgid_t gid, const struct ns_common *ns);
/*
* symlink.c
int (*shutdown_pre)(struct device *dev);
const struct kobj_ns_type_operations *ns_type;
- const void *(*namespace)(const struct device *dev);
+ const struct ns_common *(*namespace)(const struct device *dev);
void (*get_ownership)(const struct device *dev, kuid_t *uid, kgid_t *gid);
struct class_attribute class_attr_##_name = __ATTR_WO(_name)
int __must_check class_create_file_ns(const struct class *class, const struct class_attribute *attr,
- const void *ns);
+ const struct ns_common *ns);
void class_remove_file_ns(const struct class *class, const struct class_attribute *attr,
- const void *ns);
+ const struct ns_common *ns);
static inline int __must_check class_create_file(const struct class *class,
const struct class_attribute *attr)
struct file;
struct dentry;
struct iattr;
+struct ns_common;
struct seq_file;
struct vm_area_struct;
struct vm_operations_struct;
struct rb_node rb;
- const void *ns; /* namespace tag */
+ const struct ns_common *ns; /* namespace tag */
unsigned int hash; /* ns + name hash */
unsigned short flags;
umode_t mode;
*/
struct kernfs_fs_context {
struct kernfs_root *root; /* Root of the hierarchy being mounted */
- void *ns_tag; /* Namespace tag of the mount (or NULL) */
+ struct ns_common *ns_tag; /* Namespace tag of the mount (or NULL) */
unsigned long magic; /* File system specific magic number */
/* The following are set/used by kernfs_mount() */
void pr_cont_kernfs_path(struct kernfs_node *kn);
struct kernfs_node *kernfs_get_parent(struct kernfs_node *kn);
struct kernfs_node *kernfs_find_and_get_ns(struct kernfs_node *parent,
- const char *name, const void *ns);
+ const char *name,
+ const struct ns_common *ns);
struct kernfs_node *kernfs_walk_and_get_ns(struct kernfs_node *parent,
- const char *path, const void *ns);
+ const char *path,
+ const struct ns_common *ns);
void kernfs_get(struct kernfs_node *kn);
void kernfs_put(struct kernfs_node *kn);
struct kernfs_node *kernfs_create_dir_ns(struct kernfs_node *parent,
const char *name, umode_t mode,
kuid_t uid, kgid_t gid,
- void *priv, const void *ns);
+ void *priv,
+ const struct ns_common *ns);
struct kernfs_node *kernfs_create_empty_dir(struct kernfs_node *parent,
const char *name);
struct kernfs_node *__kernfs_create_file(struct kernfs_node *parent,
kuid_t uid, kgid_t gid,
loff_t size,
const struct kernfs_ops *ops,
- void *priv, const void *ns,
+ void *priv,
+ const struct ns_common *ns,
struct lock_class_key *key);
struct kernfs_node *kernfs_create_link(struct kernfs_node *parent,
const char *name,
void kernfs_unbreak_active_protection(struct kernfs_node *kn);
bool kernfs_remove_self(struct kernfs_node *kn);
int kernfs_remove_by_name_ns(struct kernfs_node *parent, const char *name,
- const void *ns);
+ const struct ns_common *ns);
int kernfs_rename_ns(struct kernfs_node *kn, struct kernfs_node *new_parent,
- const char *new_name, const void *new_ns);
+ const char *new_name, const struct ns_common *new_ns);
int kernfs_setattr(struct kernfs_node *kn, const struct iattr *iattr);
__poll_t kernfs_generic_poll(struct kernfs_open_file *of,
struct poll_table_struct *pt);
int kernfs_xattr_set(struct kernfs_node *kn, const char *name,
const void *value, size_t size, int flags);
-const void *kernfs_super_ns(struct super_block *sb);
+const struct ns_common *kernfs_super_ns(struct super_block *sb);
int kernfs_get_tree(struct fs_context *fc);
void kernfs_free_fs_context(struct fs_context *fc);
void kernfs_kill_sb(struct super_block *sb);
static inline struct kernfs_node *
kernfs_find_and_get_ns(struct kernfs_node *parent, const char *name,
- const void *ns)
+ const struct ns_common *ns)
{ return NULL; }
static inline struct kernfs_node *
kernfs_walk_and_get_ns(struct kernfs_node *parent, const char *path,
- const void *ns)
+ const struct ns_common *ns)
{ return NULL; }
static inline void kernfs_get(struct kernfs_node *kn) { }
static inline struct kernfs_node *
kernfs_create_dir_ns(struct kernfs_node *parent, const char *name,
umode_t mode, kuid_t uid, kgid_t gid,
- void *priv, const void *ns)
+ void *priv, const struct ns_common *ns)
{ return ERR_PTR(-ENOSYS); }
static inline struct kernfs_node *
__kernfs_create_file(struct kernfs_node *parent, const char *name,
umode_t mode, kuid_t uid, kgid_t gid,
loff_t size, const struct kernfs_ops *ops,
- void *priv, const void *ns, struct lock_class_key *key)
+ void *priv, const struct ns_common *ns,
+ struct lock_class_key *key)
{ return ERR_PTR(-ENOSYS); }
static inline struct kernfs_node *
{ return false; }
static inline int kernfs_remove_by_name_ns(struct kernfs_node *kn,
- const char *name, const void *ns)
+ const char *name,
+ const struct ns_common *ns)
{ return -ENOSYS; }
static inline int kernfs_rename_ns(struct kernfs_node *kn,
struct kernfs_node *new_parent,
- const char *new_name, const void *new_ns)
+ const char *new_name,
+ const struct ns_common *new_ns)
{ return -ENOSYS; }
static inline int kernfs_setattr(struct kernfs_node *kn,
const void *value, size_t size, int flags)
{ return -ENOSYS; }
-static inline const void *kernfs_super_ns(struct super_block *sb)
+static inline const struct ns_common *kernfs_super_ns(struct super_block *sb)
{ return NULL; }
static inline int kernfs_get_tree(struct fs_context *fc)
struct kobject * __must_check kobject_get_unless_zero(struct kobject *kobj);
void kobject_put(struct kobject *kobj);
-const void *kobject_namespace(const struct kobject *kobj);
+const struct ns_common *kobject_namespace(const struct kobject *kobj);
void kobject_get_ownership(const struct kobject *kobj, kuid_t *uid, kgid_t *gid);
char *kobject_get_path(const struct kobject *kobj, gfp_t flag);
const struct sysfs_ops *sysfs_ops;
const struct attribute_group **default_groups;
const struct kobj_ns_type_operations *(*child_ns_type)(const struct kobject *kobj);
- const void *(*namespace)(const struct kobject *kobj);
+ const struct ns_common *(*namespace)(const struct kobject *kobj);
void (*get_ownership)(const struct kobject *kobj, kuid_t *uid, kgid_t *gid);
};
#ifndef _LINUX_KOBJECT_NS_H
#define _LINUX_KOBJECT_NS_H
+struct ns_common;
struct sock;
struct kobject;
struct kobj_ns_type_operations {
enum kobj_ns_type type;
bool (*current_may_mount)(void);
- void *(*grab_current_ns)(void);
- const void *(*netlink_ns)(struct sock *sk);
- const void *(*initial_ns)(void);
- void (*drop_ns)(void *);
+ struct ns_common *(*grab_current_ns)(void);
+ const struct ns_common *(*netlink_ns)(struct sock *sk);
+ const struct ns_common *(*initial_ns)(void);
+ void (*drop_ns)(struct ns_common *);
};
int kobj_ns_type_register(const struct kobj_ns_type_operations *ops);
const struct kobj_ns_type_operations *kobj_ns_ops(const struct kobject *kobj);
bool kobj_ns_current_may_mount(enum kobj_ns_type type);
-void *kobj_ns_grab_current(enum kobj_ns_type type);
-void kobj_ns_drop(enum kobj_ns_type type, void *ns);
+struct ns_common *kobj_ns_grab_current(enum kobj_ns_type type);
+void kobj_ns_drop(enum kobj_ns_type type, struct ns_common *ns);
#endif /* _LINUX_KOBJECT_NS_H */
}
int netdev_class_create_file_ns(const struct class_attribute *class_attr,
- const void *ns);
+ const struct ns_common *ns);
void netdev_class_remove_file_ns(const struct class_attribute *class_attr,
- const void *ns);
+ const struct ns_common *ns);
extern const struct kobj_ns_type_operations net_ns_type_operations;
#ifdef CONFIG_SYSFS
-int __must_check sysfs_create_dir_ns(struct kobject *kobj, const void *ns);
+int __must_check sysfs_create_dir_ns(struct kobject *kobj, const struct ns_common *ns);
void sysfs_remove_dir(struct kobject *kobj);
int __must_check sysfs_rename_dir_ns(struct kobject *kobj, const char *new_name,
- const void *new_ns);
+ const struct ns_common *new_ns);
int __must_check sysfs_move_dir_ns(struct kobject *kobj,
struct kobject *new_parent_kobj,
- const void *new_ns);
+ const struct ns_common *new_ns);
int __must_check sysfs_create_mount_point(struct kobject *parent_kobj,
const char *name);
void sysfs_remove_mount_point(struct kobject *parent_kobj,
int __must_check sysfs_create_file_ns(struct kobject *kobj,
const struct attribute *attr,
- const void *ns);
+ const struct ns_common *ns);
int __must_check sysfs_create_files(struct kobject *kobj,
const struct attribute * const *attr);
int __must_check sysfs_chmod_file(struct kobject *kobj,
const struct attribute *attr);
void sysfs_unbreak_active_protection(struct kernfs_node *kn);
void sysfs_remove_file_ns(struct kobject *kobj, const struct attribute *attr,
- const void *ns);
+ const struct ns_common *ns);
bool sysfs_remove_file_self(struct kobject *kobj, const struct attribute *attr);
void sysfs_remove_files(struct kobject *kobj, const struct attribute * const *attr);
int sysfs_rename_link_ns(struct kobject *kobj, struct kobject *target,
const char *old_name, const char *new_name,
- const void *new_ns);
+ const struct ns_common *new_ns);
void sysfs_delete_link(struct kobject *dir, struct kobject *targ,
const char *name);
#else /* CONFIG_SYSFS */
-static inline int sysfs_create_dir_ns(struct kobject *kobj, const void *ns)
+static inline int sysfs_create_dir_ns(struct kobject *kobj, const struct ns_common *ns)
{
return 0;
}
}
static inline int sysfs_rename_dir_ns(struct kobject *kobj,
- const char *new_name, const void *new_ns)
+ const char *new_name, const struct ns_common *new_ns)
{
return 0;
}
static inline int sysfs_move_dir_ns(struct kobject *kobj,
struct kobject *new_parent_kobj,
- const void *new_ns)
+ const struct ns_common *new_ns)
{
return 0;
}
static inline int sysfs_create_file_ns(struct kobject *kobj,
const struct attribute *attr,
- const void *ns)
+ const struct ns_common *ns)
{
return 0;
}
static inline void sysfs_remove_file_ns(struct kobject *kobj,
const struct attribute *attr,
- const void *ns)
+ const struct ns_common *ns)
{
}
static inline int sysfs_rename_link_ns(struct kobject *k, struct kobject *t,
const char *old_name,
- const char *new_name, const void *ns)
+ const char *new_name, const struct ns_common *ns)
{
return 0;
}
#define ipx_unregister_sysctl()
#endif
-#ifdef CONFIG_NET_NS
-void __put_net(struct net *net);
-
static inline struct net *to_net_ns(struct ns_common *ns)
{
return container_of(ns, struct net, ns);
}
+#ifdef CONFIG_NET_NS
+void __put_net(struct net *net);
+
/* Try using get_net_track() instead */
static inline struct net *get_net(struct net *net)
{
return ns_ref_read(net) != 0;
}
-void net_drop_ns(void *);
+void net_drop_ns(struct ns_common *);
void net_passive_dec(struct net *net);
#else
* and thus @kobj should have a namespace tag associated with it. Returns
* %NULL otherwise.
*/
-const void *kobject_namespace(const struct kobject *kobj)
+const struct ns_common *kobject_namespace(const struct kobject *kobj)
{
const struct kobj_ns_type_operations *ns_ops = kobj_ns_ops(kobj);
return may_mount;
}
-void *kobj_ns_grab_current(enum kobj_ns_type type)
+struct ns_common *kobj_ns_grab_current(enum kobj_ns_type type)
{
- void *ns = NULL;
+ struct ns_common *ns = NULL;
spin_lock(&kobj_ns_type_lock);
if (kobj_ns_type_is_valid(type) && kobj_ns_ops_tbl[type])
}
EXPORT_SYMBOL_GPL(kobj_ns_grab_current);
-void kobj_ns_drop(enum kobj_ns_type type, void *ns)
+void kobj_ns_drop(enum kobj_ns_type type, struct ns_common *ns)
{
spin_lock(&kobj_ns_type_lock);
if (kobj_ns_type_is_valid(type) &&
ops = kobj_ns_ops(kobj);
if (ops) {
- const void *init_ns, *ns;
+ const struct ns_common *init_ns, *ns;
ns = kobj->ktype->namespace(kobj);
init_ns = ops->initial_ns();
#ifdef CONFIG_NET
const struct kobj_ns_type_operations *ops;
- const struct net *net = NULL;
+ const struct ns_common *ns = NULL;
ops = kobj_ns_ops(kobj);
if (!ops && kobj->kset) {
*/
if (ops && ops->netlink_ns && kobj->ktype->namespace)
if (ops->type == KOBJ_NS_TYPE_NET)
- net = kobj->ktype->namespace(kobj);
+ ns = kobj->ktype->namespace(kobj);
- if (!net)
+ if (!ns)
ret = uevent_net_broadcast_untagged(env, action_string,
devpath);
- else
+ else {
+ const struct net *net = container_of(ns, struct net, ns);
+
ret = uevent_net_broadcast_tagged(net->uevent_sock->sk, env,
action_string, devpath);
+ }
#endif
return ret;
netdev_put(queue->dev, &queue->dev_tracker);
}
-static const void *rx_queue_namespace(const struct kobject *kobj)
+static const struct ns_common *rx_queue_namespace(const struct kobject *kobj)
{
struct netdev_rx_queue *queue = to_rx_queue(kobj);
struct device *dev = &queue->dev->dev;
- const void *ns = NULL;
if (dev->class && dev->class->namespace)
- ns = dev->class->namespace(dev);
+ return dev->class->namespace(dev);
- return ns;
+ return NULL;
}
static void rx_queue_get_ownership(const struct kobject *kobj,
kuid_t *uid, kgid_t *gid)
{
- const struct net *net = rx_queue_namespace(kobj);
+ const struct ns_common *ns = rx_queue_namespace(kobj);
- net_ns_get_ownership(net, uid, gid);
+ net_ns_get_ownership(ns ? container_of(ns, struct net, ns) : NULL,
+ uid, gid);
}
static const struct kobj_type rx_queue_ktype = {
netdev_put(queue->dev, &queue->dev_tracker);
}
-static const void *netdev_queue_namespace(const struct kobject *kobj)
+static const struct ns_common *netdev_queue_namespace(const struct kobject *kobj)
{
struct netdev_queue *queue = to_netdev_queue(kobj);
struct device *dev = &queue->dev->dev;
- const void *ns = NULL;
if (dev->class && dev->class->namespace)
- ns = dev->class->namespace(dev);
+ return dev->class->namespace(dev);
- return ns;
+ return NULL;
}
static void netdev_queue_get_ownership(const struct kobject *kobj,
kuid_t *uid, kgid_t *gid)
{
- const struct net *net = netdev_queue_namespace(kobj);
+ const struct ns_common *ns = netdev_queue_namespace(kobj);
- net_ns_get_ownership(net, uid, gid);
+ net_ns_get_ownership(ns ? container_of(ns, struct net, ns) : NULL,
+ uid, gid);
}
static const struct kobj_type netdev_queue_ktype = {
return ns_capable(net->user_ns, CAP_SYS_ADMIN);
}
-static void *net_grab_current_ns(void)
+static struct ns_common *net_grab_current_ns(void)
{
- struct net *ns = current->nsproxy->net_ns;
+ struct net *net = current->nsproxy->net_ns;
#ifdef CONFIG_NET_NS
- if (ns)
- refcount_inc(&ns->passive);
+ if (net)
+ refcount_inc(&net->passive);
#endif
- return ns;
+ return net ? to_ns_common(net) : NULL;
}
-static const void *net_initial_ns(void)
+static const struct ns_common *net_initial_ns(void)
{
- return &init_net;
+ return to_ns_common(&init_net);
}
-static const void *net_netlink_ns(struct sock *sk)
+static const struct ns_common *net_netlink_ns(struct sock *sk)
{
- return sock_net(sk);
+ return to_ns_common(sock_net(sk));
}
const struct kobj_ns_type_operations net_ns_type_operations = {
kvfree(dev);
}
-static const void *net_namespace(const struct device *d)
+static const struct ns_common *net_namespace(const struct device *d)
{
const struct net_device *dev = to_net_dev(d);
- return dev_net(dev);
+ return to_ns_common(dev_net(dev));
}
static void net_get_ownership(const struct device *d, kuid_t *uid, kgid_t *gid)
}
int netdev_class_create_file_ns(const struct class_attribute *class_attr,
- const void *ns)
+ const struct ns_common *ns)
{
return class_create_file_ns(&net_class, class_attr, ns);
}
EXPORT_SYMBOL(netdev_class_create_file_ns);
void netdev_class_remove_file_ns(const struct class_attribute *class_attr,
- const void *ns)
+ const struct ns_common *ns)
{
class_remove_file_ns(&net_class, class_attr, ns);
}
}
}
-void net_drop_ns(void *p)
+void net_drop_ns(struct ns_common *ns)
{
- struct net *net = (struct net *)p;
-
- if (net)
- net_passive_dec(net);
+ if (ns)
+ net_passive_dec(to_net_ns(ns));
}
struct net *copy_net_ns(u64 flags,
#include <linux/kobject.h>
#include <linux/sunrpc/addr.h>
#include <linux/sunrpc/xprtsock.h>
+#include <net/net_namespace.h>
#include "sysfs.h"
kfree(xprt);
}
-static const void *rpc_sysfs_client_namespace(const struct kobject *kobj)
+static const struct ns_common *rpc_sysfs_client_namespace(const struct kobject *kobj)
{
- return container_of(kobj, struct rpc_sysfs_client, kobject)->net;
+ return to_ns_common(container_of(kobj, struct rpc_sysfs_client,
+ kobject)->net);
}
-static const void *rpc_sysfs_xprt_switch_namespace(const struct kobject *kobj)
+static const struct ns_common *rpc_sysfs_xprt_switch_namespace(const struct kobject *kobj)
{
- return container_of(kobj, struct rpc_sysfs_xprt_switch, kobject)->net;
+ return to_ns_common(container_of(kobj, struct rpc_sysfs_xprt_switch,
+ kobject)->net);
}
-static const void *rpc_sysfs_xprt_namespace(const struct kobject *kobj)
+static const struct ns_common *rpc_sysfs_xprt_namespace(const struct kobject *kobj)
{
- return container_of(kobj, struct rpc_sysfs_xprt,
- kobject)->xprt->xprt_net;
+ return to_ns_common(container_of(kobj, struct rpc_sysfs_xprt,
+ kobject)->xprt->xprt_net);
}
static struct kobj_attribute rpc_sysfs_clnt_version = __ATTR(rpc_version,
#define WIPHY_PM_OPS NULL
#endif
-static const void *wiphy_namespace(const struct device *d)
+static const struct ns_common *wiphy_namespace(const struct device *d)
{
struct wiphy *wiphy = container_of(d, struct wiphy, dev);
- return wiphy_net(wiphy);
+ return to_ns_common(wiphy_net(wiphy));
}
struct class ieee80211_class = {