[PATCH 6.1 00/15] genetlink: Test Netlink subsystem of Linux v6.1

Yana Bashlykova posted 15 patches 4 months, 3 weeks ago
drivers/net/Kconfig                           |    2 +
drivers/net/Makefile                          |    2 +
drivers/net/genetlink/Kconfig                 |    8 +
drivers/net/genetlink/Makefile                |    3 +
.../net-pf-16-proto-16-family-PARALLEL_GENL.c | 1921 ++++++
tools/testing/selftests/net/Makefile          |    6 +
tools/testing/selftests/net/genetlink.c       | 5152 +++++++++++++++++
7 files changed, 7094 insertions(+)
create mode 100644 drivers/net/genetlink/Kconfig
create mode 100644 drivers/net/genetlink/Makefile
create mode 100644 drivers/net/genetlink/net-pf-16-proto-16-family-PARALLEL_GENL.c
create mode 100644 tools/testing/selftests/net/genetlink.c
[PATCH 6.1 00/15] genetlink: Test Netlink subsystem of Linux v6.1
Posted by Yana Bashlykova 4 months, 3 weeks ago
This series adds comprehensive testing infrastructure for Netlink
and Generic Netlink

The implementation includes both kernel module and userspace tests to
verify correct Generic Netlink and Netlink behaviors under
various conditions.

Yana Bashlykova (15):
  genetlink: add sysfs test module for Generic Netlink
  genetlink: add TEST_GENL family for netlink testing
  genetlink: add PARALLEL_GENL test family
  genetlink: add test case for duplicate genl family registration
  genetlink: add test case for family with invalid ops
  genetlink: add netlink notifier support
  genetlink: add THIRD_GENL family
  genetlink: verify unregister fails for non-registered family
  genetlink: add LARGE_GENL stress test family
  selftests: net: genetlink: add packet capture test infrastructure
  selftests: net: genetlink: add /proc/net/netlink test
  selftests: net: genetlink: add Generic Netlink controller tests
  selftests: net: genetlink: add large family ID resolution test
  selftests: net: genetlink: add Netlink and Generic Netlink test suite
  selftests: net: genetlink: fix expectation for large family resolution

 drivers/net/Kconfig                           |    2 +
 drivers/net/Makefile                          |    2 +
 drivers/net/genetlink/Kconfig                 |    8 +
 drivers/net/genetlink/Makefile                |    3 +
 .../net-pf-16-proto-16-family-PARALLEL_GENL.c | 1921 ++++++
 tools/testing/selftests/net/Makefile          |    6 +
 tools/testing/selftests/net/genetlink.c       | 5152 +++++++++++++++++
 7 files changed, 7094 insertions(+)
 create mode 100644 drivers/net/genetlink/Kconfig
 create mode 100644 drivers/net/genetlink/Makefile
 create mode 100644 drivers/net/genetlink/net-pf-16-proto-16-family-PARALLEL_GENL.c
 create mode 100644 tools/testing/selftests/net/genetlink.c

-- 
2.34.1
Re: [PATCH 6.1 00/15] genetlink: Test Netlink subsystem of Linux v6.1
Posted by Jakub Kicinski 4 months, 3 weeks ago
On Fri, 12 Sep 2025 22:53:23 +0300 Yana Bashlykova wrote:
> This series adds comprehensive testing infrastructure for Netlink
> and Generic Netlink
> 
> The implementation includes both kernel module and userspace tests to
> verify correct Generic Netlink and Netlink behaviors under
> various conditions.

What is the motivation for this work?
Re: [PATCH 6.1 00/15] genetlink: Test Netlink subsystem of Linux v6.1
Posted by Яна Башлыкова 3 months, 3 weeks ago
The motivation for this work is to improve the test coverage and
reliability of the Netlink subsystem, specifically for the core
af_netlink.c and genetlink.c components. While the subsystem is
critical for kernel-userspace communication, its coverage by the
existing selftests is quite limited.

To quantify the improvement, these new selftests achieve the following
line coverage (as measured by gcov):
- net/netlink/af_netlink.c: 84.0%
- net/netlink/genetlink.c: 88.8%

Integrating these tests into the upstream suite will provide long-term
stability and make it safer to refactor or add new features to the
Netlink core in the future.

пт, 12 сент. 2025 г. в 23:17, Jakub Kicinski <kuba@kernel.org>:


пт, 12 сент. 2025 г. в 23:17, Jakub Kicinski <kuba@kernel.org>:
>
> On Fri, 12 Sep 2025 22:53:23 +0300 Yana Bashlykova wrote:
> > This series adds comprehensive testing infrastructure for Netlink
> > and Generic Netlink
> >
> > The implementation includes both kernel module and userspace tests to
> > verify correct Generic Netlink and Netlink behaviors under
> > various conditions.
>
> What is the motivation for this work?
Re: [PATCH 6.1 00/15] genetlink: Test Netlink subsystem of Linux v6.1
Posted by Jakub Kicinski 3 months, 3 weeks ago
On Wed, 15 Oct 2025 17:49:22 +0300 Яна Башлыкова wrote:
> The motivation for this work is to improve the test coverage and
> reliability of the Netlink subsystem, specifically for the core
> af_netlink.c and genetlink.c components. While the subsystem is
> critical for kernel-userspace communication, its coverage by the
> existing selftests is quite limited.
> 
> To quantify the improvement, these new selftests achieve the following
> line coverage (as measured by gcov):
> - net/netlink/af_netlink.c: 84.0%
> - net/netlink/genetlink.c: 88.8%

For what it's worth syzbot has:

    af_netlink.c  91%
    genetlink.c   68%

Without a line of code added to the kernel. Of course it's not
functional testing.

> Integrating these tests into the upstream suite will provide long-term
> stability and make it safer to refactor or add new features to the
> Netlink core in the future.

Happy to hear from others if they disagree but what kernel tests get
merged into the tree is pretty subjective. Do we have a lot of bugs 
in genetlink? Are you planning to do major development in this area
and want to catch regressions? If the answers to both of those questions
is "no" IMHO this 7kLoC is not worth carrying in the tree.