Commit 56989f6d authored by Johannes Berg's avatar Johannes Berg Committed by David S. Miller
Browse files

genetlink: mark families as __ro_after_init



Now genl_register_family() is the only thing (other than the
users themselves, perhaps, but I didn't find any doing that)
writing to the family struct.

In all families that I found, genl_register_family() is only
called from __init functions (some indirectly, in which case
I've add __init annotations to clarifly things), so all can
actually be marked __ro_after_init.

This protects the data structure from accidental corruption.
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 2ae0f17d
......@@ -82,7 +82,7 @@ static const struct genl_multicast_group acpi_event_mcgrps[] = {
{ .name = ACPI_GENL_MCAST_GROUP_NAME, },
};
static struct genl_family acpi_event_genl_family = {
static struct genl_family acpi_event_genl_family __ro_after_init = {
.module = THIS_MODULE,
.name = ACPI_GENL_FAMILY_NAME,
.version = ACPI_GENL_VERSION,
......@@ -144,7 +144,7 @@ int acpi_bus_generate_netlink_event(const char *device_class,
EXPORT_SYMBOL(acpi_bus_generate_netlink_event);
static int acpi_event_genetlink_init(void)
static int __init acpi_event_genetlink_init(void)
{
return genl_register_family(&acpi_event_genl_family);
}
......
......@@ -1290,7 +1290,7 @@ static const struct genl_ops gtp_genl_ops[] = {
},
};
static struct genl_family gtp_genl_family = {
static struct genl_family gtp_genl_family __ro_after_init = {
.name = "gtp",
.version = 0,
.hdrsize = 0,
......
......@@ -2648,7 +2648,7 @@ static const struct genl_ops macsec_genl_ops[] = {
},
};
static struct genl_family macsec_fam = {
static struct genl_family macsec_fam __ro_after_init = {
.name = MACSEC_GENL_NAME,
.hdrsize = 0,
.version = MACSEC_GENL_VERSION,
......
......@@ -2740,7 +2740,7 @@ static const struct genl_multicast_group team_nl_mcgrps[] = {
{ .name = TEAM_GENL_CHANGE_EVENT_MC_GRP_NAME, },
};
static struct genl_family team_nl_family = {
static struct genl_family team_nl_family __ro_after_init = {
.name = TEAM_GENL_NAME,
.version = TEAM_GENL_VERSION,
.maxattr = TEAM_ATTR_MAX,
......@@ -2773,7 +2773,7 @@ static int team_nl_send_event_port_get(struct team *team,
port);
}
static int team_nl_init(void)
static int __init team_nl_init(void)
{
return genl_register_family(&team_nl_family);
}
......
......@@ -3228,7 +3228,7 @@ static const struct genl_ops hwsim_ops[] = {
},
};
static struct genl_family hwsim_genl_family = {
static struct genl_family hwsim_genl_family __ro_after_init = {
.name = "MAC80211_HWSIM",
.version = 1,
.maxattr = HWSIM_ATTR_MAX,
......@@ -3287,7 +3287,7 @@ static struct notifier_block hwsim_netlink_notifier = {
.notifier_call = mac80211_hwsim_netlink_notify,
};
static int hwsim_init_netlink(void)
static int __init hwsim_init_netlink(void)
{
int rc;
......
......@@ -1368,7 +1368,7 @@ static struct genl_multicast_group pmcraid_mcgrps[] = {
{ .name = "events", /* not really used - see ID discussion below */ },
};
static struct genl_family pmcraid_event_family = {
static struct genl_family pmcraid_event_family __ro_after_init = {
.module = THIS_MODULE,
.name = "pmcraid",
.version = 1,
......@@ -1384,7 +1384,7 @@ static struct genl_family pmcraid_event_family = {
* 0 if the pmcraid_event_family is successfully registered
* with netlink generic, non-zero otherwise
*/
static int pmcraid_netlink_init(void)
static int __init pmcraid_netlink_init(void)
{
int result;
......
......@@ -147,7 +147,7 @@ static const struct genl_multicast_group tcmu_mcgrps[] = {
};
/* Our generic netlink family */
static struct genl_family tcmu_genl_family = {
static struct genl_family tcmu_genl_family __ro_after_init = {
.module = THIS_MODULE,
.hdrsize = 0,
.name = "TCM-USER",
......
......@@ -2163,7 +2163,7 @@ static const struct genl_multicast_group thermal_event_mcgrps[] = {
{ .name = THERMAL_GENL_MCAST_GROUP_NAME, },
};
static struct genl_family thermal_event_genl_family = {
static struct genl_family thermal_event_genl_family __ro_after_init = {
.module = THIS_MODULE,
.name = THERMAL_GENL_FAMILY_NAME,
.version = THERMAL_GENL_VERSION,
......@@ -2235,7 +2235,7 @@ int thermal_generate_netlink_event(struct thermal_zone_device *tz,
}
EXPORT_SYMBOL_GPL(thermal_generate_netlink_event);
static int genetlink_init(void)
static int __init genetlink_init(void)
{
return genl_register_family(&thermal_event_genl_family);
}
......
......@@ -72,7 +72,7 @@ static struct genl_ops dlm_nl_ops[] = {
},
};
static struct genl_family family = {
static struct genl_family family __ro_after_init = {
.name = DLM_GENL_NAME,
.version = DLM_GENL_VERSION,
.ops = dlm_nl_ops,
......
......@@ -12,7 +12,7 @@ static const struct genl_multicast_group quota_mcgrps[] = {
};
/* Netlink family structure for quota */
static struct genl_family quota_genl_family = {
static struct genl_family quota_genl_family __ro_after_init = {
.module = THIS_MODULE,
.hdrsize = 0,
.name = "VFS_DQUOT",
......
......@@ -293,7 +293,7 @@ static int CONCAT_(GENL_MAGIC_FAMILY, _genl_multicast_ ## group)( \
#undef GENL_mc_group
#define GENL_mc_group(group)
static struct genl_family ZZZ_genl_family __read_mostly = {
static struct genl_family ZZZ_genl_family __ro_after_init = {
.name = __stringify(GENL_MAGIC_FAMILY),
.version = GENL_MAGIC_VERSION,
#ifdef GENL_MAGIC_FAMILY_HDRSZ
......
......@@ -646,7 +646,7 @@ static const struct genl_ops taskstats_ops[] = {
},
};
static struct genl_family family = {
static struct genl_family family __ro_after_init = {
.name = TASKSTATS_GENL_NAME,
.version = TASKSTATS_GENL_VERSION,
.maxattr = TASKSTATS_CMD_ATTR_MAX,
......
......@@ -603,7 +603,7 @@ static struct genl_ops batadv_netlink_ops[] = {
};
struct genl_family batadv_netlink_family = {
struct genl_family batadv_netlink_family __ro_after_init = {
.hdrsize = 0,
.name = BATADV_NL_NAME,
.version = 1,
......
......@@ -1612,7 +1612,7 @@ static const struct genl_ops devlink_nl_ops[] = {
},
};
static struct genl_family devlink_nl_family = {
static struct genl_family devlink_nl_family __ro_after_init = {
.name = DEVLINK_GENL_NAME,
.version = DEVLINK_GENL_VERSION,
.maxattr = DEVLINK_ATTR_MAX,
......
......@@ -346,7 +346,7 @@ static const struct genl_ops dropmon_ops[] = {
},
};
static struct genl_family net_drop_monitor_family = {
static struct genl_family net_drop_monitor_family __ro_after_init = {
.hdrsize = 0,
.name = "NET_DM",
.version = 2,
......
......@@ -461,7 +461,7 @@ static const struct genl_ops hsr_ops[] = {
},
};
static struct genl_family hsr_genl_family = {
static struct genl_family hsr_genl_family __ro_after_init = {
.hdrsize = 0,
.name = "HSR",
.version = 1,
......
......@@ -131,7 +131,7 @@ static const struct genl_multicast_group ieee802154_mcgrps[] = {
[IEEE802154_BEACON_MCGRP] = { .name = IEEE802154_MCAST_BEACON_NAME, },
};
struct genl_family nl802154_family = {
struct genl_family nl802154_family __ro_after_init = {
.hdrsize = 0,
.name = IEEE802154_NL_NAME,
.version = 1,
......
......@@ -2462,7 +2462,7 @@ static const struct genl_ops nl802154_ops[] = {
#endif /* CONFIG_IEEE802154_NL802154_EXPERIMENTAL */
};
static struct genl_family nl802154_fam = {
static struct genl_family nl802154_fam __ro_after_init = {
.name = NL802154_GENL_NAME, /* have users key off the name instead */
.hdrsize = 0, /* no private header */
.version = 1, /* no particular meaning now */
......@@ -2478,7 +2478,7 @@ static struct genl_family nl802154_fam = {
};
/* initialisation/exit functions */
int nl802154_init(void)
int __init nl802154_init(void)
{
return genl_register_family(&nl802154_fam);
}
......
......@@ -824,7 +824,7 @@ static const struct genl_ops fou_nl_ops[] = {
},
};
static struct genl_family fou_nl_family = {
static struct genl_family fou_nl_family __ro_after_init = {
.hdrsize = 0,
.name = FOU_GENL_NAME,
.version = FOU_GENL_VERSION,
......
......@@ -1109,7 +1109,7 @@ static const struct genl_ops tcp_metrics_nl_ops[] = {
},
};
static struct genl_family tcp_metrics_nl_family = {
static struct genl_family tcp_metrics_nl_family __ro_after_init = {
.hdrsize = 0,
.name = TCP_METRICS_GENL_NAME,
.version = TCP_METRICS_GENL_VERSION,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment