[PATCH v3 0/2] drbd: switch from genl_magic to YNL

Christoph Böhmwalder posted 2 patches 1 month, 1 week ago
drivers/block/drbd/Makefile                   |    1 +
drivers/block/drbd/drbd_buildtag.c            |    2 +-
.../block/drbd}/drbd_config.h                 |    0
drivers/block/drbd/drbd_debugfs.c             |    2 +-
drivers/block/drbd/drbd_int.h                 |    6 +-
drivers/block/drbd/drbd_main.c                |    6 +-
drivers/block/drbd/drbd_nl.c                  |  416 +--
drivers/block/drbd/drbd_nl_gen.c              | 2606 +++++++++++++++++
drivers/block/drbd/drbd_nl_gen.h              |  395 +++
drivers/block/drbd/drbd_proc.c                |    2 +-
include/linux/drbd_genl.h                     |  536 ----
include/linux/drbd_genl_api.h                 |   56 -
include/linux/genl_magic_func.h               |  413 ---
include/linux/genl_magic_struct.h             |  272 --
include/{ => uapi}/linux/drbd.h               |   45 +-
include/uapi/linux/drbd_genl.h                |  359 +++
include/{ => uapi}/linux/drbd_limits.h        |    2 +-
17 files changed, 3653 insertions(+), 1466 deletions(-)
rename {include/linux => drivers/block/drbd}/drbd_config.h (100%)
create mode 100644 drivers/block/drbd/drbd_nl_gen.c
create mode 100644 drivers/block/drbd/drbd_nl_gen.h
delete mode 100644 include/linux/drbd_genl.h
delete mode 100644 include/linux/drbd_genl_api.h
delete mode 100644 include/linux/genl_magic_func.h
delete mode 100644 include/linux/genl_magic_struct.h
rename include/{ => uapi}/linux/drbd.h (86%)
create mode 100644 include/uapi/linux/drbd_genl.h
rename include/{ => uapi}/linux/drbd_limits.h (99%)
[PATCH v3 0/2] drbd: switch from genl_magic to YNL
Posted by Christoph Böhmwalder 1 month, 1 week ago
DRBD's genetlink interface was defined using a custom multi-include
macro system, genl_magic_{func,struct}.h. This system generated struct
definitions, netlink policies, serialization functions and more
from a single "magic" header.
It never really caught on; DRBD is its only user, its internal macro
jungle is next to impossible to understand, and even harder to debug.

This series replaces it with the standard solution, YNL.
The *_gen.[ch] files were created with a modified YNL generator, but
these modifications are not shipped because the current DRBD family is
effectively frozen.

Note: this family primarily aims for compatibility with existing
userspace. The next planned step is a new (also YNL-based) family,
"drbd2", which will implement all the actual modern recommendations for
new netlink families.

Changes from v2:
- Fix compile error

Changes from v1:
- Remove YNL generator patches, ship just the generated code

Christoph Böhmwalder (2):
  drbd: move UAPI headers to include/uapi/linux/
  drbd: replace genl_magic with explicit netlink serialization

 drivers/block/drbd/Makefile                   |    1 +
 drivers/block/drbd/drbd_buildtag.c            |    2 +-
 .../block/drbd}/drbd_config.h                 |    0
 drivers/block/drbd/drbd_debugfs.c             |    2 +-
 drivers/block/drbd/drbd_int.h                 |    6 +-
 drivers/block/drbd/drbd_main.c                |    6 +-
 drivers/block/drbd/drbd_nl.c                  |  416 +--
 drivers/block/drbd/drbd_nl_gen.c              | 2606 +++++++++++++++++
 drivers/block/drbd/drbd_nl_gen.h              |  395 +++
 drivers/block/drbd/drbd_proc.c                |    2 +-
 include/linux/drbd_genl.h                     |  536 ----
 include/linux/drbd_genl_api.h                 |   56 -
 include/linux/genl_magic_func.h               |  413 ---
 include/linux/genl_magic_struct.h             |  272 --
 include/{ => uapi}/linux/drbd.h               |   45 +-
 include/uapi/linux/drbd_genl.h                |  359 +++
 include/{ => uapi}/linux/drbd_limits.h        |    2 +-
 17 files changed, 3653 insertions(+), 1466 deletions(-)
 rename {include/linux => drivers/block/drbd}/drbd_config.h (100%)
 create mode 100644 drivers/block/drbd/drbd_nl_gen.c
 create mode 100644 drivers/block/drbd/drbd_nl_gen.h
 delete mode 100644 include/linux/drbd_genl.h
 delete mode 100644 include/linux/drbd_genl_api.h
 delete mode 100644 include/linux/genl_magic_func.h
 delete mode 100644 include/linux/genl_magic_struct.h
 rename include/{ => uapi}/linux/drbd.h (86%)
 create mode 100644 include/uapi/linux/drbd_genl.h
 rename include/{ => uapi}/linux/drbd_limits.h (99%)


base-commit: a9c4b1d37622ed01b75f94a4f68cf55f33153a31
-- 
2.53.0

Re: [PATCH v3 0/2] drbd: switch from genl_magic to YNL
Posted by Jens Axboe 1 month ago
On Wed, 06 May 2026 14:45:39 +0200, Christoph Böhmwalder wrote:
> DRBD's genetlink interface was defined using a custom multi-include
> macro system, genl_magic_{func,struct}.h. This system generated struct
> definitions, netlink policies, serialization functions and more
> from a single "magic" header.
> It never really caught on; DRBD is its only user, its internal macro
> jungle is next to impossible to understand, and even harder to debug.
> 
> [...]

Applied, thanks!

[1/2] drbd: move UAPI headers to include/uapi/linux/
      (no commit info)
[2/2] drbd: replace genl_magic with explicit netlink serialization
      (no commit info)

Best regards,
-- 
Jens Axboe



Re: [PATCH v3 0/2] drbd: switch from genl_magic to YNL
Posted by Jakub Kicinski 1 month ago
On Wed,  6 May 2026 14:45:39 +0200 Christoph Böhmwalder wrote:
> DRBD's genetlink interface was defined using a custom multi-include
> macro system, genl_magic_{func,struct}.h. This system generated struct
> definitions, netlink policies, serialization functions and more
> from a single "magic" header.
> It never really caught on; DRBD is its only user, its internal macro
> jungle is next to impossible to understand, and even harder to debug.
> 
> This series replaces it with the standard solution, YNL.
> The *_gen.[ch] files were created with a modified YNL generator, but
> these modifications are not shipped because the current DRBD family is
> effectively frozen.
> 
> Note: this family primarily aims for compatibility with existing
> userspace. The next planned step is a new (also YNL-based) family,
> "drbd2", which will implement all the actual modern recommendations for
> new netlink families.

FWIW:

Acked-by: Jakub Kicinski <kuba@kernel.org>