Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

netfilter: use NF_DROP instead of -NF_DROP

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>

authored by

Jason Xing and committed by
Pablo Neira Ayuso
8edc27fc 40616789

+3 -3
+1 -1
net/ipv4/netfilter/iptable_filter.c
··· 44 44 return -ENOMEM; 45 45 /* Entry 1 is the FORWARD hook */ 46 46 ((struct ipt_standard *)repl->entries)[1].target.verdict = 47 - forward ? -NF_ACCEPT - 1 : -NF_DROP - 1; 47 + forward ? -NF_ACCEPT - 1 : NF_DROP - 1; 48 48 49 49 err = ipt_register_table(net, &packet_filter, repl, filter_ops); 50 50 kfree(repl);
+1 -1
net/ipv6/netfilter/ip6table_filter.c
··· 43 43 return -ENOMEM; 44 44 /* Entry 1 is the FORWARD hook */ 45 45 ((struct ip6t_standard *)repl->entries)[1].target.verdict = 46 - forward ? -NF_ACCEPT - 1 : -NF_DROP - 1; 46 + forward ? -NF_ACCEPT - 1 : NF_DROP - 1; 47 47 48 48 err = ip6t_register_table(net, &packet_filter, repl, filter_ops); 49 49 kfree(repl);
+1 -1
net/netfilter/nf_conntrack_core.c
··· 2024 2024 goto repeat; 2025 2025 2026 2026 NF_CT_STAT_INC_ATOMIC(state->net, invalid); 2027 - if (ret == -NF_DROP) 2027 + if (ret == NF_DROP) 2028 2028 NF_CT_STAT_INC_ATOMIC(state->net, drop); 2029 2029 2030 2030 ret = -ret;