Skip to content

Commit

Permalink
genetlink: remove family pointer from genl_multicast_group
Browse files Browse the repository at this point in the history
There's no reason to have the family pointer there since it
can just be passed internally where needed, so remove it.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Johannes Berg authored and David S. Miller committed Nov 19, 2013
1 parent 06fb555 commit c2ebb90
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 22 deletions.
2 changes: 0 additions & 2 deletions include/net/genetlink.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@
* @id: multicast group ID, assigned by the core, to use with
* genlmsg_multicast().
* @list: list entry for linking
* @family: pointer to family, need not be set before registering
*/
struct genl_multicast_group {
struct genl_family *family; /* private */
struct list_head list; /* private */
char name[GENL_NAMSIZ];
u32 id;
Expand Down
38 changes: 18 additions & 20 deletions net/netlink/genetlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ static unsigned long mc_group_start = 0x3 | BIT(GENL_ID_VFS_DQUOT);
static unsigned long *mc_groups = &mc_group_start;
static unsigned long mc_groups_longs = 1;

static int genl_ctrl_event(int event, void *data);
static int genl_ctrl_event(int event, struct genl_family *family,
struct genl_multicast_group *grp);

static inline unsigned int genl_family_hash(unsigned int id)
{
Expand Down Expand Up @@ -235,9 +236,8 @@ int genl_register_mc_group(struct genl_family *family,
grp->id = id;
set_bit(id, mc_groups);
list_add_tail(&grp->list, &family->mcast_groups);
grp->family = family;

genl_ctrl_event(CTRL_CMD_NEWMCAST_GRP, grp);
genl_ctrl_event(CTRL_CMD_NEWMCAST_GRP, family, grp);
out:
genl_unlock_all();
return err;
Expand All @@ -248,7 +248,6 @@ static void __genl_unregister_mc_group(struct genl_family *family,
struct genl_multicast_group *grp)
{
struct net *net;
BUG_ON(grp->family != family);

netlink_table_grab();
rcu_read_lock();
Expand All @@ -260,9 +259,8 @@ static void __genl_unregister_mc_group(struct genl_family *family,
if (grp->id != 1)
clear_bit(grp->id, mc_groups);
list_del(&grp->list);
genl_ctrl_event(CTRL_CMD_DELMCAST_GRP, grp);
genl_ctrl_event(CTRL_CMD_DELMCAST_GRP, family, grp);
grp->id = 0;
grp->family = NULL;
}

static void genl_unregister_mc_groups(struct genl_family *family)
Expand Down Expand Up @@ -364,7 +362,7 @@ int __genl_register_family(struct genl_family *family)
list_add_tail(&family->family_list, genl_family_chain(family->id));
genl_unlock_all();

genl_ctrl_event(CTRL_CMD_NEWFAMILY, family);
genl_ctrl_event(CTRL_CMD_NEWFAMILY, family, NULL);

return 0;

Expand Down Expand Up @@ -400,7 +398,7 @@ int genl_unregister_family(struct genl_family *family)
genl_unlock_all();

kfree(family->attrbuf);
genl_ctrl_event(CTRL_CMD_DELFAMILY, family);
genl_ctrl_event(CTRL_CMD_DELFAMILY, family, NULL);
return 0;
}

Expand Down Expand Up @@ -693,7 +691,8 @@ static int ctrl_fill_info(struct genl_family *family, u32 portid, u32 seq,
return -EMSGSIZE;
}

static int ctrl_fill_mcgrp_info(struct genl_multicast_group *grp, u32 portid,
static int ctrl_fill_mcgrp_info(struct genl_family *family,
struct genl_multicast_group *grp, u32 portid,
u32 seq, u32 flags, struct sk_buff *skb,
u8 cmd)
{
Expand All @@ -705,8 +704,8 @@ static int ctrl_fill_mcgrp_info(struct genl_multicast_group *grp, u32 portid,
if (hdr == NULL)
return -1;

if (nla_put_string(skb, CTRL_ATTR_FAMILY_NAME, grp->family->name) ||
nla_put_u16(skb, CTRL_ATTR_FAMILY_ID, grp->family->id))
if (nla_put_string(skb, CTRL_ATTR_FAMILY_NAME, family->name) ||
nla_put_u16(skb, CTRL_ATTR_FAMILY_ID, family->id))
goto nla_put_failure;

nla_grps = nla_nest_start(skb, CTRL_ATTR_MCAST_GROUPS);
Expand Down Expand Up @@ -783,7 +782,8 @@ static struct sk_buff *ctrl_build_family_msg(struct genl_family *family,
return skb;
}

static struct sk_buff *ctrl_build_mcgrp_msg(struct genl_multicast_group *grp,
static struct sk_buff *ctrl_build_mcgrp_msg(struct genl_family *family,
struct genl_multicast_group *grp,
u32 portid, int seq, u8 cmd)
{
struct sk_buff *skb;
Expand All @@ -793,7 +793,7 @@ static struct sk_buff *ctrl_build_mcgrp_msg(struct genl_multicast_group *grp,
if (skb == NULL)
return ERR_PTR(-ENOBUFS);

err = ctrl_fill_mcgrp_info(grp, portid, seq, 0, skb, cmd);
err = ctrl_fill_mcgrp_info(family, grp, portid, seq, 0, skb, cmd);
if (err < 0) {
nlmsg_free(skb);
return ERR_PTR(err);
Expand Down Expand Up @@ -855,11 +855,10 @@ static int ctrl_getfamily(struct sk_buff *skb, struct genl_info *info)
return genlmsg_reply(msg, info);
}

static int genl_ctrl_event(int event, void *data)
static int genl_ctrl_event(int event, struct genl_family *family,
struct genl_multicast_group *grp)
{
struct sk_buff *msg;
struct genl_family *family;
struct genl_multicast_group *grp;

/* genl is still initialising */
if (!init_net.genl_sock)
Expand All @@ -868,14 +867,13 @@ static int genl_ctrl_event(int event, void *data)
switch (event) {
case CTRL_CMD_NEWFAMILY:
case CTRL_CMD_DELFAMILY:
family = data;
WARN_ON(grp);
msg = ctrl_build_family_msg(family, 0, 0, event);
break;
case CTRL_CMD_NEWMCAST_GRP:
case CTRL_CMD_DELMCAST_GRP:
grp = data;
family = grp->family;
msg = ctrl_build_mcgrp_msg(data, 0, 0, event);
BUG_ON(!grp);
msg = ctrl_build_mcgrp_msg(family, grp, 0, 0, event);
break;
default:
return -EINVAL;
Expand Down

0 comments on commit c2ebb90

Please sign in to comment.