Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 489111e5 authored by Johannes Berg's avatar Johannes Berg Committed by David S. Miller
Browse files

genetlink: statically initialize families



Instead of providing macros/inline functions to initialize
the families, make all users initialize them statically and
get rid of the macros.

This reduces the kernel code size by about 1.6k on x86-64
(with allyesconfig).

Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a07ea4d9
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -83,6 +83,7 @@ static const struct genl_multicast_group acpi_event_mcgrps[] = {
};

static struct genl_family acpi_event_genl_family = {
	.module = THIS_MODULE,
	.name = ACPI_GENL_FAMILY_NAME,
	.version = ACPI_GENL_VERSION,
	.maxattr = ACPI_GENL_ATTR_MAX,
+13 −8
Original line number Diff line number Diff line
@@ -1094,13 +1094,7 @@ static int gtp_genl_del_pdp(struct sk_buff *skb, struct genl_info *info)
	return 0;
}

static struct genl_family gtp_genl_family = {
	.name		= "gtp",
	.version	= 0,
	.hdrsize	= 0,
	.maxattr	= GTPA_MAX,
	.netnsok	= true,
};
static struct genl_family gtp_genl_family;

static int gtp_genl_fill_info(struct sk_buff *skb, u32 snd_portid, u32 snd_seq,
			      u32 type, struct pdp_ctx *pctx)
@@ -1296,6 +1290,17 @@ static const struct genl_ops gtp_genl_ops[] = {
	},
};

static struct genl_family gtp_genl_family = {
	.name		= "gtp",
	.version	= 0,
	.hdrsize	= 0,
	.maxattr	= GTPA_MAX,
	.netnsok	= true,
	.module		= THIS_MODULE,
	.ops		= gtp_genl_ops,
	.n_ops		= ARRAY_SIZE(gtp_genl_ops),
};

static int __net_init gtp_net_init(struct net *net)
{
	struct gtp_net *gn = net_generic(net, gtp_net_id);
@@ -1335,7 +1340,7 @@ static int __init gtp_init(void)
	if (err < 0)
		goto error_out;

	err = genl_register_family_with_ops(&gtp_genl_family, gtp_genl_ops);
	err = genl_register_family(&gtp_genl_family);
	if (err < 0)
		goto unreg_rtnl_link;

+13 −8
Original line number Diff line number Diff line
@@ -1421,13 +1421,7 @@ static void clear_tx_sa(struct macsec_tx_sa *tx_sa)
	macsec_txsa_put(tx_sa);
}

static struct genl_family macsec_fam = {
	.name		= MACSEC_GENL_NAME,
	.hdrsize	= 0,
	.version	= MACSEC_GENL_VERSION,
	.maxattr	= MACSEC_ATTR_MAX,
	.netnsok	= true,
};
static struct genl_family macsec_fam;

static struct net_device *get_dev_from_nl(struct net *net,
					  struct nlattr **attrs)
@@ -2654,6 +2648,17 @@ static const struct genl_ops macsec_genl_ops[] = {
	},
};

static struct genl_family macsec_fam = {
	.name		= MACSEC_GENL_NAME,
	.hdrsize	= 0,
	.version	= MACSEC_GENL_VERSION,
	.maxattr	= MACSEC_ATTR_MAX,
	.netnsok	= true,
	.module		= THIS_MODULE,
	.ops		= macsec_genl_ops,
	.n_ops		= ARRAY_SIZE(macsec_genl_ops),
};

static netdev_tx_t macsec_start_xmit(struct sk_buff *skb,
				     struct net_device *dev)
{
@@ -3461,7 +3466,7 @@ static int __init macsec_init(void)
	if (err)
		goto notifier;

	err = genl_register_family_with_ops(&macsec_fam, macsec_genl_ops);
	err = genl_register_family(&macsec_fam);
	if (err)
		goto rtnl;

+14 −8
Original line number Diff line number Diff line
@@ -2150,12 +2150,7 @@ static struct rtnl_link_ops team_link_ops __read_mostly = {
 * Generic netlink custom interface
 ***********************************/

static struct genl_family team_nl_family = {
	.name		= TEAM_GENL_NAME,
	.version	= TEAM_GENL_VERSION,
	.maxattr	= TEAM_ATTR_MAX,
	.netnsok	= true,
};
static struct genl_family team_nl_family;

static const struct nla_policy team_nl_policy[TEAM_ATTR_MAX + 1] = {
	[TEAM_ATTR_UNSPEC]			= { .type = NLA_UNSPEC, },
@@ -2745,6 +2740,18 @@ static const struct genl_multicast_group team_nl_mcgrps[] = {
	{ .name = TEAM_GENL_CHANGE_EVENT_MC_GRP_NAME, },
};

static struct genl_family team_nl_family = {
	.name		= TEAM_GENL_NAME,
	.version	= TEAM_GENL_VERSION,
	.maxattr	= TEAM_ATTR_MAX,
	.netnsok	= true,
	.module		= THIS_MODULE,
	.ops		= team_nl_ops,
	.n_ops		= ARRAY_SIZE(team_nl_ops),
	.mcgrps		= team_nl_mcgrps,
	.n_mcgrps	= ARRAY_SIZE(team_nl_mcgrps),
};

static int team_nl_send_multicast(struct sk_buff *skb,
				  struct team *team, u32 portid)
{
@@ -2768,8 +2775,7 @@ static int team_nl_send_event_port_get(struct team *team,

static int team_nl_init(void)
{
	return genl_register_family_with_ops_groups(&team_nl_family, team_nl_ops,
						    team_nl_mcgrps);
	return genl_register_family(&team_nl_family);
}

static void team_nl_fini(void)
+15 −11
Original line number Diff line number Diff line
@@ -587,14 +587,8 @@ struct hwsim_radiotap_ack_hdr {
	__le16 rt_chbitmask;
} __packed;

/* MAC80211_HWSIM netlinf family */
static struct genl_family hwsim_genl_family = {
	.hdrsize = 0,
	.name = "MAC80211_HWSIM",
	.version = 1,
	.maxattr = HWSIM_ATTR_MAX,
	.netnsok = true,
};
/* MAC80211_HWSIM netlink family */
static struct genl_family hwsim_genl_family;

enum hwsim_multicast_groups {
	HWSIM_MCGRP_CONFIG,
@@ -3234,6 +3228,18 @@ static const struct genl_ops hwsim_ops[] = {
	},
};

static struct genl_family hwsim_genl_family = {
	.name = "MAC80211_HWSIM",
	.version = 1,
	.maxattr = HWSIM_ATTR_MAX,
	.netnsok = true,
	.module = THIS_MODULE,
	.ops = hwsim_ops,
	.n_ops = ARRAY_SIZE(hwsim_ops),
	.mcgrps = hwsim_mcgrps,
	.n_mcgrps = ARRAY_SIZE(hwsim_mcgrps),
};

static void destroy_radio(struct work_struct *work)
{
	struct mac80211_hwsim_data *data =
@@ -3287,9 +3293,7 @@ static int hwsim_init_netlink(void)

	printk(KERN_INFO "mac80211_hwsim: initializing netlink\n");

	rc = genl_register_family_with_ops_groups(&hwsim_genl_family,
						  hwsim_ops,
						  hwsim_mcgrps);
	rc = genl_register_family(&hwsim_genl_family);
	if (rc)
		goto failure;

Loading