Skip to content

tools: ynl: stop using libmnl

Jakub Kicinski netdev 3 versions – Applied

Status from this message: This series was applied to netdev/net-next.git (main)

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest15 patches 1 replyApplied 15/15
  2. v215 patches 5 repliesSuperseded
  3. v115 patches 27 repliesSuperseded

Changes in v3 from the cover letter

patch 2:
- assume 4B alignment for {s,u}{16,32} getters

Patches in v3 All 15 applied

#Subject and filesSizeRepliesApplied
1/15tools: ynl: give up on libmnl for auto-intstools/net/ynl/lib/ynl-priv.h+36 -90 repliesApplied
2/15tools: ynl: create local attribute helperstools/net/ynl/lib/ynl-priv.h tools/net/ynl/lib/ynl.c tools/net/ynl/ynl-gen-c.py+227 -741 replyApplied
3/15tools: ynl: create local for_each helperstools/net/ynl/lib/ynl-priv.h tools/net/ynl/lib/ynl.c tools/net/ynl/ynl-gen-c.py+57 -100 repliesApplied
4/15tools: ynl: create local nlmsg access helperstools/net/ynl/lib/ynl-priv.h tools/net/ynl/lib/ynl.c tools/net/ynl/ynl-gen-c.py+52 -170 repliesApplied
5/15tools: ynl: create local ARRAY_SIZE() helpertools/net/ynl/lib/ynl-priv.h tools/net/ynl/ynl-gen-c.py+5 -20 repliesApplied
6/15tools: ynl: make yarg the first member of struct ynl_dump_statetools/net/ynl/lib/ynl-priv.h tools/net/ynl/lib/ynl.c tools/net/ynl/ynl-gen-c.py+6 -70 repliesApplied
7/15tools: ynl-gen: remove unused parse codetools/net/ynl/lib/ynl-priv.h tools/net/ynl/lib/ynl.c tools/net/ynl/ynl-gen-c.py+1 -110 repliesApplied
8/15tools: ynl: wrap recv() + mnl_cb_run2() into a single helpertools/net/ynl/lib/ynl.c+18 -380 repliesApplied
9/15tools: ynl: use ynl_sock_read_msgs() for ACK handlingtools/net/ynl/lib/ynl-priv.h tools/net/ynl/lib/ynl.c+14 -230 repliesApplied
10/15tools: ynl: stop using mnl_cb_run2()tools/net/ynl/lib/ynl.c tools/net/ynl/lib/ynl.h+45 -190 repliesApplied
11/15tools: ynl: switch away from mnl_cb_ttools/net/ynl/lib/ynl-priv.h tools/net/ynl/lib/ynl.c tools/net/ynl/ynl-gen-c.py+21 -180 repliesApplied
12/15tools: ynl: switch away from MNL_CB_*tools/net/ynl/lib/ynl-priv.h tools/net/ynl/lib/ynl.c tools/net/ynl/ynl-gen-c.py+40 -340 repliesApplied
13/15tools: ynl: stop using mnl socket helperstools/net/ynl/lib/ynl-priv.h tools/net/ynl/lib/ynl.c tools/net/ynl/lib/ynl.h+42 -220 repliesApplied
14/15tools: ynl: remove the libmnl dependencytools/net/ynl/lib/ynl-priv.h tools/net/ynl/lib/ynl.c tools/net/ynl/samples/Makefile +1 more+2 -60 repliesApplied
15/15tools: ynl: use MSG_DONTWAIT for getting notificationstools/net/ynl/lib/ynl.c+14 -150 repliesApplied

Reviews trailers per patch

All 15 patches have a Reviewed-by or Acked-by.

PatchNicolas DichtelDonald Hunter
1/15A-b R-b
2/15A-b
3/15A-b
4/15A-b
5/15A-b
6/15A-b
7/15A-b
8/15A-b
9/15A-b
10/15A-b
11/15A-b
12/15A-b
13/15A-b
14/15A-b
15/15A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH net-next v3 00/15] tools: ynl: stop using libmnl

There is no strong reason to stop using libmnl in ynl but there are a few small ones which add up.

First (as I remembered immediately after hitting send on v1), C++ compilers do not like the libmnl for_each macros. I haven't tried it myself, but having all the code directly in YNL makes it easier for folks porting to C++ to modify them and/or make YNL more C++ friendly.

Second, we do much more advanced netlink level parsing in ynl than libmnl so it's hard to say that libmnl abstracts much from us. The fact that this series, removing the libmnl dependency, only adds <300 LoC shows that code savings aren't huge.
OTOH when new types are added (e.g. auto-int) we need to add compatibility to deal with older version of libmnl (in fact, even tho patches have been sent months ago, auto-ints are still not supported in libmnl.git).

Thrid, the dependency makes ynl less self contained, and harder to vendor in. Whether vendoring libraries into projects is a good idea is a separate discussion, nonetheless, people want to do it.

Fourth, there are small annoyances with the libmnl APIs which are hard to fix in backward-compatible ways. See the last patch for example.

All in all, libmnl is a great library, but with all the code generation and structured parsing, ynl is better served by going its own way.

v3:
patch 2:
- assume 4B alignment for {s,u}{16,32} getters
v2:
patch 2:
- NLA_ALIGN(sizeof(struct nlattr)) -> NLA_HDRLEN;
- ...put_strz() -> ...put_str()
- use ynl_attr_data() in ynl_attr_get_{str,s8,u8}()
- use signed helpers in signed auto-ints
- use ynl_attr_get_str() instead of ynl_attr_data() in ynl.c
patch 8:
- extend commit message
patch 10:
- fold NLMSG_NEXT(nlh, rem) into the for () statement

v1: https://lore.kernel.org/all/[email protected]/

Jakub Kicinski (15):
tools: ynl: give up on libmnl for auto-ints
tools: ynl: create local attribute helpers
tools: ynl: create local for_each helpers
tools: ynl: create local nlmsg access helpers
tools: ynl: create local ARRAY_SIZE() helper
tools: ynl: make yarg the first member of struct ynl_dump_state
tools: ynl-gen: remove unused parse code
tools: ynl: wrap recv() + mnl_cb_run2() into a single helper
tools: ynl: use ynl_sock_read_msgs() for ACK handling
tools: ynl: stop using mnl_cb_run2()
tools: ynl: switch away from mnl_cb_t
tools: ynl: switch away from MNL_CB_*
tools: ynl: stop using mnl socket helpers
tools: ynl: remove the libmnl dependency
tools: ynl: use MSG_DONTWAIT for getting notifications

 tools/net/ynl/lib/ynl-priv.h   | 333 +++++++++++++++++++++++++++---
 tools/net/ynl/lib/ynl.c        | 365 +++++++++++++++++----------------
 tools/net/ynl/lib/ynl.h        |   3 +-
 tools/net/ynl/samples/Makefile |   2 +-
 tools/net/ynl/ynl-gen-c.py     | 110 ++++------
 5 files changed, 544 insertions(+), 269 deletions(-)
Signature · 1 line
2.43.2