drbd: replace genl_magic with explicit netlink serialization

Replace the genl_magic multi-include macro system with explicit
serialization and parsing.

The *_gen files were initially produced from a YNL spec via a
customized ynl-gen-c, but the DRBD netlink family is effectively
frozen, so the generator is kept unmodified.
All new functionality will land in a separate, properly-designed
family.
Carry the resulting code as ordinary in-tree source rather than
landing the spec and generator changes that produced it.

The bulk of the changes are mechanical renames to fit the YNL naming
conventions:
  - Handler functions: drbd_adm_* -> drbd_nl_*_doit/dumpit
  - GENL_MAGIC_VERSION -> DRBD_FAMILY_VERSION
  - GENL_MAGIC_FAMILY_HDRSZ -> sizeof(struct drbd_genlmsghdr)
  - drbd_genl_family -> drbd_nl_family
  - Attribute IDs: T_* -> DRBD_A_*

Remove the nested_attr_tb static global buffer and move to a per-call
allocation approach: each deserialization manages its own nested
attribute table. This will be needed anyway when we eventually move
to parallel_ops, and it's actually simpler this way, so make the
move now.

Replace the functionality of the "sensitive" flag: this was only used
by a single field (shared_secret); open-code redaction logic for that
locally.

Also replace the "invariant" flag: this only had a couple of users,
and those basically never change. Hard code the check directly inline.

The genl_family struct itself is defined manually in drbd_nl.c.

Also replace a couple of drbd-specific wrappers (nla_put_u64_0pad,
drbd_nla_find_nested) with standard kernel functions while we're at
it.

Finally, completely remove the genl_magic system; DRBD was its only
user.

Signed-off-by: Christoph Böhmwalder <christoph.boehmwalder@linbit.com>
Acked-by: Jakub Kicinski <kuba@kernel.org>
Link: https://patch.msgid.link/20260506124541.1951772-3-christoph.boehmwalder@linbit.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
Christoph Böhmwalder
2026-05-08 19:23:23 -06:00
committed by Jens Axboe
parent a54f499838
commit 8098eeb693
14 changed files with 3608 additions and 1421 deletions
+1
View File
@@ -3,6 +3,7 @@ drbd-y := drbd_buildtag.o drbd_bitmap.o drbd_proc.o
drbd-y += drbd_worker.o drbd_receiver.o drbd_req.o drbd_actlog.o
drbd-y += drbd_main.o drbd_strings.o drbd_nl.o
drbd-y += drbd_interval.o drbd_state.o
drbd-y += drbd_nl_gen.o
drbd-$(CONFIG_DEBUG_FS) += drbd_debugfs.o
obj-$(CONFIG_BLK_DEV_DRBD) += drbd.o
+1 -1
View File
@@ -844,7 +844,7 @@ static int drbd_version_show(struct seq_file *m, void *ignored)
{
seq_printf(m, "# %s\n", drbd_buildtag());
seq_printf(m, "VERSION=%s\n", REL_VERSION);
seq_printf(m, "API_VERSION=%u\n", GENL_MAGIC_VERSION);
seq_printf(m, "API_VERSION=%u\n", DRBD_FAMILY_VERSION);
seq_printf(m, "PRO_VERSION_MIN=%u\n", PRO_VERSION_MIN);
seq_printf(m, "PRO_VERSION_MAX=%u\n", PRO_VERSION_MAX);
return 0;
+3 -1
View File
@@ -32,14 +32,16 @@
#include <net/tcp.h>
#include <linux/lru_cache.h>
#include <linux/prefetch.h>
#include <linux/drbd_genl_api.h>
#include <linux/drbd.h>
#include "drbd_config.h"
#include "drbd_nl_gen.h"
#include "drbd_strings.h"
#include "drbd_state.h"
#include "drbd_protocol.h"
#include "drbd_polymorph_printk.h"
extern struct genl_family drbd_nl_family;
/* shared module parameters, defined in drbd_main.c */
#ifdef CONFIG_DRBD_FAULT_INJECTION
extern int drbd_enable_faults;
+3 -3
View File
@@ -2324,7 +2324,7 @@ static void drbd_cleanup(void)
if (retry.wq)
destroy_workqueue(retry.wq);
drbd_genl_unregister();
genl_unregister_family(&drbd_nl_family);
idr_for_each_entry(&drbd_devices, device, i)
drbd_delete_device(device);
@@ -2846,7 +2846,7 @@ static int __init drbd_init(void)
mutex_init(&resources_mutex);
INIT_LIST_HEAD(&drbd_resources);
err = drbd_genl_register();
err = genl_register_family(&drbd_nl_family);
if (err) {
pr_err("unable to register generic netlink family\n");
goto fail;
@@ -2876,7 +2876,7 @@ static int __init drbd_init(void)
pr_info("initialized. "
"Version: " REL_VERSION " (api:%d/proto:%d-%d)\n",
GENL_MAGIC_VERSION, PRO_VERSION_MIN, PRO_VERSION_MAX);
DRBD_FAMILY_VERSION, PRO_VERSION_MIN, PRO_VERSION_MAX);
pr_info("%s\n", drbd_buildtag());
pr_info("registered as block device major %d\n", DRBD_MAJOR);
return 0; /* Success! */
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+395
View File
@@ -0,0 +1,395 @@
/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */
#ifndef _LINUX_DRBD_GEN_H
#define _LINUX_DRBD_GEN_H
#include <net/netlink.h>
#include <net/genetlink.h>
#include <uapi/linux/drbd_genl.h>
#include <linux/drbd.h>
#include <linux/drbd_limits.h>
/* Common nested types */
extern const struct nla_policy drbd_connection_info_nl_policy[DRBD_A_CONNECTION_INFO_CONN_ROLE + 1];
extern const struct nla_policy drbd_connection_statistics_nl_policy[DRBD_A_CONNECTION_STATISTICS_CONN_CONGESTED + 1];
extern const struct nla_policy drbd_detach_parms_nl_policy[DRBD_A_DETACH_PARMS_FORCE_DETACH + 1];
extern const struct nla_policy drbd_device_info_nl_policy[DRBD_A_DEVICE_INFO_DEV_DISK_STATE + 1];
extern const struct nla_policy drbd_device_statistics_nl_policy[DRBD_A_DEVICE_STATISTICS_HISTORY_UUIDS + 1];
extern const struct nla_policy drbd_disconnect_parms_nl_policy[DRBD_A_DISCONNECT_PARMS_FORCE_DISCONNECT + 1];
extern const struct nla_policy drbd_disk_conf_nl_policy[DRBD_A_DISK_CONF_DISABLE_WRITE_SAME + 1];
extern const struct nla_policy drbd_drbd_cfg_context_nl_policy[DRBD_A_DRBD_CFG_CONTEXT_CTX_PEER_ADDR + 1];
extern const struct nla_policy drbd_net_conf_nl_policy[DRBD_A_NET_CONF_SOCK_CHECK_TIMEO + 1];
extern const struct nla_policy drbd_new_c_uuid_parms_nl_policy[DRBD_A_NEW_C_UUID_PARMS_CLEAR_BM + 1];
extern const struct nla_policy drbd_peer_device_info_nl_policy[DRBD_A_PEER_DEVICE_INFO_PEER_RESYNC_SUSP_DEPENDENCY + 1];
extern const struct nla_policy drbd_peer_device_statistics_nl_policy[DRBD_A_PEER_DEVICE_STATISTICS_PEER_DEV_FLAGS + 1];
extern const struct nla_policy drbd_res_opts_nl_policy[DRBD_A_RES_OPTS_ON_NO_DATA + 1];
extern const struct nla_policy drbd_resize_parms_nl_policy[DRBD_A_RESIZE_PARMS_AL_STRIPE_SIZE + 1];
extern const struct nla_policy drbd_resource_info_nl_policy[DRBD_A_RESOURCE_INFO_RES_SUSP_FEN + 1];
extern const struct nla_policy drbd_resource_statistics_nl_policy[DRBD_A_RESOURCE_STATISTICS_RES_STAT_WRITE_ORDERING + 1];
extern const struct nla_policy drbd_set_role_parms_nl_policy[DRBD_A_SET_ROLE_PARMS_ASSUME_UPTODATE + 1];
extern const struct nla_policy drbd_start_ov_parms_nl_policy[DRBD_A_START_OV_PARMS_OV_STOP_SECTOR + 1];
/* Ops table for drbd */
extern const struct genl_split_ops drbd_nl_ops[32];
int drbd_pre_doit(const struct genl_split_ops *ops, struct sk_buff *skb,
struct genl_info *info);
void
drbd_post_doit(const struct genl_split_ops *ops, struct sk_buff *skb,
struct genl_info *info);
int drbd_adm_dump_devices_done(struct netlink_callback *cb);
int drbd_adm_dump_connections_done(struct netlink_callback *cb);
int drbd_adm_dump_peer_devices_done(struct netlink_callback *cb);
int drbd_nl_get_status_doit(struct sk_buff *skb, struct genl_info *info);
int drbd_nl_get_status_dumpit(struct sk_buff *skb, struct netlink_callback *cb);
int drbd_nl_new_minor_doit(struct sk_buff *skb, struct genl_info *info);
int drbd_nl_del_minor_doit(struct sk_buff *skb, struct genl_info *info);
int drbd_nl_new_resource_doit(struct sk_buff *skb, struct genl_info *info);
int drbd_nl_del_resource_doit(struct sk_buff *skb, struct genl_info *info);
int drbd_nl_resource_opts_doit(struct sk_buff *skb, struct genl_info *info);
int drbd_nl_connect_doit(struct sk_buff *skb, struct genl_info *info);
int drbd_nl_disconnect_doit(struct sk_buff *skb, struct genl_info *info);
int drbd_nl_attach_doit(struct sk_buff *skb, struct genl_info *info);
int drbd_nl_resize_doit(struct sk_buff *skb, struct genl_info *info);
int drbd_nl_primary_doit(struct sk_buff *skb, struct genl_info *info);
int drbd_nl_secondary_doit(struct sk_buff *skb, struct genl_info *info);
int drbd_nl_new_c_uuid_doit(struct sk_buff *skb, struct genl_info *info);
int drbd_nl_start_ov_doit(struct sk_buff *skb, struct genl_info *info);
int drbd_nl_detach_doit(struct sk_buff *skb, struct genl_info *info);
int drbd_nl_invalidate_doit(struct sk_buff *skb, struct genl_info *info);
int drbd_nl_inval_peer_doit(struct sk_buff *skb, struct genl_info *info);
int drbd_nl_pause_sync_doit(struct sk_buff *skb, struct genl_info *info);
int drbd_nl_resume_sync_doit(struct sk_buff *skb, struct genl_info *info);
int drbd_nl_suspend_io_doit(struct sk_buff *skb, struct genl_info *info);
int drbd_nl_resume_io_doit(struct sk_buff *skb, struct genl_info *info);
int drbd_nl_outdate_doit(struct sk_buff *skb, struct genl_info *info);
int drbd_nl_get_timeout_type_doit(struct sk_buff *skb, struct genl_info *info);
int drbd_nl_down_doit(struct sk_buff *skb, struct genl_info *info);
int drbd_nl_chg_disk_opts_doit(struct sk_buff *skb, struct genl_info *info);
int drbd_nl_chg_net_opts_doit(struct sk_buff *skb, struct genl_info *info);
int drbd_nl_get_resources_dumpit(struct sk_buff *skb,
struct netlink_callback *cb);
int drbd_nl_get_devices_dumpit(struct sk_buff *skb,
struct netlink_callback *cb);
int drbd_nl_get_connections_dumpit(struct sk_buff *skb,
struct netlink_callback *cb);
int drbd_nl_get_peer_devices_dumpit(struct sk_buff *skb,
struct netlink_callback *cb);
int drbd_nl_get_initial_state_dumpit(struct sk_buff *skb,
struct netlink_callback *cb);
enum {
DRBD_NLGRP_EVENTS,
};
struct drbd_cfg_reply {
char info_text[0];
__u32 info_text_len;
};
struct drbd_cfg_context {
__u32 ctx_volume;
char ctx_resource_name[128];
__u32 ctx_resource_name_len;
char ctx_my_addr[128];
__u32 ctx_my_addr_len;
char ctx_peer_addr[128];
__u32 ctx_peer_addr_len;
};
struct disk_conf {
char backing_dev[128];
__u32 backing_dev_len;
char meta_dev[128];
__u32 meta_dev_len;
__s32 meta_dev_idx;
__u64 disk_size;
__u32 max_bio_bvecs;
__u32 on_io_error;
__u32 fencing;
__u32 resync_rate;
__s32 resync_after;
__u32 al_extents;
__u32 c_plan_ahead;
__u32 c_delay_target;
__u32 c_fill_target;
__u32 c_max_rate;
__u32 c_min_rate;
unsigned char disk_barrier;
unsigned char disk_flushes;
unsigned char disk_drain;
unsigned char md_flushes;
__u32 disk_timeout;
__u32 read_balancing;
unsigned char al_updates;
unsigned char discard_zeroes_if_aligned;
__u32 rs_discard_granularity;
unsigned char disable_write_same;
};
struct res_opts {
char cpu_mask[DRBD_CPU_MASK_SIZE];
__u32 cpu_mask_len;
__u32 on_no_data;
};
struct net_conf {
char shared_secret[SHARED_SECRET_MAX];
__u32 shared_secret_len;
char cram_hmac_alg[SHARED_SECRET_MAX];
__u32 cram_hmac_alg_len;
char integrity_alg[SHARED_SECRET_MAX];
__u32 integrity_alg_len;
char verify_alg[SHARED_SECRET_MAX];
__u32 verify_alg_len;
char csums_alg[SHARED_SECRET_MAX];
__u32 csums_alg_len;
__u32 wire_protocol;
__u32 connect_int;
__u32 timeout;
__u32 ping_int;
__u32 ping_timeo;
__u32 sndbuf_size;
__u32 rcvbuf_size;
__u32 ko_count;
__u32 max_buffers;
__u32 max_epoch_size;
__u32 unplug_watermark;
__u32 after_sb_0p;
__u32 after_sb_1p;
__u32 after_sb_2p;
__u32 rr_conflict;
__u32 on_congestion;
__u32 cong_fill;
__u32 cong_extents;
unsigned char two_primaries;
unsigned char discard_my_data;
unsigned char tcp_cork;
unsigned char always_asbp;
unsigned char tentative;
unsigned char use_rle;
unsigned char csums_after_crash_only;
__u32 sock_check_timeo;
};
struct set_role_parms {
unsigned char assume_uptodate;
};
struct resize_parms {
__u64 resize_size;
unsigned char resize_force;
unsigned char no_resync;
__u32 al_stripes;
__u32 al_stripe_size;
};
struct state_info {
__u32 sib_reason;
__u32 current_state;
__u64 capacity;
__u64 ed_uuid;
__u32 prev_state;
__u32 new_state;
char uuids[DRBD_NL_UUIDS_SIZE];
__u32 uuids_len;
__u32 disk_flags;
__u64 bits_total;
__u64 bits_oos;
__u64 bits_rs_total;
__u64 bits_rs_failed;
char helper[32];
__u32 helper_len;
__u32 helper_exit_code;
__u64 send_cnt;
__u64 recv_cnt;
__u64 read_cnt;
__u64 writ_cnt;
__u64 al_writ_cnt;
__u64 bm_writ_cnt;
__u32 ap_bio_cnt;
__u32 ap_pending_cnt;
__u32 rs_pending_cnt;
};
struct start_ov_parms {
__u64 ov_start_sector;
__u64 ov_stop_sector;
};
struct new_c_uuid_parms {
unsigned char clear_bm;
};
struct timeout_parms {
__u32 timeout_type;
};
struct disconnect_parms {
unsigned char force_disconnect;
};
struct detach_parms {
unsigned char force_detach;
};
struct resource_info {
__u32 res_role;
unsigned char res_susp;
unsigned char res_susp_nod;
unsigned char res_susp_fen;
};
struct device_info {
__u32 dev_disk_state;
};
struct connection_info {
__u32 conn_connection_state;
__u32 conn_role;
};
struct peer_device_info {
__u32 peer_repl_state;
__u32 peer_disk_state;
__u32 peer_resync_susp_user;
__u32 peer_resync_susp_peer;
__u32 peer_resync_susp_dependency;
};
struct resource_statistics {
__u32 res_stat_write_ordering;
};
struct device_statistics {
__u64 dev_size;
__u64 dev_read;
__u64 dev_write;
__u64 dev_al_writes;
__u64 dev_bm_writes;
__u32 dev_upper_pending;
__u32 dev_lower_pending;
unsigned char dev_upper_blocked;
unsigned char dev_lower_blocked;
unsigned char dev_al_suspended;
__u64 dev_exposed_data_uuid;
__u64 dev_current_uuid;
__u32 dev_disk_flags;
char history_uuids[DRBD_NL_HISTORY_UUIDS_SIZE];
__u32 history_uuids_len;
};
struct connection_statistics {
unsigned char conn_congested;
};
struct peer_device_statistics {
__u64 peer_dev_received;
__u64 peer_dev_sent;
__u32 peer_dev_pending;
__u32 peer_dev_unacked;
__u64 peer_dev_out_of_sync;
__u64 peer_dev_resync_failed;
__u64 peer_dev_bitmap_uuid;
__u32 peer_dev_flags;
};
struct drbd_notification_header {
__u32 nh_type;
};
struct drbd_helper_info {
char helper_name[32];
__u32 helper_name_len;
__u32 helper_status;
};
int drbd_cfg_reply_to_skb(struct sk_buff *skb, struct drbd_cfg_reply *s);
int drbd_cfg_context_from_attrs(struct drbd_cfg_context *s, struct genl_info *info);
int drbd_cfg_context_ntb_from_attrs(struct nlattr ***ret_nested_attribute_table, struct genl_info *info);
int drbd_cfg_context_to_skb(struct sk_buff *skb, struct drbd_cfg_context *s);
int disk_conf_from_attrs(struct disk_conf *s, struct genl_info *info);
int disk_conf_ntb_from_attrs(struct nlattr ***ret_nested_attribute_table, struct genl_info *info);
int disk_conf_to_skb(struct sk_buff *skb, struct disk_conf *s);
void set_disk_conf_defaults(struct disk_conf *x);
int res_opts_from_attrs(struct res_opts *s, struct genl_info *info);
int res_opts_ntb_from_attrs(struct nlattr ***ret_nested_attribute_table, struct genl_info *info);
int res_opts_to_skb(struct sk_buff *skb, struct res_opts *s);
void set_res_opts_defaults(struct res_opts *x);
int net_conf_from_attrs(struct net_conf *s, struct genl_info *info);
int net_conf_ntb_from_attrs(struct nlattr ***ret_nested_attribute_table, struct genl_info *info);
int net_conf_to_skb(struct sk_buff *skb, struct net_conf *s);
void set_net_conf_defaults(struct net_conf *x);
int set_role_parms_from_attrs(struct set_role_parms *s, struct genl_info *info);
int set_role_parms_ntb_from_attrs(struct nlattr ***ret_nested_attribute_table, struct genl_info *info);
int set_role_parms_to_skb(struct sk_buff *skb, struct set_role_parms *s);
int resize_parms_from_attrs(struct resize_parms *s, struct genl_info *info);
int resize_parms_ntb_from_attrs(struct nlattr ***ret_nested_attribute_table, struct genl_info *info);
int resize_parms_to_skb(struct sk_buff *skb, struct resize_parms *s);
void set_resize_parms_defaults(struct resize_parms *x);
int state_info_to_skb(struct sk_buff *skb, struct state_info *s);
int start_ov_parms_from_attrs(struct start_ov_parms *s, struct genl_info *info);
int start_ov_parms_ntb_from_attrs(struct nlattr ***ret_nested_attribute_table, struct genl_info *info);
int start_ov_parms_to_skb(struct sk_buff *skb, struct start_ov_parms *s);
int new_c_uuid_parms_from_attrs(struct new_c_uuid_parms *s, struct genl_info *info);
int new_c_uuid_parms_ntb_from_attrs(struct nlattr ***ret_nested_attribute_table, struct genl_info *info);
int new_c_uuid_parms_to_skb(struct sk_buff *skb, struct new_c_uuid_parms *s);
int timeout_parms_to_skb(struct sk_buff *skb, struct timeout_parms *s);
int disconnect_parms_from_attrs(struct disconnect_parms *s, struct genl_info *info);
int disconnect_parms_ntb_from_attrs(struct nlattr ***ret_nested_attribute_table, struct genl_info *info);
int disconnect_parms_to_skb(struct sk_buff *skb, struct disconnect_parms *s);
int detach_parms_from_attrs(struct detach_parms *s, struct genl_info *info);
int detach_parms_ntb_from_attrs(struct nlattr ***ret_nested_attribute_table, struct genl_info *info);
int detach_parms_to_skb(struct sk_buff *skb, struct detach_parms *s);
int resource_info_from_attrs(struct resource_info *s, struct genl_info *info);
int resource_info_ntb_from_attrs(struct nlattr ***ret_nested_attribute_table, struct genl_info *info);
int resource_info_to_skb(struct sk_buff *skb, struct resource_info *s);
int device_info_from_attrs(struct device_info *s, struct genl_info *info);
int device_info_ntb_from_attrs(struct nlattr ***ret_nested_attribute_table, struct genl_info *info);
int device_info_to_skb(struct sk_buff *skb, struct device_info *s);
int connection_info_from_attrs(struct connection_info *s, struct genl_info *info);
int connection_info_ntb_from_attrs(struct nlattr ***ret_nested_attribute_table, struct genl_info *info);
int connection_info_to_skb(struct sk_buff *skb, struct connection_info *s);
int peer_device_info_from_attrs(struct peer_device_info *s, struct genl_info *info);
int peer_device_info_ntb_from_attrs(struct nlattr ***ret_nested_attribute_table, struct genl_info *info);
int peer_device_info_to_skb(struct sk_buff *skb, struct peer_device_info *s);
int resource_statistics_from_attrs(struct resource_statistics *s, struct genl_info *info);
int resource_statistics_ntb_from_attrs(struct nlattr ***ret_nested_attribute_table, struct genl_info *info);
int resource_statistics_to_skb(struct sk_buff *skb, struct resource_statistics *s);
int device_statistics_from_attrs(struct device_statistics *s, struct genl_info *info);
int device_statistics_ntb_from_attrs(struct nlattr ***ret_nested_attribute_table, struct genl_info *info);
int device_statistics_to_skb(struct sk_buff *skb, struct device_statistics *s);
int connection_statistics_from_attrs(struct connection_statistics *s, struct genl_info *info);
int connection_statistics_ntb_from_attrs(struct nlattr ***ret_nested_attribute_table, struct genl_info *info);
int connection_statistics_to_skb(struct sk_buff *skb, struct connection_statistics *s);
int peer_device_statistics_from_attrs(struct peer_device_statistics *s, struct genl_info *info);
int peer_device_statistics_ntb_from_attrs(struct nlattr ***ret_nested_attribute_table, struct genl_info *info);
int peer_device_statistics_to_skb(struct sk_buff *skb, struct peer_device_statistics *s);
int drbd_notification_header_to_skb(struct sk_buff *skb, struct drbd_notification_header *s);
int drbd_helper_info_to_skb(struct sk_buff *skb, struct drbd_helper_info *s);
#endif /* _LINUX_DRBD_GEN_H */
+1 -1
View File
@@ -228,7 +228,7 @@ int drbd_seq_show(struct seq_file *seq, void *v)
};
seq_printf(seq, "version: " REL_VERSION " (api:%d/proto:%d-%d)\n%s\n",
GENL_MAGIC_VERSION, PRO_VERSION_MIN, PRO_VERSION_MAX, drbd_buildtag());
DRBD_FAMILY_VERSION, PRO_VERSION_MIN, PRO_VERSION_MAX, drbd_buildtag());
/*
cs .. connection state
File diff suppressed because it is too large Load Diff
-16
View File
@@ -1,16 +0,0 @@
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef DRBD_GENL_STRUCT_H
#define DRBD_GENL_STRUCT_H
/* hack around predefined gcc/cpp "linux=1",
* we cannot possibly include <1/drbd_genl.h> */
#undef linux
#include <linux/drbd.h>
#define GENL_MAGIC_VERSION 1
#define GENL_MAGIC_FAMILY drbd
#define GENL_MAGIC_FAMILY_HDRSZ sizeof(struct drbd_genlmsghdr)
#define GENL_MAGIC_INCLUDE_FILE <linux/drbd_genl.h>
#include <linux/genl_magic_struct.h>
#endif
-413
View File
@@ -1,413 +0,0 @@
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef GENL_MAGIC_FUNC_H
#define GENL_MAGIC_FUNC_H
#include <linux/args.h>
#include <linux/build_bug.h>
#include <linux/genl_magic_struct.h>
/*
* Magic: declare tla policy {{{1
* Magic: declare nested policies
* {{{2
*/
#undef GENL_mc_group
#define GENL_mc_group(group)
#undef GENL_notification
#define GENL_notification(op_name, op_num, mcast_group, tla_list)
#undef GENL_op
#define GENL_op(op_name, op_num, handler, tla_list)
#undef GENL_struct
#define GENL_struct(tag_name, tag_number, s_name, s_fields) \
[tag_name] = { .type = NLA_NESTED },
static struct nla_policy CONCATENATE(GENL_MAGIC_FAMILY, _tla_nl_policy)[] = {
#include GENL_MAGIC_INCLUDE_FILE
};
#undef GENL_struct
#define GENL_struct(tag_name, tag_number, s_name, s_fields) \
static struct nla_policy s_name ## _nl_policy[] __read_mostly = \
{ s_fields };
#undef __field
#define __field(attr_nr, attr_flag, name, nla_type, _type, __get, \
__put, __is_signed) \
[attr_nr] = { .type = nla_type },
#undef __array
#define __array(attr_nr, attr_flag, name, nla_type, _type, maxlen, \
__get, __put, __is_signed) \
[attr_nr] = { .type = nla_type, \
.len = maxlen - (nla_type == NLA_NUL_STRING) },
#include GENL_MAGIC_INCLUDE_FILE
#ifndef __KERNEL__
#ifndef pr_info
#define pr_info(args...) fprintf(stderr, args);
#endif
#endif
#ifdef GENL_MAGIC_DEBUG
static void dprint_field(const char *dir, int nla_type,
const char *name, void *valp)
{
__u64 val = valp ? *(__u32 *)valp : 1;
switch (nla_type) {
case NLA_U8: val = (__u8)val;
case NLA_U16: val = (__u16)val;
case NLA_U32: val = (__u32)val;
pr_info("%s attr %s: %d 0x%08x\n", dir,
name, (int)val, (unsigned)val);
break;
case NLA_U64:
val = *(__u64*)valp;
pr_info("%s attr %s: %lld 0x%08llx\n", dir,
name, (long long)val, (unsigned long long)val);
break;
case NLA_FLAG:
if (val)
pr_info("%s attr %s: set\n", dir, name);
break;
}
}
static void dprint_array(const char *dir, int nla_type,
const char *name, const char *val, unsigned len)
{
switch (nla_type) {
case NLA_NUL_STRING:
if (len && val[len-1] == '\0')
len--;
pr_info("%s attr %s: [len:%u] '%s'\n", dir, name, len, val);
break;
default:
/* we can always show 4 byte,
* thats what nlattr are aligned to. */
pr_info("%s attr %s: [len:%u] %02x%02x%02x%02x ...\n",
dir, name, len, val[0], val[1], val[2], val[3]);
}
}
#define DPRINT_TLA(a, op, b) pr_info("%s %s %s\n", a, op, b);
/* Name is a member field name of the struct s.
* If s is NULL (only parsing, no copy requested in *_from_attrs()),
* nla is supposed to point to the attribute containing the information
* corresponding to that struct member. */
#define DPRINT_FIELD(dir, nla_type, name, s, nla) \
do { \
if (s) \
dprint_field(dir, nla_type, #name, &s->name); \
else if (nla) \
dprint_field(dir, nla_type, #name, \
(nla_type == NLA_FLAG) ? NULL \
: nla_data(nla)); \
} while (0)
#define DPRINT_ARRAY(dir, nla_type, name, s, nla) \
do { \
if (s) \
dprint_array(dir, nla_type, #name, \
s->name, s->name ## _len); \
else if (nla) \
dprint_array(dir, nla_type, #name, \
nla_data(nla), nla_len(nla)); \
} while (0)
#else
#define DPRINT_TLA(a, op, b) do {} while (0)
#define DPRINT_FIELD(dir, nla_type, name, s, nla) do {} while (0)
#define DPRINT_ARRAY(dir, nla_type, name, s, nla) do {} while (0)
#endif
/*
* Magic: provide conversion functions {{{1
* populate struct from attribute table:
* {{{2
*/
/* processing of generic netlink messages is serialized.
* use one static buffer for parsing of nested attributes */
static struct nlattr *nested_attr_tb[128];
#undef GENL_struct
#define GENL_struct(tag_name, tag_number, s_name, s_fields) \
/* *_from_attrs functions are static, but potentially unused */ \
static int __ ## s_name ## _from_attrs(struct s_name *s, \
struct genl_info *info, bool exclude_invariants) \
{ \
const int maxtype = ARRAY_SIZE(s_name ## _nl_policy)-1; \
struct nlattr *tla = info->attrs[tag_number]; \
struct nlattr **ntb = nested_attr_tb; \
struct nlattr *nla; \
int err; \
BUILD_BUG_ON(ARRAY_SIZE(s_name ## _nl_policy) > ARRAY_SIZE(nested_attr_tb)); \
if (!tla) \
return -ENOMSG; \
DPRINT_TLA(#s_name, "<=-", #tag_name); \
err = nla_parse_nested_deprecated(ntb, maxtype, tla, \
s_name ## _nl_policy, NULL); \
if (err) \
return err; \
\
s_fields \
return 0; \
} __attribute__((unused)) \
static int s_name ## _from_attrs(struct s_name *s, \
struct genl_info *info) \
{ \
return __ ## s_name ## _from_attrs(s, info, false); \
} __attribute__((unused)) \
static int s_name ## _from_attrs_for_change(struct s_name *s, \
struct genl_info *info) \
{ \
return __ ## s_name ## _from_attrs(s, info, true); \
} __attribute__((unused)) \
#define __assign(attr_nr, attr_flag, name, nla_type, type, assignment...) \
nla = ntb[attr_nr]; \
if (nla) { \
if (exclude_invariants && !!((attr_flag) & DRBD_F_INVARIANT)) { \
pr_info("<< must not change invariant attr: %s\n", #name); \
return -EEXIST; \
} \
assignment; \
} else if (exclude_invariants && !!((attr_flag) & DRBD_F_INVARIANT)) { \
/* attribute missing from payload, */ \
/* which was expected */ \
} else if ((attr_flag) & DRBD_F_REQUIRED) { \
pr_info("<< missing attr: %s\n", #name); \
return -ENOMSG; \
}
#undef __field
#define __field(attr_nr, attr_flag, name, nla_type, type, __get, __put, \
__is_signed) \
__assign(attr_nr, attr_flag, name, nla_type, type, \
if (s) \
s->name = __get(nla); \
DPRINT_FIELD("<<", nla_type, name, s, nla))
/* validate_nla() already checked nla_len <= maxlen appropriately. */
#undef __array
#define __array(attr_nr, attr_flag, name, nla_type, type, maxlen, \
__get, __put, __is_signed) \
__assign(attr_nr, attr_flag, name, nla_type, type, \
if (s) \
s->name ## _len = \
__get(s->name, nla, maxlen); \
DPRINT_ARRAY("<<", nla_type, name, s, nla))
#include GENL_MAGIC_INCLUDE_FILE
#undef GENL_struct
#define GENL_struct(tag_name, tag_number, s_name, s_fields)
/*
* Magic: define op number to op name mapping {{{1
* {{{2
*/
static const char *CONCATENATE(GENL_MAGIC_FAMILY, _genl_cmd_to_str)(__u8 cmd)
{
switch (cmd) {
#undef GENL_op
#define GENL_op(op_name, op_num, handler, tla_list) \
case op_num: return #op_name;
#include GENL_MAGIC_INCLUDE_FILE
default:
return "unknown";
}
}
#ifdef __KERNEL__
#include <linux/stringify.h>
/*
* Magic: define genl_ops {{{1
* {{{2
*/
#undef GENL_op
#define GENL_op(op_name, op_num, handler, tla_list) \
{ \
handler \
.cmd = op_name, \
},
#define ZZZ_genl_ops CONCATENATE(GENL_MAGIC_FAMILY, _genl_ops)
static struct genl_ops ZZZ_genl_ops[] __read_mostly = {
#include GENL_MAGIC_INCLUDE_FILE
};
#undef GENL_op
#define GENL_op(op_name, op_num, handler, tla_list)
/*
* Define the genl_family, multicast groups, {{{1
* and provide register/unregister functions.
* {{{2
*/
#define ZZZ_genl_family CONCATENATE(GENL_MAGIC_FAMILY, _genl_family)
static struct genl_family ZZZ_genl_family;
/*
* Magic: define multicast groups
* Magic: define multicast group registration helper
*/
#define ZZZ_genl_mcgrps CONCATENATE(GENL_MAGIC_FAMILY, _genl_mcgrps)
static const struct genl_multicast_group ZZZ_genl_mcgrps[] = {
#undef GENL_mc_group
#define GENL_mc_group(group) { .name = #group, },
#include GENL_MAGIC_INCLUDE_FILE
};
enum CONCATENATE(GENL_MAGIC_FAMILY, group_ids) {
#undef GENL_mc_group
#define GENL_mc_group(group) CONCATENATE(GENL_MAGIC_FAMILY, _group_ ## group),
#include GENL_MAGIC_INCLUDE_FILE
};
#undef GENL_mc_group
#define GENL_mc_group(group) \
static int CONCATENATE(GENL_MAGIC_FAMILY, _genl_multicast_ ## group)( \
struct sk_buff *skb, gfp_t flags) \
{ \
unsigned int group_id = \
CONCATENATE(GENL_MAGIC_FAMILY, _group_ ## group); \
return genlmsg_multicast(&ZZZ_genl_family, skb, 0, \
group_id, flags); \
}
#include GENL_MAGIC_INCLUDE_FILE
#undef GENL_mc_group
#define GENL_mc_group(group)
static struct genl_family ZZZ_genl_family __ro_after_init = {
.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(CONCATENATE(GENL_MAGIC_FAMILY, _tla_nl_policy))-1,
.policy = CONCATENATE(GENL_MAGIC_FAMILY, _tla_nl_policy),
#ifdef GENL_MAGIC_FAMILY_PRE_DOIT
.pre_doit = GENL_MAGIC_FAMILY_PRE_DOIT,
.post_doit = GENL_MAGIC_FAMILY_POST_DOIT,
#endif
.ops = ZZZ_genl_ops,
.n_ops = ARRAY_SIZE(ZZZ_genl_ops),
.mcgrps = ZZZ_genl_mcgrps,
.resv_start_op = 42, /* drbd is currently the only user */
.n_mcgrps = ARRAY_SIZE(ZZZ_genl_mcgrps),
.module = THIS_MODULE,
};
int CONCATENATE(GENL_MAGIC_FAMILY, _genl_register)(void)
{
return genl_register_family(&ZZZ_genl_family);
}
void CONCATENATE(GENL_MAGIC_FAMILY, _genl_unregister)(void)
{
genl_unregister_family(&ZZZ_genl_family);
}
/*
* Magic: provide conversion functions {{{1
* populate skb from struct.
* {{{2
*/
#undef GENL_op
#define GENL_op(op_name, op_num, handler, tla_list)
#undef GENL_struct
#define GENL_struct(tag_name, tag_number, s_name, s_fields) \
static int s_name ## _to_skb(struct sk_buff *skb, struct s_name *s, \
const bool exclude_sensitive) \
{ \
struct nlattr *tla = nla_nest_start(skb, tag_number); \
if (!tla) \
goto nla_put_failure; \
DPRINT_TLA(#s_name, "-=>", #tag_name); \
s_fields \
nla_nest_end(skb, tla); \
return 0; \
\
nla_put_failure: \
if (tla) \
nla_nest_cancel(skb, tla); \
return -EMSGSIZE; \
} \
static inline int s_name ## _to_priv_skb(struct sk_buff *skb, \
struct s_name *s) \
{ \
return s_name ## _to_skb(skb, s, 0); \
} \
static inline int s_name ## _to_unpriv_skb(struct sk_buff *skb, \
struct s_name *s) \
{ \
return s_name ## _to_skb(skb, s, 1); \
}
#undef __field
#define __field(attr_nr, attr_flag, name, nla_type, type, __get, __put, \
__is_signed) \
if (!exclude_sensitive || !((attr_flag) & DRBD_F_SENSITIVE)) { \
DPRINT_FIELD(">>", nla_type, name, s, NULL); \
if (__put(skb, attr_nr, s->name)) \
goto nla_put_failure; \
}
#undef __array
#define __array(attr_nr, attr_flag, name, nla_type, type, maxlen, \
__get, __put, __is_signed) \
if (!exclude_sensitive || !((attr_flag) & DRBD_F_SENSITIVE)) { \
DPRINT_ARRAY(">>",nla_type, name, s, NULL); \
if (__put(skb, attr_nr, min_t(int, maxlen, \
s->name ## _len + (nla_type == NLA_NUL_STRING)),\
s->name)) \
goto nla_put_failure; \
}
#include GENL_MAGIC_INCLUDE_FILE
/* Functions for initializing structs to default values. */
#undef __field
#define __field(attr_nr, attr_flag, name, nla_type, type, __get, __put, \
__is_signed)
#undef __array
#define __array(attr_nr, attr_flag, name, nla_type, type, maxlen, \
__get, __put, __is_signed)
#undef __u32_field_def
#define __u32_field_def(attr_nr, attr_flag, name, default) \
x->name = default;
#undef __s32_field_def
#define __s32_field_def(attr_nr, attr_flag, name, default) \
x->name = default;
#undef __flg_field_def
#define __flg_field_def(attr_nr, attr_flag, name, default) \
x->name = default;
#undef __str_field_def
#define __str_field_def(attr_nr, attr_flag, name, maxlen) \
memset(x->name, 0, sizeof(x->name)); \
x->name ## _len = 0;
#undef GENL_struct
#define GENL_struct(tag_name, tag_number, s_name, s_fields) \
static void set_ ## s_name ## _defaults(struct s_name *x) __attribute__((unused)); \
static void set_ ## s_name ## _defaults(struct s_name *x) { \
s_fields \
}
#include GENL_MAGIC_INCLUDE_FILE
#endif /* __KERNEL__ */
/* }}}1 */
#endif /* GENL_MAGIC_FUNC_H */
-272
View File
@@ -1,272 +0,0 @@
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef GENL_MAGIC_STRUCT_H
#define GENL_MAGIC_STRUCT_H
#ifndef GENL_MAGIC_FAMILY
# error "you need to define GENL_MAGIC_FAMILY before inclusion"
#endif
#ifndef GENL_MAGIC_VERSION
# error "you need to define GENL_MAGIC_VERSION before inclusion"
#endif
#ifndef GENL_MAGIC_INCLUDE_FILE
# error "you need to define GENL_MAGIC_INCLUDE_FILE before inclusion"
#endif
#include <linux/args.h>
#include <linux/types.h>
#include <net/genetlink.h>
extern int CONCATENATE(GENL_MAGIC_FAMILY, _genl_register)(void);
extern void CONCATENATE(GENL_MAGIC_FAMILY, _genl_unregister)(void);
/*
* Extension of genl attribute validation policies {{{2
*/
/*
* Flags specific to drbd and not visible at the netlink layer, used in
* <struct>_from_attrs and <struct>_to_skb:
*
* @DRBD_F_REQUIRED: Attribute is required; a request without this attribute is
* invalid.
*
* @DRBD_F_SENSITIVE: Attribute includes sensitive information and must not be
* included in unpriviledged get requests or broadcasts.
*
* @DRBD_F_INVARIANT: Attribute is set when an object is initially created, but
* cannot subsequently be changed.
*/
#define DRBD_F_REQUIRED (1 << 0)
#define DRBD_F_SENSITIVE (1 << 1)
#define DRBD_F_INVARIANT (1 << 2)
/* }}}1
* MAGIC
* multi-include macro expansion magic starts here
*/
/* MAGIC helpers {{{2 */
static inline int nla_put_u64_0pad(struct sk_buff *skb, int attrtype, u64 value)
{
return nla_put_64bit(skb, attrtype, sizeof(u64), &value, 0);
}
/* possible field types */
#define __flg_field(attr_nr, attr_flag, name) \
__field(attr_nr, attr_flag, name, NLA_U8, char, \
nla_get_u8, nla_put_u8, false)
#define __u8_field(attr_nr, attr_flag, name) \
__field(attr_nr, attr_flag, name, NLA_U8, unsigned char, \
nla_get_u8, nla_put_u8, false)
#define __u16_field(attr_nr, attr_flag, name) \
__field(attr_nr, attr_flag, name, NLA_U16, __u16, \
nla_get_u16, nla_put_u16, false)
#define __u32_field(attr_nr, attr_flag, name) \
__field(attr_nr, attr_flag, name, NLA_U32, __u32, \
nla_get_u32, nla_put_u32, false)
#define __s32_field(attr_nr, attr_flag, name) \
__field(attr_nr, attr_flag, name, NLA_U32, __s32, \
nla_get_u32, nla_put_u32, true)
#define __u64_field(attr_nr, attr_flag, name) \
__field(attr_nr, attr_flag, name, NLA_U64, __u64, \
nla_get_u64, nla_put_u64_0pad, false)
#define __str_field(attr_nr, attr_flag, name, maxlen) \
__array(attr_nr, attr_flag, name, NLA_NUL_STRING, char, maxlen, \
nla_strscpy, nla_put, false)
#define __bin_field(attr_nr, attr_flag, name, maxlen) \
__array(attr_nr, attr_flag, name, NLA_BINARY, char, maxlen, \
nla_memcpy, nla_put, false)
/* fields with default values */
#define __flg_field_def(attr_nr, attr_flag, name, default) \
__flg_field(attr_nr, attr_flag, name)
#define __u32_field_def(attr_nr, attr_flag, name, default) \
__u32_field(attr_nr, attr_flag, name)
#define __s32_field_def(attr_nr, attr_flag, name, default) \
__s32_field(attr_nr, attr_flag, name)
#define __str_field_def(attr_nr, attr_flag, name, maxlen) \
__str_field(attr_nr, attr_flag, name, maxlen)
#define GENL_op_init(args...) args
#define GENL_doit(handler) \
.doit = handler, \
.flags = GENL_ADMIN_PERM,
#define GENL_dumpit(handler) \
.dumpit = handler, \
.flags = GENL_ADMIN_PERM,
/* }}}1
* Magic: define the enum symbols for genl_ops
* Magic: define the enum symbols for top level attributes
* Magic: define the enum symbols for nested attributes
* {{{2
*/
#undef GENL_struct
#define GENL_struct(tag_name, tag_number, s_name, s_fields)
#undef GENL_mc_group
#define GENL_mc_group(group)
#undef GENL_notification
#define GENL_notification(op_name, op_num, mcast_group, tla_list) \
op_name = op_num,
#undef GENL_op
#define GENL_op(op_name, op_num, handler, tla_list) \
op_name = op_num,
enum {
#include GENL_MAGIC_INCLUDE_FILE
};
#undef GENL_notification
#define GENL_notification(op_name, op_num, mcast_group, tla_list)
#undef GENL_op
#define GENL_op(op_name, op_num, handler, attr_list)
#undef GENL_struct
#define GENL_struct(tag_name, tag_number, s_name, s_fields) \
tag_name = tag_number,
enum {
#include GENL_MAGIC_INCLUDE_FILE
};
#undef GENL_struct
#define GENL_struct(tag_name, tag_number, s_name, s_fields) \
enum { \
s_fields \
};
#undef __field
#define __field(attr_nr, attr_flag, name, nla_type, type, \
__get, __put, __is_signed) \
T_ ## name = (__u16)(attr_nr),
#undef __array
#define __array(attr_nr, attr_flag, name, nla_type, type, \
maxlen, __get, __put, __is_signed) \
T_ ## name = (__u16)(attr_nr),
#include GENL_MAGIC_INCLUDE_FILE
/* }}}1
* Magic: compile time assert unique numbers for operations
* Magic: -"- unique numbers for top level attributes
* Magic: -"- unique numbers for nested attributes
* {{{2
*/
#undef GENL_struct
#define GENL_struct(tag_name, tag_number, s_name, s_fields)
#undef GENL_op
#define GENL_op(op_name, op_num, handler, attr_list) \
case op_name:
#undef GENL_notification
#define GENL_notification(op_name, op_num, mcast_group, tla_list) \
case op_name:
static inline void ct_assert_unique_operations(void)
{
switch (0) {
#include GENL_MAGIC_INCLUDE_FILE
case 0:
;
}
}
#undef GENL_op
#define GENL_op(op_name, op_num, handler, attr_list)
#undef GENL_notification
#define GENL_notification(op_name, op_num, mcast_group, tla_list)
#undef GENL_struct
#define GENL_struct(tag_name, tag_number, s_name, s_fields) \
case tag_number:
static inline void ct_assert_unique_top_level_attributes(void)
{
switch (0) {
#include GENL_MAGIC_INCLUDE_FILE
case 0:
;
}
}
#undef GENL_struct
#define GENL_struct(tag_name, tag_number, s_name, s_fields) \
static inline void ct_assert_unique_ ## s_name ## _attributes(void) \
{ \
switch (0) { \
s_fields \
case 0: \
; \
} \
}
#undef __field
#define __field(attr_nr, attr_flag, name, nla_type, type, __get, __put, \
__is_signed) \
case attr_nr:
#undef __array
#define __array(attr_nr, attr_flag, name, nla_type, type, maxlen, \
__get, __put, __is_signed) \
case attr_nr:
#include GENL_MAGIC_INCLUDE_FILE
/* }}}1
* Magic: declare structs
* struct <name> {
* fields
* };
* {{{2
*/
#undef GENL_struct
#define GENL_struct(tag_name, tag_number, s_name, s_fields) \
struct s_name { s_fields };
#undef __field
#define __field(attr_nr, attr_flag, name, nla_type, type, __get, __put, \
__is_signed) \
type name;
#undef __array
#define __array(attr_nr, attr_flag, name, nla_type, type, maxlen, \
__get, __put, __is_signed) \
type name[maxlen]; \
__u32 name ## _len;
#include GENL_MAGIC_INCLUDE_FILE
#undef GENL_struct
#define GENL_struct(tag_name, tag_number, s_name, s_fields) \
enum { \
s_fields \
};
#undef __field
#define __field(attr_nr, attr_flag, name, nla_type, type, __get, __put, \
is_signed) \
F_ ## name ## _IS_SIGNED = is_signed,
#undef __array
#define __array(attr_nr, attr_flag, name, nla_type, type, maxlen, \
__get, __put, is_signed) \
F_ ## name ## _IS_SIGNED = is_signed,
#include GENL_MAGIC_INCLUDE_FILE
/* }}}1 */
#endif /* GENL_MAGIC_STRUCT_H */
+3
View File
@@ -333,6 +333,9 @@ enum drbd_uuid_index {
#define HISTORY_UUIDS MAX_PEERS
#define DRBD_NL_UUIDS_SIZE (UI_SIZE * sizeof(__u64))
#define DRBD_NL_HISTORY_UUIDS_SIZE (HISTORY_UUIDS * sizeof(__u64))
enum drbd_timeout_flag {
UT_DEFAULT = 0,
UT_DEGRADED = 1,
+359
View File
@@ -0,0 +1,359 @@
/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */
#ifndef _UAPI_LINUX_DRBD_GENL_H
#define _UAPI_LINUX_DRBD_GENL_H
#define DRBD_FAMILY_NAME "drbd"
#define DRBD_FAMILY_VERSION 1
enum {
DRBD_NLA_CFG_REPLY = 1,
DRBD_NLA_CFG_CONTEXT,
DRBD_NLA_DISK_CONF,
DRBD_NLA_RESOURCE_OPTS,
DRBD_NLA_NET_CONF,
DRBD_NLA_SET_ROLE_PARMS,
DRBD_NLA_RESIZE_PARMS,
DRBD_NLA_STATE_INFO,
DRBD_NLA_START_OV_PARMS,
DRBD_NLA_NEW_C_UUID_PARMS,
DRBD_NLA_TIMEOUT_PARMS,
DRBD_NLA_DISCONNECT_PARMS,
DRBD_NLA_DETACH_PARMS,
DRBD_NLA_RESOURCE_INFO = 15,
DRBD_NLA_DEVICE_INFO,
DRBD_NLA_CONNECTION_INFO,
DRBD_NLA_PEER_DEVICE_INFO,
DRBD_NLA_RESOURCE_STATISTICS,
DRBD_NLA_DEVICE_STATISTICS,
DRBD_NLA_CONNECTION_STATISTICS,
DRBD_NLA_PEER_DEVICE_STATISTICS,
DRBD_NLA_NOTIFICATION_HEADER,
DRBD_NLA_HELPER,
__DRBD_NLA_MAX,
DRBD_NLA_MAX = (__DRBD_NLA_MAX - 1)
};
enum {
DRBD_A_DRBD_CFG_REPLY_INFO_TEXT = 1,
__DRBD_A_DRBD_CFG_REPLY_MAX,
DRBD_A_DRBD_CFG_REPLY_MAX = (__DRBD_A_DRBD_CFG_REPLY_MAX - 1)
};
enum {
DRBD_A_DRBD_CFG_CONTEXT_CTX_VOLUME = 1,
DRBD_A_DRBD_CFG_CONTEXT_CTX_RESOURCE_NAME,
DRBD_A_DRBD_CFG_CONTEXT_CTX_MY_ADDR,
DRBD_A_DRBD_CFG_CONTEXT_CTX_PEER_ADDR,
__DRBD_A_DRBD_CFG_CONTEXT_MAX,
DRBD_A_DRBD_CFG_CONTEXT_MAX = (__DRBD_A_DRBD_CFG_CONTEXT_MAX - 1)
};
enum {
DRBD_A_DISK_CONF_BACKING_DEV = 1,
DRBD_A_DISK_CONF_META_DEV,
DRBD_A_DISK_CONF_META_DEV_IDX,
DRBD_A_DISK_CONF_DISK_SIZE,
DRBD_A_DISK_CONF_MAX_BIO_BVECS,
DRBD_A_DISK_CONF_ON_IO_ERROR,
DRBD_A_DISK_CONF_FENCING,
DRBD_A_DISK_CONF_RESYNC_RATE,
DRBD_A_DISK_CONF_RESYNC_AFTER,
DRBD_A_DISK_CONF_AL_EXTENTS,
DRBD_A_DISK_CONF_C_PLAN_AHEAD,
DRBD_A_DISK_CONF_C_DELAY_TARGET,
DRBD_A_DISK_CONF_C_FILL_TARGET,
DRBD_A_DISK_CONF_C_MAX_RATE,
DRBD_A_DISK_CONF_C_MIN_RATE,
DRBD_A_DISK_CONF_DISK_BARRIER,
DRBD_A_DISK_CONF_DISK_FLUSHES,
DRBD_A_DISK_CONF_DISK_DRAIN,
DRBD_A_DISK_CONF_MD_FLUSHES,
DRBD_A_DISK_CONF_DISK_TIMEOUT,
DRBD_A_DISK_CONF_READ_BALANCING,
DRBD_A_DISK_CONF_AL_UPDATES = 23,
DRBD_A_DISK_CONF_DISCARD_ZEROES_IF_ALIGNED,
DRBD_A_DISK_CONF_RS_DISCARD_GRANULARITY,
DRBD_A_DISK_CONF_DISABLE_WRITE_SAME,
__DRBD_A_DISK_CONF_MAX,
DRBD_A_DISK_CONF_MAX = (__DRBD_A_DISK_CONF_MAX - 1)
};
enum {
DRBD_A_RES_OPTS_CPU_MASK = 1,
DRBD_A_RES_OPTS_ON_NO_DATA,
__DRBD_A_RES_OPTS_MAX,
DRBD_A_RES_OPTS_MAX = (__DRBD_A_RES_OPTS_MAX - 1)
};
enum {
DRBD_A_NET_CONF_SHARED_SECRET = 1,
DRBD_A_NET_CONF_CRAM_HMAC_ALG,
DRBD_A_NET_CONF_INTEGRITY_ALG,
DRBD_A_NET_CONF_VERIFY_ALG,
DRBD_A_NET_CONF_CSUMS_ALG,
DRBD_A_NET_CONF_WIRE_PROTOCOL,
DRBD_A_NET_CONF_CONNECT_INT,
DRBD_A_NET_CONF_TIMEOUT,
DRBD_A_NET_CONF_PING_INT,
DRBD_A_NET_CONF_PING_TIMEO,
DRBD_A_NET_CONF_SNDBUF_SIZE,
DRBD_A_NET_CONF_RCVBUF_SIZE,
DRBD_A_NET_CONF_KO_COUNT,
DRBD_A_NET_CONF_MAX_BUFFERS,
DRBD_A_NET_CONF_MAX_EPOCH_SIZE,
DRBD_A_NET_CONF_UNPLUG_WATERMARK,
DRBD_A_NET_CONF_AFTER_SB_0P,
DRBD_A_NET_CONF_AFTER_SB_1P,
DRBD_A_NET_CONF_AFTER_SB_2P,
DRBD_A_NET_CONF_RR_CONFLICT,
DRBD_A_NET_CONF_ON_CONGESTION,
DRBD_A_NET_CONF_CONG_FILL,
DRBD_A_NET_CONF_CONG_EXTENTS,
DRBD_A_NET_CONF_TWO_PRIMARIES,
DRBD_A_NET_CONF_DISCARD_MY_DATA,
DRBD_A_NET_CONF_TCP_CORK,
DRBD_A_NET_CONF_ALWAYS_ASBP,
DRBD_A_NET_CONF_TENTATIVE,
DRBD_A_NET_CONF_USE_RLE,
DRBD_A_NET_CONF_CSUMS_AFTER_CRASH_ONLY = 33,
DRBD_A_NET_CONF_SOCK_CHECK_TIMEO,
__DRBD_A_NET_CONF_MAX,
DRBD_A_NET_CONF_MAX = (__DRBD_A_NET_CONF_MAX - 1)
};
enum {
DRBD_A_SET_ROLE_PARMS_ASSUME_UPTODATE = 1,
__DRBD_A_SET_ROLE_PARMS_MAX,
DRBD_A_SET_ROLE_PARMS_MAX = (__DRBD_A_SET_ROLE_PARMS_MAX - 1)
};
enum {
DRBD_A_RESIZE_PARMS_RESIZE_SIZE = 1,
DRBD_A_RESIZE_PARMS_RESIZE_FORCE,
DRBD_A_RESIZE_PARMS_NO_RESYNC,
DRBD_A_RESIZE_PARMS_AL_STRIPES,
DRBD_A_RESIZE_PARMS_AL_STRIPE_SIZE,
__DRBD_A_RESIZE_PARMS_MAX,
DRBD_A_RESIZE_PARMS_MAX = (__DRBD_A_RESIZE_PARMS_MAX - 1)
};
enum {
DRBD_A_STATE_INFO_SIB_REASON = 1,
DRBD_A_STATE_INFO_CURRENT_STATE,
DRBD_A_STATE_INFO_CAPACITY,
DRBD_A_STATE_INFO_ED_UUID,
DRBD_A_STATE_INFO_PREV_STATE,
DRBD_A_STATE_INFO_NEW_STATE,
DRBD_A_STATE_INFO_UUIDS,
DRBD_A_STATE_INFO_DISK_FLAGS,
DRBD_A_STATE_INFO_BITS_TOTAL,
DRBD_A_STATE_INFO_BITS_OOS,
DRBD_A_STATE_INFO_BITS_RS_TOTAL,
DRBD_A_STATE_INFO_BITS_RS_FAILED,
DRBD_A_STATE_INFO_HELPER,
DRBD_A_STATE_INFO_HELPER_EXIT_CODE,
DRBD_A_STATE_INFO_SEND_CNT,
DRBD_A_STATE_INFO_RECV_CNT,
DRBD_A_STATE_INFO_READ_CNT,
DRBD_A_STATE_INFO_WRIT_CNT,
DRBD_A_STATE_INFO_AL_WRIT_CNT,
DRBD_A_STATE_INFO_BM_WRIT_CNT,
DRBD_A_STATE_INFO_AP_BIO_CNT,
DRBD_A_STATE_INFO_AP_PENDING_CNT,
DRBD_A_STATE_INFO_RS_PENDING_CNT,
__DRBD_A_STATE_INFO_MAX,
DRBD_A_STATE_INFO_MAX = (__DRBD_A_STATE_INFO_MAX - 1)
};
enum {
DRBD_A_START_OV_PARMS_OV_START_SECTOR = 1,
DRBD_A_START_OV_PARMS_OV_STOP_SECTOR,
__DRBD_A_START_OV_PARMS_MAX,
DRBD_A_START_OV_PARMS_MAX = (__DRBD_A_START_OV_PARMS_MAX - 1)
};
enum {
DRBD_A_NEW_C_UUID_PARMS_CLEAR_BM = 1,
__DRBD_A_NEW_C_UUID_PARMS_MAX,
DRBD_A_NEW_C_UUID_PARMS_MAX = (__DRBD_A_NEW_C_UUID_PARMS_MAX - 1)
};
enum {
DRBD_A_TIMEOUT_PARMS_TIMEOUT_TYPE = 1,
__DRBD_A_TIMEOUT_PARMS_MAX,
DRBD_A_TIMEOUT_PARMS_MAX = (__DRBD_A_TIMEOUT_PARMS_MAX - 1)
};
enum {
DRBD_A_DISCONNECT_PARMS_FORCE_DISCONNECT = 1,
__DRBD_A_DISCONNECT_PARMS_MAX,
DRBD_A_DISCONNECT_PARMS_MAX = (__DRBD_A_DISCONNECT_PARMS_MAX - 1)
};
enum {
DRBD_A_DETACH_PARMS_FORCE_DETACH = 1,
__DRBD_A_DETACH_PARMS_MAX,
DRBD_A_DETACH_PARMS_MAX = (__DRBD_A_DETACH_PARMS_MAX - 1)
};
enum {
DRBD_A_RESOURCE_INFO_RES_ROLE = 1,
DRBD_A_RESOURCE_INFO_RES_SUSP,
DRBD_A_RESOURCE_INFO_RES_SUSP_NOD,
DRBD_A_RESOURCE_INFO_RES_SUSP_FEN,
__DRBD_A_RESOURCE_INFO_MAX,
DRBD_A_RESOURCE_INFO_MAX = (__DRBD_A_RESOURCE_INFO_MAX - 1)
};
enum {
DRBD_A_DEVICE_INFO_DEV_DISK_STATE = 1,
__DRBD_A_DEVICE_INFO_MAX,
DRBD_A_DEVICE_INFO_MAX = (__DRBD_A_DEVICE_INFO_MAX - 1)
};
enum {
DRBD_A_CONNECTION_INFO_CONN_CONNECTION_STATE = 1,
DRBD_A_CONNECTION_INFO_CONN_ROLE,
__DRBD_A_CONNECTION_INFO_MAX,
DRBD_A_CONNECTION_INFO_MAX = (__DRBD_A_CONNECTION_INFO_MAX - 1)
};
enum {
DRBD_A_PEER_DEVICE_INFO_PEER_REPL_STATE = 1,
DRBD_A_PEER_DEVICE_INFO_PEER_DISK_STATE,
DRBD_A_PEER_DEVICE_INFO_PEER_RESYNC_SUSP_USER,
DRBD_A_PEER_DEVICE_INFO_PEER_RESYNC_SUSP_PEER,
DRBD_A_PEER_DEVICE_INFO_PEER_RESYNC_SUSP_DEPENDENCY,
__DRBD_A_PEER_DEVICE_INFO_MAX,
DRBD_A_PEER_DEVICE_INFO_MAX = (__DRBD_A_PEER_DEVICE_INFO_MAX - 1)
};
enum {
DRBD_A_RESOURCE_STATISTICS_RES_STAT_WRITE_ORDERING = 1,
__DRBD_A_RESOURCE_STATISTICS_MAX,
DRBD_A_RESOURCE_STATISTICS_MAX = (__DRBD_A_RESOURCE_STATISTICS_MAX - 1)
};
enum {
DRBD_A_DEVICE_STATISTICS_DEV_SIZE = 1,
DRBD_A_DEVICE_STATISTICS_DEV_READ,
DRBD_A_DEVICE_STATISTICS_DEV_WRITE,
DRBD_A_DEVICE_STATISTICS_DEV_AL_WRITES,
DRBD_A_DEVICE_STATISTICS_DEV_BM_WRITES,
DRBD_A_DEVICE_STATISTICS_DEV_UPPER_PENDING,
DRBD_A_DEVICE_STATISTICS_DEV_LOWER_PENDING,
DRBD_A_DEVICE_STATISTICS_DEV_UPPER_BLOCKED,
DRBD_A_DEVICE_STATISTICS_DEV_LOWER_BLOCKED,
DRBD_A_DEVICE_STATISTICS_DEV_AL_SUSPENDED,
DRBD_A_DEVICE_STATISTICS_DEV_EXPOSED_DATA_UUID,
DRBD_A_DEVICE_STATISTICS_DEV_CURRENT_UUID,
DRBD_A_DEVICE_STATISTICS_DEV_DISK_FLAGS,
DRBD_A_DEVICE_STATISTICS_HISTORY_UUIDS,
__DRBD_A_DEVICE_STATISTICS_MAX,
DRBD_A_DEVICE_STATISTICS_MAX = (__DRBD_A_DEVICE_STATISTICS_MAX - 1)
};
enum {
DRBD_A_CONNECTION_STATISTICS_CONN_CONGESTED = 1,
__DRBD_A_CONNECTION_STATISTICS_MAX,
DRBD_A_CONNECTION_STATISTICS_MAX = (__DRBD_A_CONNECTION_STATISTICS_MAX - 1)
};
enum {
DRBD_A_PEER_DEVICE_STATISTICS_PEER_DEV_RECEIVED = 1,
DRBD_A_PEER_DEVICE_STATISTICS_PEER_DEV_SENT,
DRBD_A_PEER_DEVICE_STATISTICS_PEER_DEV_PENDING,
DRBD_A_PEER_DEVICE_STATISTICS_PEER_DEV_UNACKED,
DRBD_A_PEER_DEVICE_STATISTICS_PEER_DEV_OUT_OF_SYNC,
DRBD_A_PEER_DEVICE_STATISTICS_PEER_DEV_RESYNC_FAILED,
DRBD_A_PEER_DEVICE_STATISTICS_PEER_DEV_BITMAP_UUID,
DRBD_A_PEER_DEVICE_STATISTICS_PEER_DEV_FLAGS = 9,
__DRBD_A_PEER_DEVICE_STATISTICS_MAX,
DRBD_A_PEER_DEVICE_STATISTICS_MAX = (__DRBD_A_PEER_DEVICE_STATISTICS_MAX - 1)
};
enum {
DRBD_A_DRBD_NOTIFICATION_HEADER_NH_TYPE = 1,
__DRBD_A_DRBD_NOTIFICATION_HEADER_MAX,
DRBD_A_DRBD_NOTIFICATION_HEADER_MAX = (__DRBD_A_DRBD_NOTIFICATION_HEADER_MAX - 1)
};
enum {
DRBD_A_DRBD_HELPER_INFO_HELPER_NAME = 1,
DRBD_A_DRBD_HELPER_INFO_HELPER_STATUS,
__DRBD_A_DRBD_HELPER_INFO_MAX,
DRBD_A_DRBD_HELPER_INFO_MAX = (__DRBD_A_DRBD_HELPER_INFO_MAX - 1)
};
enum {
DRBD_ADM_EVENT = 1,
DRBD_ADM_GET_STATUS,
DRBD_ADM_NEW_MINOR = 5,
DRBD_ADM_DEL_MINOR,
DRBD_ADM_NEW_RESOURCE,
DRBD_ADM_DEL_RESOURCE,
DRBD_ADM_RESOURCE_OPTS,
DRBD_ADM_CONNECT,
DRBD_ADM_DISCONNECT,
DRBD_ADM_ATTACH,
DRBD_ADM_RESIZE,
DRBD_ADM_PRIMARY,
DRBD_ADM_SECONDARY,
DRBD_ADM_NEW_C_UUID,
DRBD_ADM_START_OV,
DRBD_ADM_DETACH,
DRBD_ADM_INVALIDATE,
DRBD_ADM_INVAL_PEER,
DRBD_ADM_PAUSE_SYNC,
DRBD_ADM_RESUME_SYNC,
DRBD_ADM_SUSPEND_IO,
DRBD_ADM_RESUME_IO,
DRBD_ADM_OUTDATE,
DRBD_ADM_GET_TIMEOUT_TYPE,
DRBD_ADM_DOWN,
DRBD_ADM_CHG_DISK_OPTS,
DRBD_ADM_CHG_NET_OPTS,
DRBD_ADM_GET_RESOURCES,
DRBD_ADM_GET_DEVICES,
DRBD_ADM_GET_CONNECTIONS,
DRBD_ADM_GET_PEER_DEVICES,
DRBD_ADM_RESOURCE_STATE,
DRBD_ADM_DEVICE_STATE,
DRBD_ADM_CONNECTION_STATE,
DRBD_ADM_PEER_DEVICE_STATE,
DRBD_ADM_GET_INITIAL_STATE,
DRBD_ADM_HELPER = 40,
DRBD_ADM_INITIAL_STATE_DONE,
__DRBD_ADM_MAX,
DRBD_ADM_MAX = (__DRBD_ADM_MAX - 1)
};
#define DRBD_MCGRP_EVENTS "events"
#endif /* _UAPI_LINUX_DRBD_GENL_H */