]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
netfilter: use NF_DROP instead of -NF_DROP
authorJason Xing <kernelxing@tencent.com>
Mon, 25 Mar 2024 12:36:14 +0000 (20:36 +0800)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 6 May 2024 14:29:21 +0000 (16:29 +0200)
At the beginning in 2009 one patch [1] introduced collecting drop
counter in nf_conntrack_in() by returning -NF_DROP. Later, another
patch [2] changed the return value of tcp_packet() which now is
renamed to nf_conntrack_tcp_packet() from -NF_DROP to NF_DROP. As
we can see, that -NF_DROP should be corrected.

Similarly, there are other two points where the -NF_DROP is used.

Well, as NF_DROP is equal to 0, inverting NF_DROP makes no sense
as patch [2] said many years ago.

[1]
commit 7d1e04598e5e ("netfilter: nf_conntrack: account packets drop by tcp_packet()")
[2]
commit ec8d540969da ("netfilter: conntrack: fix dropping packet after l4proto->packet()")

Signed-off-by: Jason Xing <kernelxing@tencent.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/ipv4/netfilter/iptable_filter.c
net/ipv6/netfilter/ip6table_filter.c
net/netfilter/nf_conntrack_core.c

index b9062f4552ace52cf23f7b0543b69ba166e2eecd..3ab908b74795177fa037a0381547076d1d248107 100644 (file)
@@ -44,7 +44,7 @@ static int iptable_filter_table_init(struct net *net)
                return -ENOMEM;
        /* Entry 1 is the FORWARD hook */
        ((struct ipt_standard *)repl->entries)[1].target.verdict =
-               forward ? -NF_ACCEPT - 1 : -NF_DROP - 1;
+               forward ? -NF_ACCEPT - 1 : NF_DROP - 1;
 
        err = ipt_register_table(net, &packet_filter, repl, filter_ops);
        kfree(repl);
index df785ebda0ca43ebdfe364da3a7ca051ce46aa79..e8992693e14a041758d53a3daad2084d6a555760 100644 (file)
@@ -43,7 +43,7 @@ static int ip6table_filter_table_init(struct net *net)
                return -ENOMEM;
        /* Entry 1 is the FORWARD hook */
        ((struct ip6t_standard *)repl->entries)[1].target.verdict =
-               forward ? -NF_ACCEPT - 1 : -NF_DROP - 1;
+               forward ? -NF_ACCEPT - 1 : NF_DROP - 1;
 
        err = ip6t_register_table(net, &packet_filter, repl, filter_ops);
        kfree(repl);
index c63868666bd9e5819bdfef9986ab9d46d0e7475f..6102dc09cdd3efef46472602a738977f0c11fb5b 100644 (file)
@@ -2024,7 +2024,7 @@ repeat:
                        goto repeat;
 
                NF_CT_STAT_INC_ATOMIC(state->net, invalid);
-               if (ret == -NF_DROP)
+               if (ret == NF_DROP)
                        NF_CT_STAT_INC_ATOMIC(state->net, drop);
 
                ret = -ret;