Merge branch 'for-thermal-genetlink-family-bind-unbind-callbacks'
Stanislaw Gruszka says: ==================== thermal/netlink/intel_hfi: Enable HFI feature only when required The patchset introduces a new genetlink family bind/unbind callbacks and thermal/netlink notifications, which allow drivers to send netlink multicast events based on the presence of actual user-space consumers. This functionality optimizes resource usage by allowing disabling of features when not needed. v1: https://lore.kernel.org/linux-pm/20240131120535.933424-1-stanislaw.gruszka@linux.intel.com// v2: https://lore.kernel.org/linux-pm/20240206133605.1518373-1-stanislaw.gruszka@linux.intel.com/ v3: https://lore.kernel.org/linux-pm/20240209120625.1775017-1-stanislaw.gruszka@linux.intel.com/ ==================== Link: https://lore.kernel.org/r/20240212161615.161935-1-stanislaw.gruszka@linux.intel.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
commit
fc906e7922
@ -41,6 +41,8 @@ struct genl_info;
|
||||
* do additional, common, filtering and return an error
|
||||
* @post_doit: called after an operation's doit callback, it may
|
||||
* undo operations done by pre_doit, for example release locks
|
||||
* @bind: called when family multicast group is added to a netlink socket
|
||||
* @unbind: called when family multicast group is removed from a netlink socket
|
||||
* @module: pointer to the owning module (set to THIS_MODULE)
|
||||
* @mcgrps: multicast groups used by this family
|
||||
* @n_mcgrps: number of multicast groups
|
||||
@ -84,6 +86,8 @@ struct genl_family {
|
||||
void (*post_doit)(const struct genl_split_ops *ops,
|
||||
struct sk_buff *skb,
|
||||
struct genl_info *info);
|
||||
int (*bind)(int mcgrp);
|
||||
void (*unbind)(int mcgrp);
|
||||
const struct genl_ops * ops;
|
||||
const struct genl_small_ops *small_ops;
|
||||
const struct genl_split_ops *split_ops;
|
||||
|
@ -1836,6 +1836,9 @@ static int genl_bind(struct net *net, int group)
|
||||
!ns_capable(net->user_ns, CAP_SYS_ADMIN))
|
||||
ret = -EPERM;
|
||||
|
||||
if (family->bind)
|
||||
family->bind(i);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1843,12 +1846,39 @@ static int genl_bind(struct net *net, int group)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void genl_unbind(struct net *net, int group)
|
||||
{
|
||||
const struct genl_family *family;
|
||||
unsigned int id;
|
||||
|
||||
down_read(&cb_lock);
|
||||
|
||||
idr_for_each_entry(&genl_fam_idr, family, id) {
|
||||
int i;
|
||||
|
||||
if (family->n_mcgrps == 0)
|
||||
continue;
|
||||
|
||||
i = group - family->mcgrp_offset;
|
||||
if (i < 0 || i >= family->n_mcgrps)
|
||||
continue;
|
||||
|
||||
if (family->unbind)
|
||||
family->unbind(i);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
up_read(&cb_lock);
|
||||
}
|
||||
|
||||
static int __net_init genl_pernet_init(struct net *net)
|
||||
{
|
||||
struct netlink_kernel_cfg cfg = {
|
||||
.input = genl_rcv,
|
||||
.flags = NL_CFG_F_NONROOT_RECV,
|
||||
.bind = genl_bind,
|
||||
.unbind = genl_unbind,
|
||||
.release = genl_release,
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user