};
static struct genl_family acpi_event_genl_family = {
- .id = GENL_ID_GENERATE,
.name = ACPI_GENL_FAMILY_NAME,
.version = ACPI_GENL_VERSION,
.maxattr = ACPI_GENL_ATTR_MAX,
}
static struct genl_family gtp_genl_family = {
- .id = GENL_ID_GENERATE,
.name = "gtp",
.version = 0,
.hdrsize = 0,
}
static struct genl_family macsec_fam = {
- .id = GENL_ID_GENERATE,
.name = MACSEC_GENL_NAME,
.hdrsize = 0,
.version = MACSEC_GENL_VERSION,
***********************************/
static struct genl_family team_nl_family = {
- .id = GENL_ID_GENERATE,
.name = TEAM_GENL_NAME,
.version = TEAM_GENL_VERSION,
.maxattr = TEAM_ATTR_MAX,
/* MAC80211_HWSIM netlinf family */
static struct genl_family hwsim_genl_family = {
- .id = GENL_ID_GENERATE,
.hdrsize = 0,
.name = "MAC80211_HWSIM",
.version = 1,
};
static struct genl_family pmcraid_event_family = {
- /*
- * Due to prior multicast group abuse (the code having assumed that
- * the family ID can be used as a multicast group ID) we need to
- * statically allocate a family (and thus group) ID.
- */
- .id = GENL_ID_PMCRAID,
.name = "pmcraid",
.version = 1,
.maxattr = PMCRAID_AEN_ATTR_MAX,
/* Our generic netlink family */
static struct genl_family tcmu_genl_family = {
- .id = GENL_ID_GENERATE,
.hdrsize = 0,
.name = "TCM-USER",
.version = 1,
};
static struct genl_family thermal_event_genl_family = {
- .id = GENL_ID_GENERATE,
.name = THERMAL_GENL_FAMILY_NAME,
.version = THERMAL_GENL_VERSION,
.maxattr = THERMAL_GENL_ATTR_MAX,
static uint32_t listener_nlportid;
static struct genl_family family = {
- .id = GENL_ID_GENERATE,
.name = DLM_GENL_NAME,
.version = DLM_GENL_VERSION,
};
/* Netlink family structure for quota */
static struct genl_family quota_genl_family = {
- /*
- * Needed due to multicast group ID abuse - old code assumed
- * the family ID was also a valid multicast group ID (which
- * isn't true) and userspace might thus rely on it. Assign a
- * static ID for this group to make dealing with that easier.
- */
- .id = GENL_ID_VFS_DQUOT,
.hdrsize = 0,
.name = "VFS_DQUOT",
.version = 1,
*/
#define ZZZ_genl_family CONCAT_(GENL_MAGIC_FAMILY, _genl_family)
static struct genl_family ZZZ_genl_family __read_mostly = {
- .id = GENL_ID_GENERATE,
.name = __stringify(GENL_MAGIC_FAMILY),
.version = GENL_MAGIC_VERSION,
#ifdef GENL_MAGIC_FAMILY_HDRSZ
/**
* struct genl_family - generic netlink family
- * @id: protocol family idenfitier
+ * @id: protocol family identifier (private)
* @hdrsize: length of user specific header in bytes
* @name: name of family
* @version: protocol version
* @n_ops: number of operations supported by this family (private)
*/
struct genl_family {
- unsigned int id;
+ unsigned int id; /* private */
unsigned int hdrsize;
char name[GENL_NAMSIZ];
unsigned int version;
* Registers the specified family and operations from the specified table.
* Only one family may be registered with the same family name or identifier.
*
- * The family id may equal GENL_ID_GENERATE causing an unique id to
- * be automatically generated and assigned.
- *
* 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.
/*
* List of reserved static generic netlink identifiers:
*/
-#define GENL_ID_GENERATE 0
#define GENL_ID_CTRL NLMSG_MIN_TYPE
#define GENL_ID_VFS_DQUOT (NLMSG_MIN_TYPE + 1)
#define GENL_ID_PMCRAID (NLMSG_MIN_TYPE + 2)
struct kmem_cache *taskstats_cache;
static struct genl_family family = {
- .id = GENL_ID_GENERATE,
.name = TASKSTATS_GENL_NAME,
.version = TASKSTATS_GENL_VERSION,
.maxattr = TASKSTATS_CMD_ATTR_MAX,
#include "translation-table.h"
struct genl_family batadv_netlink_family = {
- .id = GENL_ID_GENERATE,
.hdrsize = 0,
.name = BATADV_NL_NAME,
.version = 1,
}
static struct genl_family devlink_nl_family = {
- .id = GENL_ID_GENERATE,
.name = DEVLINK_GENL_NAME,
.version = DEVLINK_GENL_VERSION,
.maxattr = DEVLINK_ATTR_MAX,
};
static struct genl_family net_drop_monitor_family = {
- .id = GENL_ID_GENERATE,
.hdrsize = 0,
.name = "NET_DM",
.version = 2,
};
static struct genl_family hsr_genl_family = {
- .id = GENL_ID_GENERATE,
.hdrsize = 0,
.name = "HSR",
.version = 1,
static DEFINE_SPINLOCK(ieee802154_seq_lock);
struct genl_family nl802154_family = {
- .id = GENL_ID_GENERATE,
.hdrsize = 0,
.name = IEEE802154_NL_NAME,
.version = 1,
/* the netlink family */
static struct genl_family nl802154_fam = {
- .id = GENL_ID_GENERATE, /* don't bother with a hardcoded ID */
.name = NL802154_GENL_NAME, /* have users key off the name instead */
.hdrsize = 0, /* no private header */
.version = 1, /* no particular meaning now */
}
static struct genl_family fou_nl_family = {
- .id = GENL_ID_GENERATE,
.hdrsize = 0,
.name = FOU_GENL_NAME,
.version = FOU_GENL_VERSION,
}
static struct genl_family tcp_metrics_nl_family = {
- .id = GENL_ID_GENERATE,
.hdrsize = 0,
.name = TCP_METRICS_GENL_NAME,
.version = TCP_METRICS_GENL_VERSION,
};
static struct genl_family ila_nl_family = {
- .id = GENL_ID_GENERATE,
.hdrsize = 0,
.name = ILA_GENL_NAME,
.version = ILA_GENL_VERSION,
static struct genl_family irda_nl_family = {
- .id = GENL_ID_GENERATE,
.name = IRDA_NL_NAME,
.hdrsize = 0,
.version = IRDA_NL_VERSION,
static struct genl_family l2tp_nl_family = {
- .id = GENL_ID_GENERATE,
.name = L2TP_GENL_NAME,
.version = L2TP_GENL_VERSION,
.hdrsize = 0,
/* IPVS genetlink family */
static struct genl_family ip_vs_genl_family = {
- .id = GENL_ID_GENERATE,
.hdrsize = 0,
.name = IPVS_GENL_NAME,
.version = IPVS_GENL_VERSION,
/* NetLabel Generic NETLINK CALIPSO family */
static struct genl_family netlbl_calipso_gnl_family = {
- .id = GENL_ID_GENERATE,
.hdrsize = 0,
.name = NETLBL_NLTYPE_CALIPSO_NAME,
.version = NETLBL_PROTO_VERSION,
/* NetLabel Generic NETLINK CIPSOv4 family */
static struct genl_family netlbl_cipsov4_gnl_family = {
- .id = GENL_ID_GENERATE,
.hdrsize = 0,
.name = NETLBL_NLTYPE_CIPSOV4_NAME,
.version = NETLBL_PROTO_VERSION,
/* NetLabel Generic NETLINK CIPSOv4 family */
static struct genl_family netlbl_mgmt_gnl_family = {
- .id = GENL_ID_GENERATE,
.hdrsize = 0,
.name = NETLBL_NLTYPE_MGMT_NAME,
.version = NETLBL_PROTO_VERSION,
/* NetLabel Generic NETLINK unlabeled family */
static struct genl_family netlbl_unlabel_gnl_family = {
- .id = GENL_ID_GENERATE,
.hdrsize = 0,
.name = NETLBL_NLTYPE_UNLABELED_NAME,
.version = NETLBL_PROTO_VERSION,
*
* Registers the specified family after validating it first. Only one
* family may be registered with the same family name or identifier.
- * The family id may equal GENL_ID_GENERATE causing an unique id to
- * be automatically generated and assigned.
*
* The family's ops array must already be assigned, you can use the
* genl_register_family_with_ops() helper function.
*/
int __genl_register_family(struct genl_family *family)
{
- int err = -EINVAL, i;
-
- if (family->id && family->id < GENL_MIN_ID)
- goto errout;
-
- if (family->id > GENL_MAX_ID)
- goto errout;
+ int err, i;
err = genl_validate_ops(family);
if (err)
goto errout_locked;
}
- if (family->id == GENL_ID_GENERATE) {
- u16 newid = genl_generate_id();
+ if (family == &genl_ctrl) {
+ family->id = GENL_ID_CTRL;
+ } else {
+ u16 newid;
+
+ /* this should be left zero in the struct */
+ WARN_ON(family->id);
+
+ /*
+ * Sadly, a few cases need to be special-cased
+ * due to them having previously abused the API
+ * and having used their family ID also as their
+ * multicast group ID, so we use reserved IDs
+ * for both to be sure we can do that mapping.
+ */
+ if (strcmp(family->name, "pmcraid") == 0)
+ newid = GENL_ID_PMCRAID;
+ else if (strcmp(family->name, "VFS_DQUOT") == 0)
+ newid = GENL_ID_VFS_DQUOT;
+ else
+ newid = genl_generate_id();
if (!newid) {
err = -ENOMEM;
}
family->id = newid;
- } else if (genl_family_find_byid(family->id)) {
- err = -EEXIST;
- goto errout_locked;
}
if (family->maxattr && !family->parallel_ops) {
errout_locked:
genl_unlock_all();
-errout:
return err;
}
EXPORT_SYMBOL(__genl_register_family);
};
static struct genl_family nfc_genl_family = {
- .id = GENL_ID_GENERATE,
.hdrsize = 0,
.name = NFC_GENL_NAME,
.version = NFC_GENL_VERSION,
};
static struct genl_family dp_packet_genl_family = {
- .id = GENL_ID_GENERATE,
.hdrsize = sizeof(struct ovs_header),
.name = OVS_PACKET_FAMILY,
.version = OVS_PACKET_VERSION,
};
static struct genl_family dp_flow_genl_family = {
- .id = GENL_ID_GENERATE,
.hdrsize = sizeof(struct ovs_header),
.name = OVS_FLOW_FAMILY,
.version = OVS_FLOW_VERSION,
};
static struct genl_family dp_datapath_genl_family = {
- .id = GENL_ID_GENERATE,
.hdrsize = sizeof(struct ovs_header),
.name = OVS_DATAPATH_FAMILY,
.version = OVS_DATAPATH_VERSION,
};
struct genl_family dp_vport_genl_family = {
- .id = GENL_ID_GENERATE,
.hdrsize = sizeof(struct ovs_header),
.name = OVS_VPORT_FAMILY,
.version = OVS_VPORT_VERSION,
* so we have a separate genl handling for the new API.
*/
struct genl_family tipc_genl_family = {
- .id = GENL_ID_GENERATE,
.name = TIPC_GENL_V2_NAME,
.version = TIPC_GENL_V2_VERSION,
.hdrsize = 0,
}
static struct genl_family tipc_genl_compat_family = {
- .id = GENL_ID_GENERATE,
.name = TIPC_GENL_NAME,
.version = TIPC_GENL_VERSION,
.hdrsize = TIPC_GENL_HDRLEN,
struct genl_family wimax_gnl_family = {
- .id = GENL_ID_GENERATE,
.name = "WiMAX",
.version = WIMAX_GNL_VERSION,
.hdrsize = 0,
/* the netlink family */
static struct genl_family nl80211_fam = {
- .id = GENL_ID_GENERATE, /* don't bother with a hardcoded ID */
.name = NL80211_GENL_NAME, /* have users key off the name instead */
.hdrsize = 0, /* no private header */
.version = 1, /* no particular meaning now */