All of lore.kernel.org
 help / color / mirror / Atom feed
* Bug when updating ICMP flows using conntrack tools
@ 2021-03-18  6:38 Luuk Paulussen
  2021-03-18 13:01 ` Florian Westphal
  0 siblings, 1 reply; 4+ messages in thread
From: Luuk Paulussen @ 2021-03-18  6:38 UTC (permalink / raw)
  To: netfilter-devel

Hi,

We recently upgraded the version of conntrack-tools and libnetfilter-conntrack that we are using and have found a bug when using conntrack to update ICMP flows. I've tracked down where the bug is occurring, but am looking for some guidance on the preferred way to fix it.

E.g. Doing the following when there are icmp flows present has no effect on ICMP flows:
conntrack -f ipv4 -U --mark=1

In conntrack-tools in conntrack.c in update_cb, the ORIG data and META data are copied, but not the REPL data. This has been this way for quite some time.
nfct_copy(tmp, ct, NFCT_CP_ORIG);
nfct_copy(tmp, obj, NFCT_CP_META);

However, in libnetfilter-conntrack the way that the message is built has been changed, and in nfct_nlmsg_build, the check about whether to build the REPL tuple has been extended to include
test_bit(ATTR_ICMP_TYPE, ct->head.set) ||
test_bit(ATTR_ICMP_CODE, ct->head.set) ||
test_bit(ATTR_ICMP_ID, ct->head.set)

In the old building functions, these bits weren't present, so it wouldn't try to build the REPL tuple, so everything worked. However, now it tries to build the REPL tuple, and because none of the REPL data is present, building the tuple fails and it errors out without sending the request to the kernel.

My question is whether it is better to remove the checks in libnetfilter-conntrack or add the copy of the REPL data in conntrack tools.

Upgraded:
libnetfilter-conntrack from 1.0.6 to 1.0.8
conntrack-tools from 1.4.4 to 1.4.6

Kind regards,
Luuk

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Bug when updating ICMP flows using conntrack tools
  2021-03-18  6:38 Bug when updating ICMP flows using conntrack tools Luuk Paulussen
@ 2021-03-18 13:01 ` Florian Westphal
  2021-03-18 19:59   ` [PATCH libnetfilter_conntrack] conntrack: Don't use ICMP attrs in decision to build repl tuple Luuk Paulussen
  0 siblings, 1 reply; 4+ messages in thread
From: Florian Westphal @ 2021-03-18 13:01 UTC (permalink / raw)
  To: Luuk Paulussen; +Cc: netfilter-devel

Luuk Paulussen <Luuk.Paulussen@alliedtelesis.co.nz> wrote:
> However, in libnetfilter-conntrack the way that the message is built has been changed, and in nfct_nlmsg_build, the check about whether to build the REPL tuple has been extended to include
> test_bit(ATTR_ICMP_TYPE, ct->head.set) ||
> test_bit(ATTR_ICMP_CODE, ct->head.set) ||
> test_bit(ATTR_ICMP_ID, ct->head.set)

That looks like a bug, those checks should only be done for ORIG.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH libnetfilter_conntrack] conntrack: Don't use ICMP attrs in decision to build repl tuple
  2021-03-18 13:01 ` Florian Westphal
@ 2021-03-18 19:59   ` Luuk Paulussen
  2021-03-19 14:00     ` Pablo Neira Ayuso
  0 siblings, 1 reply; 4+ messages in thread
From: Luuk Paulussen @ 2021-03-18 19:59 UTC (permalink / raw)
  To: netfilter-devel; +Cc: Luuk Paulussen

conntrack-tools doesn't set the REPL attributes by default for updates,
so for ICMP flows, the update won't be sent as building the repl tuple
will fail.

Signed-off-by: Luuk Paulussen <luuk.paulussen@alliedtelesis.co.nz>
---
 src/conntrack/build_mnl.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/src/conntrack/build_mnl.c b/src/conntrack/build_mnl.c
index d9ad268..0067a1c 100644
--- a/src/conntrack/build_mnl.c
+++ b/src/conntrack/build_mnl.c
@@ -496,10 +496,7 @@ nfct_nlmsg_build(struct nlmsghdr *nlh, const struct nf_conntrack *ct)
 	    test_bit(ATTR_REPL_PORT_DST, ct->head.set) ||
 	    test_bit(ATTR_REPL_L3PROTO, ct->head.set) ||
 	    test_bit(ATTR_REPL_L4PROTO, ct->head.set) ||
-	    test_bit(ATTR_REPL_ZONE, ct->head.set) ||
-	    test_bit(ATTR_ICMP_TYPE, ct->head.set) ||
-	    test_bit(ATTR_ICMP_CODE, ct->head.set) ||
-	    test_bit(ATTR_ICMP_ID, ct->head.set)) {
+	    test_bit(ATTR_REPL_ZONE, ct->head.set)) {
 		const struct __nfct_tuple *t = &ct->repl;
 		struct nlattr *nest;
 
-- 
2.31.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH libnetfilter_conntrack] conntrack: Don't use ICMP attrs in decision to build repl tuple
  2021-03-18 19:59   ` [PATCH libnetfilter_conntrack] conntrack: Don't use ICMP attrs in decision to build repl tuple Luuk Paulussen
@ 2021-03-19 14:00     ` Pablo Neira Ayuso
  0 siblings, 0 replies; 4+ messages in thread
From: Pablo Neira Ayuso @ 2021-03-19 14:00 UTC (permalink / raw)
  To: Luuk Paulussen; +Cc: netfilter-devel

On Fri, Mar 19, 2021 at 08:59:19AM +1300, Luuk Paulussen wrote:
> conntrack-tools doesn't set the REPL attributes by default for updates,
> so for ICMP flows, the update won't be sent as building the repl tuple
> will fail.

Applied, thanks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-03-19 14:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-18  6:38 Bug when updating ICMP flows using conntrack tools Luuk Paulussen
2021-03-18 13:01 ` Florian Westphal
2021-03-18 19:59   ` [PATCH libnetfilter_conntrack] conntrack: Don't use ICMP attrs in decision to build repl tuple Luuk Paulussen
2021-03-19 14:00     ` Pablo Neira Ayuso

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.