From e5dcecba015f9774a402ba559b80b16999747e3b Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Tue, 19 Nov 2013 15:19:32 +0100 Subject: drop_monitor/genetlink: use proper genetlink multicast APIs The drop monitor code is abusing the genetlink API and is statically using the generic netlink multicast group 1, even if that group belongs to somebody else (which it invariably will, since it's not reserved.) Make the drop monitor code use the proper APIs to reserve a group ID, but also reserve the group id 1 in generic netlink code to preserve the userspace API. Since drop monitor can be a module, don't clear the bit for it on unregistration. Acked-by: Neil Horman Signed-off-by: Johannes Berg Signed-off-by: David S. Miller --- net/core/drop_monitor.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'net/core') diff --git a/net/core/drop_monitor.c b/net/core/drop_monitor.c index 0efc5028ba9d..46ee488c0015 100644 --- a/net/core/drop_monitor.c +++ b/net/core/drop_monitor.c @@ -106,6 +106,10 @@ static struct sk_buff *reset_per_cpu_data(struct per_cpu_dm_data *data) return skb; } +static struct genl_multicast_group dm_mcgrp = { + .name = "events", +}; + static void send_dm_alert(struct work_struct *work) { struct sk_buff *skb; @@ -116,7 +120,7 @@ static void send_dm_alert(struct work_struct *work) skb = reset_per_cpu_data(data); if (skb) - genlmsg_multicast(skb, 0, NET_DM_GRP_ALERT, GFP_KERNEL); + genlmsg_multicast(skb, 0, dm_mcgrp.id, GFP_KERNEL); } /* @@ -371,6 +375,13 @@ static int __init init_net_drop_monitor(void) return rc; } + rc = genl_register_mc_group(&net_drop_monitor_family, &dm_mcgrp); + if (rc) { + pr_err("Failed to register drop monitor mcast group\n"); + goto out_unreg; + } + WARN_ON(dm_mcgrp.id != NET_DM_GRP_ALERT); + rc = register_netdevice_notifier(&dropmon_net_notifier); if (rc < 0) { pr_crit("Failed to register netdevice notifier\n"); -- cgit v1.2.3