]> git.ipfire.org Git - thirdparty/ipset.git/commitdiff
ip_set: Fix compatibility with kernels between v3.3 and v4.5
authorSerhey Popovych <serhe.popovych@gmail.com>
Thu, 5 Mar 2020 15:28:24 +0000 (17:28 +0200)
committerJozsef Kadlecsik <kadlec@netfilter.org>
Mon, 9 Mar 2020 11:09:55 +0000 (12:09 +0100)
These kernels does not have in their @struct netlink_dump_control method
that is used to prepare for netlink dump ->start(). This affects all
kernels that does not contain commit fc9e50f5a5a4 ("netlink: add a start
callback for starting a netlink dump").

Introduce fake value of HAVE_NETLINK_DUMP_START_ARGS equal to 7 that
never spot in the wild and set HAVE_NETLINK_DUMP_START_ARGS to 4 only
after explicit test if ->start() is available.

Fixes: 7725bf5ba041 ("netfilter: ipset: fix suspicious RCU usage in find_set_and_id")
Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
Signed-off-by: Jozsef Kadlecsik <kadlec@netfilter.org>
configure.ac
kernel/net/netfilter/ipset/ip_set_core.c

index c7077558d26aa05c8aeac37066ac97e04efecc7a..d3a2758d8456798d39e64e88b32f68a77c15610f 100644 (file)
@@ -319,9 +319,13 @@ elif test -f $ksourcedir/include/linux/netlink.h && \
    $AWK '/ netlink_dump_start\(/,/\)/' $ksourcedir/include/linux/netlink.h | $GREP -q 'min_dump_alloc.*;'; then
        AC_MSG_RESULT(6 args)
        AC_SUBST(HAVE_NETLINK_DUMP_START_ARGS, 6)
-else
+elif test -f $ksourcedir/include/linux/netlink.h && \
+   $AWK '/^struct netlink_dump_control {/,/\}/' $ksourcedir/include/linux/netlink.h | $GREP -q '\(\*start\)'; then
        AC_MSG_RESULT(4 args)
        AC_SUBST(HAVE_NETLINK_DUMP_START_ARGS, 4)
+else
+       AC_MSG_RESULT(7 fake args)
+       AC_SUBST(HAVE_NETLINK_DUMP_START_ARGS, 7)
 fi
 
 AC_MSG_CHECKING([kernel source for ns_capable])
index 082d89d704cf9698c986889ae036308b01c1fbad..906d01a05f524ef5e33f958c475012fa03394808 100644 (file)
@@ -1734,7 +1734,9 @@ IPSET_CBFN(ip_set_dump, struct net *net, struct sock *ctnl,
 #else
        {
                struct netlink_dump_control c = {
+#if HAVE_NETLINK_DUMP_START_ARGS == 4
                        .start = ip_set_dump_start,
+#endif
                        .dump = ip_set_dump_do,
                        .done = ip_set_dump_done,
                };