genetlink: statically initialize families
authorJohannes Berg <johannes.berg@intel.com>
Mon, 24 Oct 2016 12:40:03 +0000 (14:40 +0200)
committerDavid S. Miller <davem@davemloft.net>
Thu, 27 Oct 2016 20:16:09 +0000 (16:16 -0400)
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: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
37 files changed:
drivers/acpi/event.c
drivers/net/gtp.c
drivers/net/macsec.c
drivers/net/team/team.c
drivers/net/wireless/mac80211_hwsim.c
drivers/scsi/pmcraid.c
drivers/target/target_core_user.c
drivers/thermal/thermal_core.c
fs/dlm/netlink.c
fs/quota/netlink.c
include/linux/drbd_genl.h
include/linux/genl_magic_func.h
include/net/genetlink.h
kernel/taskstats.c
net/batman-adv/netlink.c
net/core/devlink.c
net/core/drop_monitor.c
net/hsr/hsr_netlink.c
net/ieee802154/netlink.c
net/ieee802154/nl802154.c
net/ipv4/fou.c
net/ipv4/tcp_metrics.c
net/ipv6/ila/ila_xlat.c
net/irda/irnetlink.c
net/l2tp/l2tp_netlink.c
net/netfilter/ipvs/ip_vs_ctl.c
net/netlabel/netlabel_calipso.c
net/netlabel/netlabel_cipso_v4.c
net/netlabel/netlabel_mgmt.c
net/netlabel/netlabel_unlabeled.c
net/netlink/genetlink.c
net/nfc/netlink.c
net/openvswitch/datapath.c
net/tipc/netlink.c
net/tipc/netlink_compat.c
net/wimax/stack.c
net/wireless/nl80211.c

index 8dfca3d531313d7a56a38cb99217b0096adb3119..1ab12ad7d5ba76e1fe64bd4dff46cfebd7bcb850 100644 (file)
@@ -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,
index f66737ba129964a19c45aa212400fa043b5a3dea..0604fd78f8261f9e7920c29d4a193073a7be0596 100644 (file)
@@ -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;
 
index a5309b81a78658a8678b50911bd043778d7e77e1..63ca7a3c77cf6e8d45a585f298d31c8e76e41f1a 100644 (file)
@@ -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;
 
index 0b50205764ff24a905aefefd0d45412e45d58ff1..46bf7c1216c029179ec27e289cad046ac4871279 100644 (file)
@@ -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)
index 54b6cd62676e44a99172e6efc67c49ae6e501f88..5d4637e586e8e7b523778d9d3509be77d8676509 100644 (file)
@@ -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;
 
index cc50eb87b28a394ee47c80ff61d41ccaedc4f3b7..c0ab7bb8c3ce094fbc93c754335d7192695b8dad 100644 (file)
@@ -1369,6 +1369,7 @@ static struct genl_multicast_group pmcraid_mcgrps[] = {
 };
 
 static struct genl_family pmcraid_event_family = {
+       .module = THIS_MODULE,
        .name = "pmcraid",
        .version = 1,
        .maxattr = PMCRAID_AEN_ATTR_MAX,
index 313a0ef3cda7dcbb5bf7cb5a027b3e69fbd757f8..3483372f556298a7c19265e61eb65ebb9bd08c17 100644 (file)
@@ -148,6 +148,7 @@ static const struct genl_multicast_group tcmu_mcgrps[] = {
 
 /* Our generic netlink family */
 static struct genl_family tcmu_genl_family = {
+       .module = THIS_MODULE,
        .hdrsize = 0,
        .name = "TCM-USER",
        .version = 1,
index 68d7503f64174beba83a188b69da7978c38f1061..93b6caab2d9f04a3066337ded20bb4545c0bcee0 100644 (file)
@@ -2164,6 +2164,7 @@ static const struct genl_multicast_group thermal_event_mcgrps[] = {
 };
 
 static struct genl_family thermal_event_genl_family = {
+       .module = THIS_MODULE,
        .name = THERMAL_GENL_FAMILY_NAME,
        .version = THERMAL_GENL_VERSION,
        .maxattr = THERMAL_GENL_ATTR_MAX,
index 00d2269562644872344025bd860e656760b572b4..04042d69573c05033ecc4a728f6bdd2591382382 100644 (file)
 static uint32_t dlm_nl_seqnum;
 static uint32_t listener_nlportid;
 
-static struct genl_family family = {
-       .name           = DLM_GENL_NAME,
-       .version        = DLM_GENL_VERSION,
-};
+static struct genl_family family;
 
 static int prepare_data(u8 cmd, struct sk_buff **skbp, size_t size)
 {
@@ -75,9 +72,17 @@ static struct genl_ops dlm_nl_ops[] = {
        },
 };
 
+static struct genl_family family = {
+       .name           = DLM_GENL_NAME,
+       .version        = DLM_GENL_VERSION,
+       .ops            = dlm_nl_ops,
+       .n_ops          = ARRAY_SIZE(dlm_nl_ops),
+       .module         = THIS_MODULE,
+};
+
 int __init dlm_netlink_init(void)
 {
-       return genl_register_family_with_ops(&family, dlm_nl_ops);
+       return genl_register_family(&family);
 }
 
 void dlm_netlink_exit(void)
index 3965a5cdfaa2597d7e6c9f7922228c967ecfe2f3..9457c7b0dfa20254395ffd938d62f0f2da1c9950 100644 (file)
@@ -13,6 +13,7 @@ static const struct genl_multicast_group quota_mcgrps[] = {
 
 /* Netlink family structure for quota */
 static struct genl_family quota_genl_family = {
+       .module = THIS_MODULE,
        .hdrsize = 0,
        .name = "VFS_DQUOT",
        .version = 1,
index c934d3a96b5e7da7fd7966ddcb34682454100206..2896f93808ae3a8ed962cf1958e72ff2e5f8da3a 100644 (file)
@@ -67,7 +67,7 @@
  *     genl_magic_func.h
  *             generates an entry in the static genl_ops array,
  *             and static register/unregister functions to
- *             genl_register_family_with_ops().
+ *             genl_register_family().
  *
  *     flags and handler:
  *             GENL_op_init( .doit = x, .dumpit = y, .flags = something)
index 7c070c1fe4577dcb84c956fcbe3d6f46558994c5..40c2e39362c86a60f423a1622be398bd4dbe34bd 100644 (file)
@@ -259,15 +259,7 @@ static struct genl_ops ZZZ_genl_ops[] __read_mostly = {
  *                                                                     {{{2
  */
 #define ZZZ_genl_family                CONCAT_(GENL_MAGIC_FAMILY, _genl_family)
-static struct genl_family ZZZ_genl_family __read_mostly = {
-       .name = __stringify(GENL_MAGIC_FAMILY),
-       .version = GENL_MAGIC_VERSION,
-#ifdef GENL_MAGIC_FAMILY_HDRSZ
-       .hdrsize = NLA_ALIGN(GENL_MAGIC_FAMILY_HDRSZ),
-#endif
-       .maxattr = ARRAY_SIZE(drbd_tla_nl_policy)-1,
-};
-
+static struct genl_family ZZZ_genl_family;
 /*
  * Magic: define multicast groups
  * Magic: define multicast group registration helper
@@ -301,11 +293,23 @@ 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 = {
+       .name = __stringify(GENL_MAGIC_FAMILY),
+       .version = GENL_MAGIC_VERSION,
+#ifdef GENL_MAGIC_FAMILY_HDRSZ
+       .hdrsize = NLA_ALIGN(GENL_MAGIC_FAMILY_HDRSZ),
+#endif
+       .maxattr = ARRAY_SIZE(drbd_tla_nl_policy)-1,
+       .ops = ZZZ_genl_ops,
+       .n_ops = ARRAY_SIZE(ZZZ_genl_ops),
+       .mcgrps = ZZZ_genl_mcgrps,
+       .n_mcgrps = ARRAY_SIZE(ZZZ_genl_mcgrps),
+       .module = THIS_MODULE,
+};
+
 int CONCAT_(GENL_MAGIC_FAMILY, _genl_register)(void)
 {
-       return genl_register_family_with_ops_groups(&ZZZ_genl_family,   \
-                                                   ZZZ_genl_ops,       \
-                                                   ZZZ_genl_mcgrps);
+       return genl_register_family(&ZZZ_genl_family);
 }
 
 void CONCAT_(GENL_MAGIC_FAMILY, _genl_unregister)(void)
index 43a5c3975a2f1815fd362943f29188fdfac647c1..2298b50cee346f95fbfc23d733c865c74317e9a5 100644 (file)
@@ -39,13 +39,14 @@ struct genl_info;
  *     Note that unbind() will not be called symmetrically if the
  *     generic netlink family is removed while there are still open
  *     sockets.
- * @attrbuf: buffer to store parsed attributes
- * @family_list: family list
- * @mcgrps: multicast groups used by this family (private)
- * @n_mcgrps: number of multicast groups (private)
+ * @attrbuf: buffer to store parsed attributes (private)
+ * @family_list: family list (private)
+ * @mcgrps: multicast groups used by this family
+ * @n_mcgrps: number of multicast groups
  * @mcgrp_offset: starting number of multicast group IDs in this family
- * @ops: the operations supported by this family (private)
- * @n_ops: number of operations supported by this family (private)
+ *     (private)
+ * @ops: the operations supported by this family
+ * @n_ops: number of operations supported by this family
  */
 struct genl_family {
        unsigned int            id;             /* private */
@@ -64,10 +65,10 @@ struct genl_family {
        int                     (*mcast_bind)(struct net *net, int group);
        void                    (*mcast_unbind)(struct net *net, int group);
        struct nlattr **        attrbuf;        /* private */
-       const struct genl_ops * ops;            /* private */
-       const struct genl_multicast_group *mcgrps; /* private */
-       unsigned int            n_ops;          /* private */
-       unsigned int            n_mcgrps;       /* private */
+       const struct genl_ops * ops;
+       const struct genl_multicast_group *mcgrps;
+       unsigned int            n_ops;
+       unsigned int            n_mcgrps;
        unsigned int            mcgrp_offset;   /* private */
        struct list_head        family_list;    /* private */
        struct module           *module;
@@ -132,55 +133,7 @@ struct genl_ops {
        u8                      flags;
 };
 
-int __genl_register_family(struct genl_family *family);
-
-static inline int genl_register_family(struct genl_family *family)
-{
-       family->module = THIS_MODULE;
-       return __genl_register_family(family);
-}
-
-/**
- * genl_register_family_with_ops - register a generic netlink family with ops
- * @family: generic netlink family
- * @ops: operations to be registered
- * @n_ops: number of elements to register
- *
- * Registers the specified family and operations from the specified table.
- * Only one family may be registered with the same family name or identifier.
- *
- * Either a doit or dumpit callback must be specified for every registered
- * operation or the function will fail. Only one operation structure per
- * command identifier may be registered.
- *
- * See include/net/genetlink.h for more documenation on the operations
- * structure.
- *
- * Return 0 on success or a negative error code.
- */
-static inline int
-_genl_register_family_with_ops_grps(struct genl_family *family,
-                                   const struct genl_ops *ops, size_t n_ops,
-                                   const struct genl_multicast_group *mcgrps,
-                                   size_t n_mcgrps)
-{
-       family->module = THIS_MODULE;
-       family->ops = ops;
-       family->n_ops = n_ops;
-       family->mcgrps = mcgrps;
-       family->n_mcgrps = n_mcgrps;
-       return __genl_register_family(family);
-}
-
-#define genl_register_family_with_ops(family, ops)                     \
-       _genl_register_family_with_ops_grps((family),                   \
-                                           (ops), ARRAY_SIZE(ops),     \
-                                           NULL, 0)
-#define genl_register_family_with_ops_groups(family, ops, grps)        \
-       _genl_register_family_with_ops_grps((family),                   \
-                                           (ops), ARRAY_SIZE(ops),     \
-                                           (grps), ARRAY_SIZE(grps))
-
+int genl_register_family(struct genl_family *family);
 int genl_unregister_family(struct genl_family *family);
 void genl_notify(struct genl_family *family, struct sk_buff *skb,
                 struct genl_info *info, u32 group, gfp_t flags);
index d7a1a9461a10e3a85891413f2ab52c789475599a..4075ece592f2b8ddf7347987aea402e30c47f589 100644 (file)
@@ -41,11 +41,7 @@ static DEFINE_PER_CPU(__u32, taskstats_seqnum);
 static int family_registered;
 struct kmem_cache *taskstats_cache;
 
-static struct genl_family family = {
-       .name           = TASKSTATS_GENL_NAME,
-       .version        = TASKSTATS_GENL_VERSION,
-       .maxattr        = TASKSTATS_CMD_ATTR_MAX,
-};
+static struct genl_family family;
 
 static const struct nla_policy taskstats_cmd_get_policy[TASKSTATS_CMD_ATTR_MAX+1] = {
        [TASKSTATS_CMD_ATTR_PID]  = { .type = NLA_U32 },
@@ -650,6 +646,15 @@ static const struct genl_ops taskstats_ops[] = {
        },
 };
 
+static struct genl_family family = {
+       .name           = TASKSTATS_GENL_NAME,
+       .version        = TASKSTATS_GENL_VERSION,
+       .maxattr        = TASKSTATS_CMD_ATTR_MAX,
+       .module         = THIS_MODULE,
+       .ops            = taskstats_ops,
+       .n_ops          = ARRAY_SIZE(taskstats_ops),
+};
+
 /* Needed early in initialization */
 void __init taskstats_init_early(void)
 {
@@ -666,7 +671,7 @@ static int __init taskstats_init(void)
 {
        int rc;
 
-       rc = genl_register_family_with_ops(&family, taskstats_ops);
+       rc = genl_register_family(&family);
        if (rc)
                return rc;
 
index a03b0ed7e8dd6a8196e34c28dde9b23c5260c861..e28cec34a016499642b7ebb1fc3abad898dba921 100644 (file)
 #include "tp_meter.h"
 #include "translation-table.h"
 
-struct genl_family batadv_netlink_family = {
-       .hdrsize = 0,
-       .name = BATADV_NL_NAME,
-       .version = 1,
-       .maxattr = BATADV_ATTR_MAX,
-       .netnsok = true,
-};
+struct genl_family batadv_netlink_family;
 
 /* multicast groups */
 enum batadv_netlink_multicast_groups {
@@ -609,6 +603,19 @@ static struct genl_ops batadv_netlink_ops[] = {
 
 };
 
+struct genl_family batadv_netlink_family = {
+       .hdrsize = 0,
+       .name = BATADV_NL_NAME,
+       .version = 1,
+       .maxattr = BATADV_ATTR_MAX,
+       .netnsok = true,
+       .module = THIS_MODULE,
+       .ops = batadv_netlink_ops,
+       .n_ops = ARRAY_SIZE(batadv_netlink_ops),
+       .mcgrps = batadv_netlink_mcgrps,
+       .n_mcgrps = ARRAY_SIZE(batadv_netlink_mcgrps),
+};
+
 /**
  * batadv_netlink_register - register batadv genl netlink family
  */
@@ -616,9 +623,7 @@ void __init batadv_netlink_register(void)
 {
        int ret;
 
-       ret = genl_register_family_with_ops_groups(&batadv_netlink_family,
-                                                  batadv_netlink_ops,
-                                                  batadv_netlink_mcgrps);
+       ret = genl_register_family(&batadv_netlink_family);
        if (ret)
                pr_warn("unable to register netlink family");
 }
index 3008d9c33875cd77ad327ee5b87349927939c92b..063da8091aefa65dda5bf48fb800066defb819a3 100644 (file)
@@ -341,14 +341,7 @@ static void devlink_nl_post_doit(const struct genl_ops *ops,
        mutex_unlock(&devlink_mutex);
 }
 
-static struct genl_family devlink_nl_family = {
-       .name           = DEVLINK_GENL_NAME,
-       .version        = DEVLINK_GENL_VERSION,
-       .maxattr        = DEVLINK_ATTR_MAX,
-       .netnsok        = true,
-       .pre_doit       = devlink_nl_pre_doit,
-       .post_doit      = devlink_nl_post_doit,
-};
+static struct genl_family devlink_nl_family;
 
 enum devlink_multicast_groups {
        DEVLINK_MCGRP_CONFIG,
@@ -1619,6 +1612,20 @@ static const struct genl_ops devlink_nl_ops[] = {
        },
 };
 
+static struct genl_family devlink_nl_family = {
+       .name           = DEVLINK_GENL_NAME,
+       .version        = DEVLINK_GENL_VERSION,
+       .maxattr        = DEVLINK_ATTR_MAX,
+       .netnsok        = true,
+       .pre_doit       = devlink_nl_pre_doit,
+       .post_doit      = devlink_nl_post_doit,
+       .module         = THIS_MODULE,
+       .ops            = devlink_nl_ops,
+       .n_ops          = ARRAY_SIZE(devlink_nl_ops),
+       .mcgrps         = devlink_nl_mcgrps,
+       .n_mcgrps       = ARRAY_SIZE(devlink_nl_mcgrps),
+};
+
 /**
  *     devlink_alloc - Allocate new devlink instance resources
  *
@@ -1841,9 +1848,7 @@ EXPORT_SYMBOL_GPL(devlink_sb_unregister);
 
 static int __init devlink_module_init(void)
 {
-       return genl_register_family_with_ops_groups(&devlink_nl_family,
-                                                   devlink_nl_ops,
-                                                   devlink_nl_mcgrps);
+       return genl_register_family(&devlink_nl_family);
 }
 
 static void __exit devlink_module_exit(void)
index a5320dfcd978d09a7fd9d32b95fedaee1b4756d2..80c002794ff668d952a81980bfd45d82ebc2a213 100644 (file)
@@ -59,11 +59,7 @@ struct dm_hw_stat_delta {
        unsigned long last_drop_val;
 };
 
-static struct genl_family net_drop_monitor_family = {
-       .hdrsize        = 0,
-       .name           = "NET_DM",
-       .version        = 2,
-};
+static struct genl_family net_drop_monitor_family;
 
 static DEFINE_PER_CPU(struct per_cpu_dm_data, dm_cpu_data);
 
@@ -350,6 +346,17 @@ static const struct genl_ops dropmon_ops[] = {
        },
 };
 
+static struct genl_family net_drop_monitor_family = {
+       .hdrsize        = 0,
+       .name           = "NET_DM",
+       .version        = 2,
+       .module         = THIS_MODULE,
+       .ops            = dropmon_ops,
+       .n_ops          = ARRAY_SIZE(dropmon_ops),
+       .mcgrps         = dropmon_mcgrps,
+       .n_mcgrps       = ARRAY_SIZE(dropmon_mcgrps),
+};
+
 static struct notifier_block dropmon_net_notifier = {
        .notifier_call = dropmon_net_event
 };
@@ -366,8 +373,7 @@ static int __init init_net_drop_monitor(void)
                return -ENOSPC;
        }
 
-       rc = genl_register_family_with_ops_groups(&net_drop_monitor_family,
-                                                 dropmon_ops, dropmon_mcgrps);
+       rc = genl_register_family(&net_drop_monitor_family);
        if (rc) {
                pr_err("Could not create drop monitor netlink family\n");
                return rc;
index 2ad039492bee8beb913f46349b29ea8aa9c6c47e..aab34c7f6f89795496ccb174ca52a389a81f08a0 100644 (file)
@@ -131,12 +131,7 @@ static const struct nla_policy hsr_genl_policy[HSR_A_MAX + 1] = {
        [HSR_A_IF2_SEQ] = { .type = NLA_U16 },
 };
 
-static struct genl_family hsr_genl_family = {
-       .hdrsize = 0,
-       .name = "HSR",
-       .version = 1,
-       .maxattr = HSR_A_MAX,
-};
+static struct genl_family hsr_genl_family;
 
 static const struct genl_multicast_group hsr_mcgrps[] = {
        { .name = "hsr-network", },
@@ -466,6 +461,18 @@ static const struct genl_ops hsr_ops[] = {
        },
 };
 
+static struct genl_family hsr_genl_family = {
+       .hdrsize = 0,
+       .name = "HSR",
+       .version = 1,
+       .maxattr = HSR_A_MAX,
+       .module = THIS_MODULE,
+       .ops = hsr_ops,
+       .n_ops = ARRAY_SIZE(hsr_ops),
+       .mcgrps = hsr_mcgrps,
+       .n_mcgrps = ARRAY_SIZE(hsr_mcgrps),
+};
+
 int __init hsr_netlink_init(void)
 {
        int rc;
@@ -474,8 +481,7 @@ int __init hsr_netlink_init(void)
        if (rc)
                goto fail_rtnl_link_register;
 
-       rc = genl_register_family_with_ops_groups(&hsr_genl_family, hsr_ops,
-                                                 hsr_mcgrps);
+       rc = genl_register_family(&hsr_genl_family);
        if (rc)
                goto fail_genl_register_family;
 
index 19144158b69661386f8d3395f25403ecbd30ebb4..08e62470bac2fd18a807906182807c5579890c07 100644 (file)
 static unsigned int ieee802154_seq_num;
 static DEFINE_SPINLOCK(ieee802154_seq_lock);
 
-struct genl_family nl802154_family = {
-       .hdrsize        = 0,
-       .name           = IEEE802154_NL_NAME,
-       .version        = 1,
-       .maxattr        = IEEE802154_ATTR_MAX,
-};
-
 /* Requests to userspace */
 struct sk_buff *ieee802154_nl_create(int flags, u8 req)
 {
@@ -138,11 +131,21 @@ static const struct genl_multicast_group ieee802154_mcgrps[] = {
        [IEEE802154_BEACON_MCGRP] = { .name = IEEE802154_MCAST_BEACON_NAME, },
 };
 
+struct genl_family nl802154_family = {
+       .hdrsize        = 0,
+       .name           = IEEE802154_NL_NAME,
+       .version        = 1,
+       .maxattr        = IEEE802154_ATTR_MAX,
+       .module         = THIS_MODULE,
+       .ops            = ieee8021154_ops,
+       .n_ops          = ARRAY_SIZE(ieee8021154_ops),
+       .mcgrps         = ieee802154_mcgrps,
+       .n_mcgrps       = ARRAY_SIZE(ieee802154_mcgrps),
+};
+
 int __init ieee802154_nl_init(void)
 {
-       return genl_register_family_with_ops_groups(&nl802154_family,
-                                                   ieee8021154_ops,
-                                                   ieee802154_mcgrps);
+       return genl_register_family(&nl802154_family);
 }
 
 void ieee802154_nl_exit(void)
index 182299858f1d89b1c8771a064a10e38483c54ff1..f7e75578aeddf12fbf643c2b45fdd2d84467eaac 100644 (file)
 #include "rdev-ops.h"
 #include "core.h"
 
-static int nl802154_pre_doit(const struct genl_ops *ops, struct sk_buff *skb,
-                            struct genl_info *info);
-
-static void nl802154_post_doit(const struct genl_ops *ops, struct sk_buff *skb,
-                              struct genl_info *info);
-
 /* the netlink family */
-static struct genl_family nl802154_fam = {
-       .name = NL802154_GENL_NAME,     /* have users key off the name instead */
-       .hdrsize = 0,                   /* no private header */
-       .version = 1,                   /* no particular meaning now */
-       .maxattr = NL802154_ATTR_MAX,
-       .netnsok = true,
-       .pre_doit = nl802154_pre_doit,
-       .post_doit = nl802154_post_doit,
-};
+static struct genl_family nl802154_fam;
 
 /* multicast groups */
 enum nl802154_multicast_groups {
@@ -2476,11 +2462,25 @@ static const struct genl_ops nl802154_ops[] = {
 #endif /* CONFIG_IEEE802154_NL802154_EXPERIMENTAL */
 };
 
+static struct genl_family nl802154_fam = {
+       .name = NL802154_GENL_NAME,     /* have users key off the name instead */
+       .hdrsize = 0,                   /* no private header */
+       .version = 1,                   /* no particular meaning now */
+       .maxattr = NL802154_ATTR_MAX,
+       .netnsok = true,
+       .pre_doit = nl802154_pre_doit,
+       .post_doit = nl802154_post_doit,
+       .module = THIS_MODULE,
+       .ops = nl802154_ops,
+       .n_ops = ARRAY_SIZE(nl802154_ops),
+       .mcgrps = nl802154_mcgrps,
+       .n_mcgrps = ARRAY_SIZE(nl802154_mcgrps),
+};
+
 /* initialisation/exit functions */
 int nl802154_init(void)
 {
-       return genl_register_family_with_ops_groups(&nl802154_fam, nl802154_ops,
-                                                   nl802154_mcgrps);
+       return genl_register_family(&nl802154_fam);
 }
 
 void nl802154_exit(void)
index e3fc527c5d3786dd48b359ac6f0cedf4c96630bb..5b5226a2434f8d4c052d12f8212b44a1133a1a22 100644 (file)
@@ -622,13 +622,7 @@ static int fou_destroy(struct net *net, struct fou_cfg *cfg)
        return err;
 }
 
-static struct genl_family fou_nl_family = {
-       .hdrsize        = 0,
-       .name           = FOU_GENL_NAME,
-       .version        = FOU_GENL_VERSION,
-       .maxattr        = FOU_ATTR_MAX,
-       .netnsok        = true,
-};
+static struct genl_family fou_nl_family;
 
 static const struct nla_policy fou_nl_policy[FOU_ATTR_MAX + 1] = {
        [FOU_ATTR_PORT] = { .type = NLA_U16, },
@@ -830,6 +824,17 @@ static const struct genl_ops fou_nl_ops[] = {
        },
 };
 
+static struct genl_family fou_nl_family = {
+       .hdrsize        = 0,
+       .name           = FOU_GENL_NAME,
+       .version        = FOU_GENL_VERSION,
+       .maxattr        = FOU_ATTR_MAX,
+       .netnsok        = true,
+       .module         = THIS_MODULE,
+       .ops            = fou_nl_ops,
+       .n_ops          = ARRAY_SIZE(fou_nl_ops),
+};
+
 size_t fou_encap_hlen(struct ip_tunnel_encap *e)
 {
        return sizeof(struct udphdr);
@@ -1085,8 +1090,7 @@ static int __init fou_init(void)
        if (ret)
                goto exit;
 
-       ret = genl_register_family_with_ops(&fou_nl_family,
-                                           fou_nl_ops);
+       ret = genl_register_family(&fou_nl_family);
        if (ret < 0)
                goto unregister;
 
index 3da305127b32a067ac420db2be160bf203288e2d..bba3c72c4a3909a3e68dce1685df088a83b8ad6f 100644 (file)
@@ -742,13 +742,7 @@ void tcp_fastopen_cache_set(struct sock *sk, u16 mss,
        rcu_read_unlock();
 }
 
-static struct genl_family tcp_metrics_nl_family = {
-       .hdrsize        = 0,
-       .name           = TCP_METRICS_GENL_NAME,
-       .version        = TCP_METRICS_GENL_VERSION,
-       .maxattr        = TCP_METRICS_ATTR_MAX,
-       .netnsok        = true,
-};
+static struct genl_family tcp_metrics_nl_family;
 
 static const struct nla_policy tcp_metrics_nl_policy[TCP_METRICS_ATTR_MAX + 1] = {
        [TCP_METRICS_ATTR_ADDR_IPV4]    = { .type = NLA_U32, },
@@ -1115,6 +1109,17 @@ static const struct genl_ops tcp_metrics_nl_ops[] = {
        },
 };
 
+static struct genl_family tcp_metrics_nl_family = {
+       .hdrsize        = 0,
+       .name           = TCP_METRICS_GENL_NAME,
+       .version        = TCP_METRICS_GENL_VERSION,
+       .maxattr        = TCP_METRICS_ATTR_MAX,
+       .netnsok        = true,
+       .module         = THIS_MODULE,
+       .ops            = tcp_metrics_nl_ops,
+       .n_ops          = ARRAY_SIZE(tcp_metrics_nl_ops),
+};
+
 static unsigned int tcpmhash_entries;
 static int __init set_tcpmhash_entries(char *str)
 {
@@ -1178,8 +1183,7 @@ void __init tcp_metrics_init(void)
        if (ret < 0)
                panic("Could not allocate the tcp_metrics hash table\n");
 
-       ret = genl_register_family_with_ops(&tcp_metrics_nl_family,
-                                           tcp_metrics_nl_ops);
+       ret = genl_register_family(&tcp_metrics_nl_family);
        if (ret < 0)
                panic("Could not register tcp_metrics generic netlink\n");
 }
index 0d57e27d1cdd2dc744a1f7bbae3032aa6955f986..97f7b0cc46750d273a4385ec5261cd97a72c7d41 100644 (file)
@@ -118,14 +118,7 @@ static const struct rhashtable_params rht_params = {
        .obj_cmpfn = ila_cmpfn,
 };
 
-static struct genl_family ila_nl_family = {
-       .hdrsize        = 0,
-       .name           = ILA_GENL_NAME,
-       .version        = ILA_GENL_VERSION,
-       .maxattr        = ILA_ATTR_MAX,
-       .netnsok        = true,
-       .parallel_ops   = true,
-};
+static struct genl_family ila_nl_family;
 
 static const struct nla_policy ila_nl_policy[ILA_ATTR_MAX + 1] = {
        [ILA_ATTR_LOCATOR] = { .type = NLA_U64, },
@@ -560,6 +553,18 @@ static const struct genl_ops ila_nl_ops[] = {
        },
 };
 
+static struct genl_family ila_nl_family = {
+       .hdrsize        = 0,
+       .name           = ILA_GENL_NAME,
+       .version        = ILA_GENL_VERSION,
+       .maxattr        = ILA_ATTR_MAX,
+       .netnsok        = true,
+       .parallel_ops   = true,
+       .module         = THIS_MODULE,
+       .ops            = ila_nl_ops,
+       .n_ops          = ARRAY_SIZE(ila_nl_ops),
+};
+
 #define ILA_HASH_TABLE_SIZE 1024
 
 static __net_init int ila_init_net(struct net *net)
@@ -630,8 +635,7 @@ int ila_xlat_init(void)
        if (ret)
                goto exit;
 
-       ret = genl_register_family_with_ops(&ila_nl_family,
-                                           ila_nl_ops);
+       ret = genl_register_family(&ila_nl_family);
        if (ret < 0)
                goto unregister;
 
index f23b81aa91fefb2bcd8de1aa9fcbff160e981541..07877347c2f77f13af40178cc0709f0d7f06e23c 100644 (file)
 
 
 
-static struct genl_family irda_nl_family = {
-       .name = IRDA_NL_NAME,
-       .hdrsize = 0,
-       .version = IRDA_NL_VERSION,
-       .maxattr = IRDA_NL_CMD_MAX,
-};
+static struct genl_family irda_nl_family;
 
 static struct net_device * ifname_to_netdev(struct net *net, struct genl_info *info)
 {
@@ -146,9 +141,19 @@ static const struct genl_ops irda_nl_ops[] = {
 
 };
 
+static struct genl_family irda_nl_family = {
+       .name = IRDA_NL_NAME,
+       .hdrsize = 0,
+       .version = IRDA_NL_VERSION,
+       .maxattr = IRDA_NL_CMD_MAX,
+       .module = THIS_MODULE,
+       .ops = irda_nl_ops,
+       .n_ops = ARRAY_SIZE(irda_nl_ops),
+};
+
 int irda_nl_register(void)
 {
-       return genl_register_family_with_ops(&irda_nl_family, irda_nl_ops);
+       return genl_register_family(&irda_nl_family);
 }
 
 void irda_nl_unregister(void)
index 4fbf1f41ac5249e557d5306ae5d49aa815fb2f33..e4e8c0769a6be69a8f5fd09ae937fe3fbb8062da 100644 (file)
 #include "l2tp_core.h"
 
 
-static struct genl_family l2tp_nl_family = {
-       .name           = L2TP_GENL_NAME,
-       .version        = L2TP_GENL_VERSION,
-       .hdrsize        = 0,
-       .maxattr        = L2TP_ATTR_MAX,
-       .netnsok        = true,
-};
+static struct genl_family l2tp_nl_family;
 
 static const struct genl_multicast_group l2tp_multicast_group[] = {
        {
@@ -976,6 +970,19 @@ static const struct genl_ops l2tp_nl_ops[] = {
        },
 };
 
+static struct genl_family l2tp_nl_family = {
+       .name           = L2TP_GENL_NAME,
+       .version        = L2TP_GENL_VERSION,
+       .hdrsize        = 0,
+       .maxattr        = L2TP_ATTR_MAX,
+       .netnsok        = true,
+       .module         = THIS_MODULE,
+       .ops            = l2tp_nl_ops,
+       .n_ops          = ARRAY_SIZE(l2tp_nl_ops),
+       .mcgrps         = l2tp_multicast_group,
+       .n_mcgrps       = ARRAY_SIZE(l2tp_multicast_group),
+};
+
 int l2tp_nl_register_ops(enum l2tp_pwtype pw_type, const struct l2tp_nl_cmd_ops *ops)
 {
        int ret;
@@ -1012,9 +1019,7 @@ EXPORT_SYMBOL_GPL(l2tp_nl_unregister_ops);
 static int l2tp_nl_init(void)
 {
        pr_info("L2TP netlink interface\n");
-       return genl_register_family_with_ops_groups(&l2tp_nl_family,
-                                                   l2tp_nl_ops,
-                                                   l2tp_multicast_group);
+       return genl_register_family(&l2tp_nl_family);
 }
 
 static void l2tp_nl_cleanup(void)
index ceed66cdd03e5b4b2f5c6bb07189a2b55f7fa157..ea3e8aed063ff3eb89c9116697066ea4e657ef4c 100644 (file)
@@ -2840,13 +2840,7 @@ static struct nf_sockopt_ops ip_vs_sockopts = {
  */
 
 /* IPVS genetlink family */
-static struct genl_family ip_vs_genl_family = {
-       .hdrsize        = 0,
-       .name           = IPVS_GENL_NAME,
-       .version        = IPVS_GENL_VERSION,
-       .maxattr        = IPVS_CMD_MAX,
-       .netnsok        = true,         /* Make ipvsadm to work on netns */
-};
+static struct genl_family ip_vs_genl_family;
 
 /* Policy used for first-level command attributes */
 static const struct nla_policy ip_vs_cmd_policy[IPVS_CMD_ATTR_MAX + 1] = {
@@ -3871,10 +3865,20 @@ static const struct genl_ops ip_vs_genl_ops[] = {
        },
 };
 
+static struct genl_family ip_vs_genl_family = {
+       .hdrsize        = 0,
+       .name           = IPVS_GENL_NAME,
+       .version        = IPVS_GENL_VERSION,
+       .maxattr        = IPVS_CMD_MAX,
+       .netnsok        = true,         /* Make ipvsadm to work on netns */
+       .module         = THIS_MODULE,
+       .ops            = ip_vs_genl_ops,
+       .n_ops          = ARRAY_SIZE(ip_vs_genl_ops),
+};
+
 static int __init ip_vs_genl_register(void)
 {
-       return genl_register_family_with_ops(&ip_vs_genl_family,
-                                            ip_vs_genl_ops);
+       return genl_register_family(&ip_vs_genl_family);
 }
 
 static void ip_vs_genl_unregister(void)
index 152e503b8c5ddeda59ee7ab40c49e471d4aace8a..ca7c9c411a5c9824d4c56914914774e1e4be5ed0 100644 (file)
@@ -60,12 +60,7 @@ struct netlbl_domhsh_walk_arg {
 };
 
 /* NetLabel Generic NETLINK CALIPSO family */
-static struct genl_family netlbl_calipso_gnl_family = {
-       .hdrsize = 0,
-       .name = NETLBL_NLTYPE_CALIPSO_NAME,
-       .version = NETLBL_PROTO_VERSION,
-       .maxattr = NLBL_CALIPSO_A_MAX,
-};
+static struct genl_family netlbl_calipso_gnl_family;
 
 /* NetLabel Netlink attribute policy */
 static const struct nla_policy calipso_genl_policy[NLBL_CALIPSO_A_MAX + 1] = {
@@ -354,6 +349,16 @@ static const struct genl_ops netlbl_calipso_ops[] = {
        },
 };
 
+static struct genl_family netlbl_calipso_gnl_family = {
+       .hdrsize = 0,
+       .name = NETLBL_NLTYPE_CALIPSO_NAME,
+       .version = NETLBL_PROTO_VERSION,
+       .maxattr = NLBL_CALIPSO_A_MAX,
+       .module = THIS_MODULE,
+       .ops = netlbl_calipso_ops,
+       .n_ops = ARRAY_SIZE(netlbl_calipso_ops),
+};
+
 /* NetLabel Generic NETLINK Protocol Functions
  */
 
@@ -367,8 +372,7 @@ static const struct genl_ops netlbl_calipso_ops[] = {
  */
 int __init netlbl_calipso_genl_init(void)
 {
-       return genl_register_family_with_ops(&netlbl_calipso_gnl_family,
-                                            netlbl_calipso_ops);
+       return genl_register_family(&netlbl_calipso_gnl_family);
 }
 
 static const struct netlbl_calipso_ops *calipso_ops;
index 755b284e7ad404a7654234f5dab307b2e4a32166..a665eae91245114270bfec2b640c1b766dd11dbe 100644 (file)
@@ -59,13 +59,7 @@ struct netlbl_domhsh_walk_arg {
 };
 
 /* NetLabel Generic NETLINK CIPSOv4 family */
-static struct genl_family netlbl_cipsov4_gnl_family = {
-       .hdrsize = 0,
-       .name = NETLBL_NLTYPE_CIPSOV4_NAME,
-       .version = NETLBL_PROTO_VERSION,
-       .maxattr = NLBL_CIPSOV4_A_MAX,
-};
-
+static struct genl_family netlbl_cipsov4_gnl_family;
 /* NetLabel Netlink attribute policy */
 static const struct nla_policy netlbl_cipsov4_genl_policy[NLBL_CIPSOV4_A_MAX + 1] = {
        [NLBL_CIPSOV4_A_DOI] = { .type = NLA_U32 },
@@ -766,6 +760,16 @@ static const struct genl_ops netlbl_cipsov4_ops[] = {
        },
 };
 
+static struct genl_family netlbl_cipsov4_gnl_family = {
+       .hdrsize = 0,
+       .name = NETLBL_NLTYPE_CIPSOV4_NAME,
+       .version = NETLBL_PROTO_VERSION,
+       .maxattr = NLBL_CIPSOV4_A_MAX,
+       .module = THIS_MODULE,
+       .ops = netlbl_cipsov4_ops,
+       .n_ops = ARRAY_SIZE(netlbl_cipsov4_ops),
+};
+
 /*
  * NetLabel Generic NETLINK Protocol Functions
  */
@@ -780,6 +784,5 @@ static const struct genl_ops netlbl_cipsov4_ops[] = {
  */
 int __init netlbl_cipsov4_genl_init(void)
 {
-       return genl_register_family_with_ops(&netlbl_cipsov4_gnl_family,
-                                            netlbl_cipsov4_ops);
+       return genl_register_family(&netlbl_cipsov4_gnl_family);
 }
index 3b00f2368fcd49eee521caf917bdd276c6584d20..ecfe8eb149db5def8a0e506cd647959d32ce1d41 100644 (file)
@@ -60,12 +60,7 @@ struct netlbl_domhsh_walk_arg {
 };
 
 /* NetLabel Generic NETLINK CIPSOv4 family */
-static struct genl_family netlbl_mgmt_gnl_family = {
-       .hdrsize = 0,
-       .name = NETLBL_NLTYPE_MGMT_NAME,
-       .version = NETLBL_PROTO_VERSION,
-       .maxattr = NLBL_MGMT_A_MAX,
-};
+static struct genl_family netlbl_mgmt_gnl_family;
 
 /* NetLabel Netlink attribute policy */
 static const struct nla_policy netlbl_mgmt_genl_policy[NLBL_MGMT_A_MAX + 1] = {
@@ -833,6 +828,16 @@ static const struct genl_ops netlbl_mgmt_genl_ops[] = {
        },
 };
 
+static struct genl_family netlbl_mgmt_gnl_family = {
+       .hdrsize = 0,
+       .name = NETLBL_NLTYPE_MGMT_NAME,
+       .version = NETLBL_PROTO_VERSION,
+       .maxattr = NLBL_MGMT_A_MAX,
+       .module = THIS_MODULE,
+       .ops = netlbl_mgmt_genl_ops,
+       .n_ops = ARRAY_SIZE(netlbl_mgmt_genl_ops),
+};
+
 /*
  * NetLabel Generic NETLINK Protocol Functions
  */
@@ -847,6 +852,5 @@ static const struct genl_ops netlbl_mgmt_genl_ops[] = {
  */
 int __init netlbl_mgmt_genl_init(void)
 {
-       return genl_register_family_with_ops(&netlbl_mgmt_gnl_family,
-                                            netlbl_mgmt_genl_ops);
+       return genl_register_family(&netlbl_mgmt_gnl_family);
 }
index c2ea8d1f653acbdcfeacc977cf581cbc21809d6d..5dbbad41114f8fd51a7ac69786da13f27b4ec1c3 100644 (file)
@@ -123,12 +123,7 @@ static struct netlbl_unlhsh_iface __rcu *netlbl_unlhsh_def;
 static u8 netlabel_unlabel_acceptflg;
 
 /* NetLabel Generic NETLINK unlabeled family */
-static struct genl_family netlbl_unlabel_gnl_family = {
-       .hdrsize = 0,
-       .name = NETLBL_NLTYPE_UNLABELED_NAME,
-       .version = NETLBL_PROTO_VERSION,
-       .maxattr = NLBL_UNLABEL_A_MAX,
-};
+static struct genl_family netlbl_unlabel_gnl_family;
 
 /* NetLabel Netlink attribute policy */
 static const struct nla_policy netlbl_unlabel_genl_policy[NLBL_UNLABEL_A_MAX + 1] = {
@@ -1377,6 +1372,16 @@ static const struct genl_ops netlbl_unlabel_genl_ops[] = {
        },
 };
 
+static struct genl_family netlbl_unlabel_gnl_family = {
+       .hdrsize = 0,
+       .name = NETLBL_NLTYPE_UNLABELED_NAME,
+       .version = NETLBL_PROTO_VERSION,
+       .maxattr = NLBL_UNLABEL_A_MAX,
+       .module = THIS_MODULE,
+       .ops = netlbl_unlabel_genl_ops,
+       .n_ops = ARRAY_SIZE(netlbl_unlabel_genl_ops),
+};
+
 /*
  * NetLabel Generic NETLINK Protocol Functions
  */
@@ -1391,8 +1396,7 @@ static const struct genl_ops netlbl_unlabel_genl_ops[] = {
  */
 int __init netlbl_unlabel_genl_init(void)
 {
-       return genl_register_family_with_ops(&netlbl_unlabel_gnl_family,
-                                            netlbl_unlabel_genl_ops);
+       return genl_register_family(&netlbl_unlabel_gnl_family);
 }
 
 /*
index f19ec969edee93ddf55bae4e14ca3a5cf96a0901..ca582ee4ae054aaaa3d4d43e8ed917021b297215 100644 (file)
@@ -344,18 +344,18 @@ static int genl_validate_ops(const struct genl_family *family)
 }
 
 /**
- * __genl_register_family - register a generic netlink family
+ * genl_register_family - register a generic netlink family
  * @family: generic netlink family
  *
  * Registers the specified family after validating it first. Only one
  * family may be registered with the same family name or identifier.
  *
- * The family's ops array must already be assigned, you can use the
- * genl_register_family_with_ops() helper function.
+ * The family's ops, multicast groups and module pointer must already
+ * be assigned.
  *
  * Return 0 on success or a negative error code.
  */
-int __genl_register_family(struct genl_family *family)
+int genl_register_family(struct genl_family *family)
 {
        int err, i;
 
@@ -429,7 +429,7 @@ errout_locked:
        genl_unlock_all();
        return err;
 }
-EXPORT_SYMBOL(__genl_register_family);
+EXPORT_SYMBOL(genl_register_family);
 
 /**
  * genl_unregister_family - unregister generic netlink family
@@ -452,7 +452,6 @@ int genl_unregister_family(struct genl_family *family)
                genl_unregister_mc_groups(family);
 
                list_del(&rc->family_list);
-               family->n_ops = 0;
                up_write(&cb_lock);
                wait_event(genl_sk_destructing_waitq,
                           atomic_read(&genl_sk_destructing_cnt) == 0);
@@ -681,13 +680,7 @@ static void genl_rcv(struct sk_buff *skb)
  * Controller
  **************************************************************************/
 
-static struct genl_family genl_ctrl = {
-       .id = GENL_ID_CTRL,
-       .name = "nlctrl",
-       .version = 0x2,
-       .maxattr = CTRL_ATTR_MAX,
-       .netnsok = true,
-};
+static struct genl_family genl_ctrl;
 
 static int ctrl_fill_info(struct genl_family *family, u32 portid, u32 seq,
                          u32 flags, struct sk_buff *skb, u8 cmd)
@@ -997,6 +990,19 @@ static const struct genl_multicast_group genl_ctrl_groups[] = {
        { .name = "notify", },
 };
 
+static struct genl_family genl_ctrl = {
+       .module = THIS_MODULE,
+       .ops = genl_ctrl_ops,
+       .n_ops = ARRAY_SIZE(genl_ctrl_ops),
+       .mcgrps = genl_ctrl_groups,
+       .n_mcgrps = ARRAY_SIZE(genl_ctrl_groups),
+       .id = GENL_ID_CTRL,
+       .name = "nlctrl",
+       .version = 0x2,
+       .maxattr = CTRL_ATTR_MAX,
+       .netnsok = true,
+};
+
 static int genl_bind(struct net *net, int group)
 {
        int i, err = -ENOENT;
@@ -1086,8 +1092,7 @@ static int __init genl_init(void)
        for (i = 0; i < GENL_FAM_TAB_SIZE; i++)
                INIT_LIST_HEAD(&family_ht[i]);
 
-       err = genl_register_family_with_ops_groups(&genl_ctrl, genl_ctrl_ops,
-                                                  genl_ctrl_groups);
+       err = genl_register_family(&genl_ctrl);
        if (err < 0)
                goto problem;
 
index c230403e066c10934d693d07a8ee67f2b18f0163..450b1e5144cc71cb89ee7dd9048ec164211e12b7 100644 (file)
@@ -38,13 +38,7 @@ static const struct genl_multicast_group nfc_genl_mcgrps[] = {
        { .name = NFC_GENL_MCAST_EVENT_NAME, },
 };
 
-static struct genl_family nfc_genl_family = {
-       .hdrsize = 0,
-       .name = NFC_GENL_NAME,
-       .version = NFC_GENL_VERSION,
-       .maxattr = NFC_ATTR_MAX,
-};
-
+static struct genl_family nfc_genl_family;
 static const struct nla_policy nfc_genl_policy[NFC_ATTR_MAX + 1] = {
        [NFC_ATTR_DEVICE_INDEX] = { .type = NLA_U32 },
        [NFC_ATTR_DEVICE_NAME] = { .type = NLA_STRING,
@@ -1752,6 +1746,18 @@ static const struct genl_ops nfc_genl_ops[] = {
        },
 };
 
+static struct genl_family nfc_genl_family = {
+       .hdrsize = 0,
+       .name = NFC_GENL_NAME,
+       .version = NFC_GENL_VERSION,
+       .maxattr = NFC_ATTR_MAX,
+       .module = THIS_MODULE,
+       .ops = nfc_genl_ops,
+       .n_ops = ARRAY_SIZE(nfc_genl_ops),
+       .mcgrps = nfc_genl_mcgrps,
+       .n_mcgrps = ARRAY_SIZE(nfc_genl_mcgrps),
+};
+
 
 struct urelease_work {
        struct  work_struct w;
@@ -1837,9 +1843,7 @@ int __init nfc_genl_init(void)
 {
        int rc;
 
-       rc = genl_register_family_with_ops_groups(&nfc_genl_family,
-                                                 nfc_genl_ops,
-                                                 nfc_genl_mcgrps);
+       rc = genl_register_family(&nfc_genl_family);
        if (rc)
                return rc;
 
index f9fef7dfba15a2bfbfa0c46f74ca5e1962eab82e..ad6a111a001437208459ca14666eb4a8d91a5343 100644 (file)
@@ -679,6 +679,7 @@ static struct genl_family dp_packet_genl_family = {
        .parallel_ops = true,
        .ops = dp_packet_genl_ops,
        .n_ops = ARRAY_SIZE(dp_packet_genl_ops),
+       .module = THIS_MODULE,
 };
 
 static void get_dp_stats(const struct datapath *dp, struct ovs_dp_stats *stats,
@@ -1445,6 +1446,7 @@ static struct genl_family dp_flow_genl_family = {
        .n_ops = ARRAY_SIZE(dp_flow_genl_ops),
        .mcgrps = &ovs_dp_flow_multicast_group,
        .n_mcgrps = 1,
+       .module = THIS_MODULE,
 };
 
 static size_t ovs_dp_cmd_msg_size(void)
@@ -1830,6 +1832,7 @@ static struct genl_family dp_datapath_genl_family = {
        .n_ops = ARRAY_SIZE(dp_datapath_genl_ops),
        .mcgrps = &ovs_dp_datapath_multicast_group,
        .n_mcgrps = 1,
+       .module = THIS_MODULE,
 };
 
 /* Called with ovs_mutex or RCU read lock. */
@@ -2251,6 +2254,7 @@ struct genl_family dp_vport_genl_family = {
        .n_ops = ARRAY_SIZE(dp_vport_genl_ops),
        .mcgrps = &ovs_dp_vport_multicast_group,
        .n_mcgrps = 1,
+       .module = THIS_MODULE,
 };
 
 static struct genl_family * const dp_genl_families[] = {
index 383b8fedabc76b14030b38614ca2f30cb539219e..74a405bf107bd57d51b3ffee1594d72321e84dfd 100644 (file)
@@ -135,14 +135,6 @@ const struct nla_policy tipc_nl_udp_policy[TIPC_NLA_UDP_MAX + 1] = {
 /* Users of the legacy API (tipc-config) can't handle that we add operations,
  * so we have a separate genl handling for the new API.
  */
-struct genl_family tipc_genl_family = {
-       .name           = TIPC_GENL_V2_NAME,
-       .version        = TIPC_GENL_V2_VERSION,
-       .hdrsize        = 0,
-       .maxattr        = TIPC_NLA_MAX,
-       .netnsok        = true,
-};
-
 static const struct genl_ops tipc_genl_v2_ops[] = {
        {
                .cmd    = TIPC_NL_BEARER_DISABLE,
@@ -257,6 +249,17 @@ static const struct genl_ops tipc_genl_v2_ops[] = {
 #endif
 };
 
+struct genl_family tipc_genl_family = {
+       .name           = TIPC_GENL_V2_NAME,
+       .version        = TIPC_GENL_V2_VERSION,
+       .hdrsize        = 0,
+       .maxattr        = TIPC_NLA_MAX,
+       .netnsok        = true,
+       .module         = THIS_MODULE,
+       .ops            = tipc_genl_v2_ops,
+       .n_ops          = ARRAY_SIZE(tipc_genl_v2_ops),
+};
+
 int tipc_nlmsg_parse(const struct nlmsghdr *nlh, struct nlattr ***attr)
 {
        u32 maxattr = tipc_genl_family.maxattr;
@@ -272,8 +275,7 @@ int tipc_netlink_start(void)
 {
        int res;
 
-       res = genl_register_family_with_ops(&tipc_genl_family,
-                                           tipc_genl_v2_ops);
+       res = genl_register_family(&tipc_genl_family);
        if (res) {
                pr_err("Failed to register netlink interface\n");
                return res;
index f04428e4c8e56beb83309a34afb96e8c95e397ff..07b19931e458461b5e93fce137dd855cf17c43c8 100644 (file)
@@ -1215,27 +1215,29 @@ send:
        return err;
 }
 
+static struct genl_ops tipc_genl_compat_ops[] = {
+       {
+               .cmd            = TIPC_GENL_CMD,
+               .doit           = tipc_nl_compat_recv,
+       },
+};
+
 static struct genl_family tipc_genl_compat_family = {
        .name           = TIPC_GENL_NAME,
        .version        = TIPC_GENL_VERSION,
        .hdrsize        = TIPC_GENL_HDRLEN,
        .maxattr        = 0,
        .netnsok        = true,
-};
-
-static struct genl_ops tipc_genl_compat_ops[] = {
-       {
-               .cmd            = TIPC_GENL_CMD,
-               .doit           = tipc_nl_compat_recv,
-       },
+       .module         = THIS_MODULE,
+       .ops            = tipc_genl_compat_ops,
+       .n_ops          = ARRAY_SIZE(tipc_genl_compat_ops),
 };
 
 int tipc_netlink_compat_start(void)
 {
        int res;
 
-       res = genl_register_family_with_ops(&tipc_genl_compat_family,
-                                           tipc_genl_compat_ops);
+       res = genl_register_family(&tipc_genl_compat_family);
        if (res) {
                pr_err("Failed to register legacy compat interface\n");
                return res;
index 8ac83a41585f2c4866786d45a87f8302ea8d4a57..587e1627681f079c317cb63fdc4df96646fba7ac 100644 (file)
@@ -572,15 +572,20 @@ struct d_level D_LEVEL[] = {
 size_t D_LEVEL_SIZE = ARRAY_SIZE(D_LEVEL);
 
 
+static const struct genl_multicast_group wimax_gnl_mcgrps[] = {
+       { .name = "msg", },
+};
+
 struct genl_family wimax_gnl_family = {
        .name = "WiMAX",
        .version = WIMAX_GNL_VERSION,
        .hdrsize = 0,
        .maxattr = WIMAX_GNL_ATTR_MAX,
-};
-
-static const struct genl_multicast_group wimax_gnl_mcgrps[] = {
-       { .name = "msg", },
+       .module = THIS_MODULE,
+       .ops = wimax_gnl_ops,
+       .n_ops = ARRAY_SIZE(wimax_gnl_ops),
+       .mcgrps = wimax_gnl_mcgrps,
+       .n_mcgrps = ARRAY_SIZE(wimax_gnl_mcgrps),
 };
 
 
@@ -595,11 +600,7 @@ int __init wimax_subsys_init(void)
        d_parse_params(D_LEVEL, D_LEVEL_SIZE, wimax_debug_params,
                       "wimax.debug");
 
-       snprintf(wimax_gnl_family.name, sizeof(wimax_gnl_family.name),
-                "WiMAX");
-       result = genl_register_family_with_ops_groups(&wimax_gnl_family,
-                                                     wimax_gnl_ops,
-                                                     wimax_gnl_mcgrps);
+       result = genl_register_family(&wimax_gnl_family);
        if (unlikely(result < 0)) {
                pr_err("cannot register generic netlink family: %d\n", result);
                goto error_register_family;
index 714beafe05e0d8fec01b128290413745efcc5b96..8e5ca3c475933fad902219453ab55a3caefa4bb5 100644 (file)
@@ -32,21 +32,8 @@ static int nl80211_crypto_settings(struct cfg80211_registered_device *rdev,
                                   struct cfg80211_crypto_settings *settings,
                                   int cipher_limit);
 
-static int nl80211_pre_doit(const struct genl_ops *ops, struct sk_buff *skb,
-                           struct genl_info *info);
-static void nl80211_post_doit(const struct genl_ops *ops, struct sk_buff *skb,
-                             struct genl_info *info);
-
 /* the netlink family */
-static struct genl_family nl80211_fam = {
-       .name = NL80211_GENL_NAME,      /* have users key off the name instead */
-       .hdrsize = 0,                   /* no private header */
-       .version = 1,                   /* no particular meaning now */
-       .maxattr = NL80211_ATTR_MAX,
-       .netnsok = true,
-       .pre_doit = nl80211_pre_doit,
-       .post_doit = nl80211_post_doit,
-};
+static struct genl_family nl80211_fam;
 
 /* multicast groups */
 enum nl80211_multicast_groups {
@@ -12599,6 +12586,21 @@ static const struct genl_ops nl80211_ops[] = {
        },
 };
 
+static struct genl_family nl80211_fam = {
+       .name = NL80211_GENL_NAME,      /* have users key off the name instead */
+       .hdrsize = 0,                   /* no private header */
+       .version = 1,                   /* no particular meaning now */
+       .maxattr = NL80211_ATTR_MAX,
+       .netnsok = true,
+       .pre_doit = nl80211_pre_doit,
+       .post_doit = nl80211_post_doit,
+       .module = THIS_MODULE,
+       .ops = nl80211_ops,
+       .n_ops = ARRAY_SIZE(nl80211_ops),
+       .mcgrps = nl80211_mcgrps,
+       .n_mcgrps = ARRAY_SIZE(nl80211_mcgrps),
+};
+
 /* notification functions */
 
 void nl80211_notify_wiphy(struct cfg80211_registered_device *rdev,
@@ -14565,8 +14567,7 @@ int nl80211_init(void)
 {
        int err;
 
-       err = genl_register_family_with_ops_groups(&nl80211_fam, nl80211_ops,
-                                                  nl80211_mcgrps);
+       err = genl_register_family(&nl80211_fam);
        if (err)
                return err;