Skip to content

Commit 68eb550

Browse files
jmberg-inteldavem330
authored andcommitted
genetlink: pass family to functions using groups
This doesn't really change anything, but prepares for the next patch that will change the APIs to pass the group ID within the family, rather than the global group ID. Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 62b68e9 commit 68eb550

18 files changed

Lines changed: 133 additions & 87 deletions

File tree

‎drivers/acpi/event.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ int acpi_bus_generate_netlink_event(const char *device_class,
146146
return result;
147147
}
148148

149-
genlmsg_multicast(skb, 0, acpi_event_mcgrp.id, GFP_ATOMIC);
149+
genlmsg_multicast(&acpi_event_genl_family,
150+
skb, 0, acpi_event_mcgrp.id, GFP_ATOMIC);
150151
return 0;
151152
}
152153

‎drivers/net/team/team.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2677,8 +2677,9 @@ static struct genl_multicast_group team_change_event_mcgrp = {
26772677
static int team_nl_send_multicast(struct sk_buff *skb,
26782678
struct team *team, u32 portid)
26792679
{
2680-
return genlmsg_multicast_netns(dev_net(team->dev), skb, 0,
2681-
team_change_event_mcgrp.id, GFP_KERNEL);
2680+
return genlmsg_multicast_netns(&team_nl_family, dev_net(team->dev),
2681+
skb, 0, team_change_event_mcgrp.id,
2682+
GFP_KERNEL);
26822683
}
26832684

26842685
static int team_nl_send_event_options_get(struct team *team,

‎drivers/scsi/pmcraid.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1512,7 +1512,8 @@ static int pmcraid_notify_aen(
15121512
}
15131513

15141514
result =
1515-
genlmsg_multicast(skb, 0, pmcraid_event_family.id, GFP_ATOMIC);
1515+
genlmsg_multicast(&pmcraid_event_family, skb, 0,
1516+
pmcraid_event_family.id, GFP_ATOMIC);
15161517

15171518
/* If there are no listeners, genlmsg_multicast may return non-zero
15181519
* value.

‎drivers/thermal/thermal_core.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1675,7 +1675,8 @@ int thermal_generate_netlink_event(struct thermal_zone_device *tz,
16751675
return result;
16761676
}
16771677

1678-
result = genlmsg_multicast(skb, 0, thermal_event_mcgrp.id, GFP_ATOMIC);
1678+
result = genlmsg_multicast(&thermal_event_genl_family, skb, 0,
1679+
thermal_event_mcgrp.id, GFP_ATOMIC);
16791680
if (result)
16801681
dev_err(&tz->device, "Failed to send netlink event:%d", result);
16811682

‎fs/quota/netlink.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ void quota_send_warning(struct kqid qid, dev_t dev,
8888
goto attr_err_out;
8989
genlmsg_end(skb, msg_head);
9090

91-
genlmsg_multicast(skb, 0, quota_mcgrp.id, GFP_NOFS);
91+
genlmsg_multicast(&quota_genl_family, skb, 0, quota_mcgrp.id, GFP_NOFS);
9292
return;
9393
attr_err_out:
9494
printk(KERN_ERR "VFS: Not enough space to compose quota message!\n");

‎include/linux/genl_magic_func.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,8 @@ static int CONCAT_(GENL_MAGIC_FAMILY, _genl_multicast_ ## group)( \
286286
CONCAT_(GENL_MAGIC_FAMILY, _mcg_ ## group).id; \
287287
if (!group_id) \
288288
return -EINVAL; \
289-
return genlmsg_multicast(skb, 0, group_id, flags); \
289+
return genlmsg_multicast(&ZZZ_genl_family, skb, 0, \
290+
group_id, flags); \
290291
}
291292

292293
#include GENL_MAGIC_INCLUDE_FILE

‎include/net/genetlink.h‎

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,8 @@ static inline int _genl_register_family_with_ops(struct genl_family *family,
166166
int genl_unregister_family(struct genl_family *family);
167167
int genl_register_mc_group(struct genl_family *family,
168168
struct genl_multicast_group *grp);
169-
void genl_notify(struct sk_buff *skb, struct net *net, u32 portid,
169+
void genl_notify(struct genl_family *family,
170+
struct sk_buff *skb, struct net *net, u32 portid,
170171
u32 group, struct nlmsghdr *nlh, gfp_t flags);
171172

172173
void *genlmsg_put(struct sk_buff *skb, u32 portid, u32 seq,
@@ -246,41 +247,48 @@ static inline void genlmsg_cancel(struct sk_buff *skb, void *hdr)
246247

247248
/**
248249
* genlmsg_multicast_netns - multicast a netlink message to a specific netns
250+
* @family: the generic netlink family
249251
* @net: the net namespace
250252
* @skb: netlink message as socket buffer
251253
* @portid: own netlink portid to avoid sending to yourself
252254
* @group: multicast group id
253255
* @flags: allocation flags
254256
*/
255-
static inline int genlmsg_multicast_netns(struct net *net, struct sk_buff *skb,
257+
static inline int genlmsg_multicast_netns(struct genl_family *family,
258+
struct net *net, struct sk_buff *skb,
256259
u32 portid, unsigned int group, gfp_t flags)
257260
{
258261
return nlmsg_multicast(net->genl_sock, skb, portid, group, flags);
259262
}
260263

261264
/**
262265
* genlmsg_multicast - multicast a netlink message to the default netns
266+
* @family: the generic netlink family
263267
* @skb: netlink message as socket buffer
264268
* @portid: own netlink portid to avoid sending to yourself
265269
* @group: multicast group id
266270
* @flags: allocation flags
267271
*/
268-
static inline int genlmsg_multicast(struct sk_buff *skb, u32 portid,
272+
static inline int genlmsg_multicast(struct genl_family *family,
273+
struct sk_buff *skb, u32 portid,
269274
unsigned int group, gfp_t flags)
270275
{
271-
return genlmsg_multicast_netns(&init_net, skb, portid, group, flags);
276+
return genlmsg_multicast_netns(family, &init_net, skb,
277+
portid, group, flags);
272278
}
273279

274280
/**
275281
* genlmsg_multicast_allns - multicast a netlink message to all net namespaces
282+
* @family: the generic netlink family
276283
* @skb: netlink message as socket buffer
277284
* @portid: own netlink portid to avoid sending to yourself
278285
* @group: multicast group id
279286
* @flags: allocation flags
280287
*
281288
* This function must hold the RTNL or rcu_read_lock().
282289
*/
283-
int genlmsg_multicast_allns(struct sk_buff *skb, u32 portid,
290+
int genlmsg_multicast_allns(struct genl_family *family,
291+
struct sk_buff *skb, u32 portid,
284292
unsigned int group, gfp_t flags);
285293

286294
/**
@@ -353,6 +361,7 @@ static inline struct sk_buff *genlmsg_new(size_t payload, gfp_t flags)
353361

354362
/**
355363
* genl_set_err - report error to genetlink broadcast listeners
364+
* @family: the generic netlink family
356365
* @net: the network namespace to report the error to
357366
* @portid: the PORTID of a process that we want to skip (if any)
358367
* @group: the broadcast group that will notice the error
@@ -361,7 +370,8 @@ static inline struct sk_buff *genlmsg_new(size_t payload, gfp_t flags)
361370
* This function returns the number of broadcast listeners that have set the
362371
* NETLINK_RECV_NO_ENOBUFS socket option.
363372
*/
364-
static inline int genl_set_err(struct net *net, u32 portid, u32 group, int code)
373+
static inline int genl_set_err(struct genl_family *family, struct net *net,
374+
u32 portid, u32 group, int code)
365375
{
366376
return netlink_set_err(net->genl_sock, portid, group, code);
367377
}

‎net/core/drop_monitor.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@ static void send_dm_alert(struct work_struct *work)
120120
skb = reset_per_cpu_data(data);
121121

122122
if (skb)
123-
genlmsg_multicast(skb, 0, dm_mcgrp.id, GFP_KERNEL);
123+
genlmsg_multicast(&net_drop_monitor_family, skb, 0,
124+
dm_mcgrp.id, GFP_KERNEL);
124125
}
125126

126127
/*

‎net/hsr/hsr_netlink.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ void hsr_nl_ringerror(struct hsr_priv *hsr_priv, unsigned char addr[ETH_ALEN],
129129
goto nla_put_failure;
130130

131131
genlmsg_end(skb, msg_head);
132-
genlmsg_multicast(skb, 0, hsr_network_genl_mcgrp.id, GFP_ATOMIC);
132+
genlmsg_multicast(&hsr_genl_family, skb, 0,
133+
hsr_network_genl_mcgrp.id, GFP_ATOMIC);
133134

134135
return;
135136

@@ -163,7 +164,8 @@ void hsr_nl_nodedown(struct hsr_priv *hsr_priv, unsigned char addr[ETH_ALEN])
163164
goto nla_put_failure;
164165

165166
genlmsg_end(skb, msg_head);
166-
genlmsg_multicast(skb, 0, hsr_network_genl_mcgrp.id, GFP_ATOMIC);
167+
genlmsg_multicast(&hsr_genl_family, skb, 0,
168+
hsr_network_genl_mcgrp.id, GFP_ATOMIC);
167169

168170
return;
169171

‎net/ieee802154/netlink.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ int ieee802154_nl_mcast(struct sk_buff *msg, unsigned int group)
7070
if (genlmsg_end(msg, hdr) < 0)
7171
goto out;
7272

73-
return genlmsg_multicast(msg, 0, group, GFP_ATOMIC);
73+
return genlmsg_multicast(&nl802154_family, msg, 0, group, GFP_ATOMIC);
7474
out:
7575
nlmsg_free(msg);
7676
return -ENOBUFS;

0 commit comments

Comments
 (0)