Skip to content

netlink: remove mmapped netlink support

Florian Westphal netdev 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest5 patches 2 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5netlink: remove mmapped netlink supportDocumentation/networking/netlink_mmap.txt include/uapi/linux/netlink.h include/uapi/linux/netlink_diag.h +4 more+15 -11400 replies
2/5openvswitch: Revert: "Enable memory mapped Netlink i/o"net/openvswitch/datapath.c+3 -70 replies
3/5Revert "genl: Add genlmsg_new_unicast() for unicast message allocation"include/net/genetlink.h net/netlink/genetlink.c net/openvswitch/datapath.c +1 more+5 -310 replies
4/5nfnetlink: remove nfnetlink_alloc_skbinclude/linux/netfilter/nfnetlink.h net/netfilter/nfnetlink.c net/netfilter/nfnetlink_log.c+2 -120 replies
5/5nfnetlink: Revert "nfnetlink: add support for memory mapped netlink"include/linux/netlink.h net/netfilter/nfnetlink_queue.c net/netlink/af_netlink.c+6 -300 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH -next 0/5] netlink: remove mmapped netlink support

As discussed during netconf 2016 in Seville, this series removes CONFIG_NETLINK_MMAP.

Close to three years after it was merged it has retained several problems that do not appear to be fixable.

No official netfilter libmnl release contains support for mmap backed netlink sockets. No openvswitch release makes use of it either.

To use the mmap interface, userspace not only has to probe for mmap netlink support, it also has to implement a recv/socket receive path in order to handle messages that exceed the size of an rx ring element (NL_MMAP_STATUS_COPY).

So if there are odd programs out there that attempt to use MMAP netlink they should continue to work as they already need a socket based code path to work properly.

The actual revert (first patch) has a list of problems.
The followup patches remove a couple of helpers that are no longer needed after the revert.

I did a few tests with mmap vs. socket based interface on a 4.4 based kernel on an i7-4790 box and there are no performance advantages:

loopback, single nfqueue, queueing in -t filter INPUT:
traffic generated by 8 * ping -q -f localhost:
socket backend:

# time ./nfqdump -c 10000000 > /dev/null
real    0m27.325s
user    0m3.993s
sys     0m23.292s

with mmap ring backend:

# time LD_PRELOAD=../../src/.libs/libmnl.so .libs/nf-queue 0 > /dev/null
real    0m29.054s
user    0m4.924s
sys     0m24.127s

with single tcp stream, unidirectional, loopback mtu set at 1500 (nc localhost discard < /dev/zero > /dev/null):

socket interface:
time nfqdump -b $((8 * 1024 * 1024 * 1024)) -w /dev/null

real    0m15.960s
user    0m1.756s
sys     0m11.143s

mmap ring:

real    0m16.441s
user    0m3.040s
sys     0m13.687s

socket interface nfqdump[1] with --gso option (i.e. MTU is exceeded, no kernel-side segmentation and checksum fixups) completes in about 5s.

I also tested dumping a conntrack table with 1m entries.
On my box this takes about 2.4 seconds for both mmap and socket backend:

time LD_PRELOAD=../../src/.libs/libmnl.so ./nfct-dump-sk > /dev/null
mnl_cb_run: Success
messages: 1000000

real    0m2.485s
user    0m1.085s
sys     0m1.400s

time LD_PRELOAD=../../src/.libs/libmnl.so ./nfct-dump-mmap > /dev/null
messages: 1000000

real    0m2.451s
user    0m1.124s
sys     0m1.328s

[1] https://git.breakpoint.cc/cgit/fw/nfqdump.git/