Skip to content

Commit

Permalink
kobject_uevent: remove unneeded netlink_ns check
Browse files Browse the repository at this point in the history
Back when I rewrote large chunks of uevent sending I should have removed
the .netlink_ns method completely after having removed it's last user in
[1]. Let's remove it now and also remove the helper associated with it
that is unused too.

Fixes: a349843 ("netns: restrict uevents") /* No backport needed. */
Cc: Greg Kroah-Hartman <[email protected]>
Cc: "David S. Miller" <[email protected]>
Signed-off-by: Christian Brauner <[email protected]>
---
/* v2 */
unchanged
  • Loading branch information
Christian Brauner committed Apr 22, 2020
1 parent ae83d0b commit 7f67039
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 24 deletions.
1 change: 0 additions & 1 deletion Documentation/filesystems/sysfs-tagging.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,5 @@ Users of this interface:
- define a type in the kobj_ns_type enumeration.
- call kobj_ns_type_register() with its kobj_ns_type_operations which has
- current_ns() which returns current's namespace
- netlink_ns() which returns a socket's namespace
- initial_ns() which returns the initial namesapce
- call kobj_ns_exit() when an individual tag is no longer valid
3 changes: 0 additions & 3 deletions include/linux/kobject_ns.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,13 @@ enum kobj_ns_type {
/*
* Callbacks so sysfs can determine namespaces
* @grab_current_ns: return a new reference to calling task's namespace
* @netlink_ns: return namespace to which a sock belongs (right?)
* @initial_ns: return the initial namespace (i.e. init_net_ns)
* @drop_ns: drops a reference to namespace
*/
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 *);
};
Expand All @@ -52,7 +50,6 @@ const struct kobj_ns_type_operations *kobj_ns_ops(struct kobject *kobj);

bool kobj_ns_current_may_mount(enum kobj_ns_type type);
void *kobj_ns_grab_current(enum kobj_ns_type type);
const void *kobj_ns_netlink(enum kobj_ns_type type, struct sock *sk);
const void *kobj_ns_initial(enum kobj_ns_type type);
void kobj_ns_drop(enum kobj_ns_type type, void *ns);

Expand Down
13 changes: 0 additions & 13 deletions lib/kobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -1092,19 +1092,6 @@ void *kobj_ns_grab_current(enum kobj_ns_type type)
}
EXPORT_SYMBOL_GPL(kobj_ns_grab_current);

const void *kobj_ns_netlink(enum kobj_ns_type type, struct sock *sk)
{
const void *ns = NULL;

spin_lock(&kobj_ns_type_lock);
if ((type > KOBJ_NS_TYPE_NONE) && (type < KOBJ_NS_TYPES) &&
kobj_ns_ops_tbl[type])
ns = kobj_ns_ops_tbl[type]->netlink_ns(sk);
spin_unlock(&kobj_ns_type_lock);

return ns;
}

const void *kobj_ns_initial(enum kobj_ns_type type)
{
const void *ns = NULL;
Expand Down
2 changes: 1 addition & 1 deletion lib/kobject_uevent.c
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ static int kobject_uevent_net_broadcast(struct kobject *kobj,
* are the only tag relevant here since we want to decide which
* network namespaces to broadcast the uevent into.
*/
if (ops && ops->netlink_ns && kobj->ktype->namespace)
if (ops && kobj->ktype->namespace)
if (ops->type == KOBJ_NS_TYPE_NET)
net = kobj->ktype->namespace(kobj);

Expand Down
6 changes: 0 additions & 6 deletions net/core/net-sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1694,16 +1694,10 @@ static const void *net_initial_ns(void)
return &init_net;
}

static const void *net_netlink_ns(struct sock *sk)
{
return sock_net(sk);
}

const struct kobj_ns_type_operations net_ns_type_operations = {
.type = KOBJ_NS_TYPE_NET,
.current_may_mount = net_current_may_mount,
.grab_current_ns = net_grab_current_ns,
.netlink_ns = net_netlink_ns,
.initial_ns = net_initial_ns,
.drop_ns = net_drop_ns,
};
Expand Down

0 comments on commit 7f67039

Please sign in to comment.