整理Generic Netlink 编程过程中遇到的坑

Summer的小屋 2019-07-01

Linux 4.10 API接口变更

1. 删除了API函数__genl_register_family_with_ops(family, ops, n_ops).

2. 删除了API宏函数genl_register_family_with_ops(family, ops).

git提交链接:
https://github.com/torvalds/l...

# 内核开发者日志
genetlink: statically initialize families

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 <[email protected]>
Signed-off-by: David S. Miller <[email protected]>

3. 删除了常量定义GENL_ID_GENERATE

git提交日志链接:
https://github.com/torvalds/l...

# 内核开发者日志3
genetlink: no longer support using static family IDs

Static family IDs have never really been used, the only
use case was the workaround I introduced for those users
that assumed their family ID was also their multicast
group ID.

Additionally, because static family IDs would never be
reserved by the generic netlink code, using a relatively
low ID would only work for built-in families that can be
registered immediately after generic netlink is started,
which is basically only the control family (apart from
the workaround code, which I also had to add code for so
it would reserve those IDs)

Thus, anything other than GENL_ID_GENERATE is flawed and
luckily not used except in the cases I mentioned. Move
those workarounds into a few lines of code, and then get
rid of GENL_ID_GENERATE entirely, making it more robust.

Signed-off-by: Johannes Berg <[email protected]>
Signed-off-by: David S. Miller <[email protected]>

Linux 3.13.0 API接口变更

  1. 删除了API函数genl_register_ops() / genl_unregister_ops()

git提交日志链接:
https://github.com/torvalds/l...

# 内核开发者日志
genetlink: remove genl_register_ops/genl_unregister_ops

genl_register_ops() is still needed for internal registration,
but is no longer available to users of the API.

Signed-off-by: Johannes Berg <[email protected]>
Signed-off-by: David S. Miller <[email protected]>

相关推荐