All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH nf-next] netfilter: ctnetlink: always include remaining timeout
@ 2020-12-10 11:20 Florian Westphal
  2020-12-10 13:19 ` Pablo Neira Ayuso
  0 siblings, 1 reply; 3+ messages in thread
From: Florian Westphal @ 2020-12-10 11:20 UTC (permalink / raw)
  To: netfilter-devel; +Cc: Florian Westphal

DESTROY events do not include the remaining timeout.

Unconditionally including the timeout allows to see if the entry timed
timed out or was removed explicitly.

The latter case can happen when a conntrack gets deleted prematurely,
e.g. due to a tcp reset, module removal, netdev notifier (nat/masquerade
device went down), ctnetlink and so on.

Signed-off-by: Florian Westphal <fw@strlen.de>
---
 Might make sense to further extend nf_ct_delete and also pass a
 reason code in the future.

 net/netfilter/nf_conntrack_netlink.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c
index 3d0fd33be018..3f957769cd72 100644
--- a/net/netfilter/nf_conntrack_netlink.c
+++ b/net/netfilter/nf_conntrack_netlink.c
@@ -778,15 +778,14 @@ ctnetlink_conntrack_event(unsigned int events, struct nf_ct_event *item)
 
 	if (ctnetlink_dump_status(skb, ct) < 0)
 		goto nla_put_failure;
+	if (ctnetlink_dump_timeout(skb, ct) < 0)
+		goto nla_put_failure;
 
 	if (events & (1 << IPCT_DESTROY)) {
 		if (ctnetlink_dump_acct(skb, ct, type) < 0 ||
 		    ctnetlink_dump_timestamp(skb, ct) < 0)
 			goto nla_put_failure;
 	} else {
-		if (ctnetlink_dump_timeout(skb, ct) < 0)
-			goto nla_put_failure;
-
 		if (events & (1 << IPCT_PROTOINFO)
 		    && ctnetlink_dump_protoinfo(skb, ct) < 0)
 			goto nla_put_failure;
-- 
2.26.2


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

* Re: [PATCH nf-next] netfilter: ctnetlink: always include remaining timeout
  2020-12-10 11:20 [PATCH nf-next] netfilter: ctnetlink: always include remaining timeout Florian Westphal
@ 2020-12-10 13:19 ` Pablo Neira Ayuso
  2020-12-10 13:32   ` Florian Westphal
  0 siblings, 1 reply; 3+ messages in thread
From: Pablo Neira Ayuso @ 2020-12-10 13:19 UTC (permalink / raw)
  To: Florian Westphal; +Cc: netfilter-devel

On Thu, Dec 10, 2020 at 12:20:22PM +0100, Florian Westphal wrote:
> DESTROY events do not include the remaining timeout.
> 
> Unconditionally including the timeout allows to see if the entry timed
> timed out or was removed explicitly.
> 
> The latter case can happen when a conntrack gets deleted prematurely,
> e.g. due to a tcp reset, module removal, netdev notifier (nat/masquerade
> device went down), ctnetlink and so on.
>
> Signed-off-by: Florian Westphal <fw@strlen.de>
> ---
>  Might make sense to further extend nf_ct_delete and also pass a
>  reason code in the future.

IIRC, TCP state is not included in the event, right?

This has been requested many times in the past, to debug connectivity
issues too.

Probably extending .to_nlattr to take a bool parameter to specify if
this is the destroy event path, then _only_ include the TCP state
information there (other TCP information is not relevant and netlink
bandwidth is limited from the event path).

Thanks.

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

* Re: [PATCH nf-next] netfilter: ctnetlink: always include remaining timeout
  2020-12-10 13:19 ` Pablo Neira Ayuso
@ 2020-12-10 13:32   ` Florian Westphal
  0 siblings, 0 replies; 3+ messages in thread
From: Florian Westphal @ 2020-12-10 13:32 UTC (permalink / raw)
  To: Pablo Neira Ayuso; +Cc: Florian Westphal, netfilter-devel

Pablo Neira Ayuso <pablo@netfilter.org> wrote:
> On Thu, Dec 10, 2020 at 12:20:22PM +0100, Florian Westphal wrote:
> > DESTROY events do not include the remaining timeout.
> > 
> > Unconditionally including the timeout allows to see if the entry timed
> > timed out or was removed explicitly.
> > 
> > The latter case can happen when a conntrack gets deleted prematurely,
> > e.g. due to a tcp reset, module removal, netdev notifier (nat/masquerade
> > device went down), ctnetlink and so on.
> >
> > Signed-off-by: Florian Westphal <fw@strlen.de>
> > ---
> >  Might make sense to further extend nf_ct_delete and also pass a
> >  reason code in the future.
> 
> IIRC, TCP state is not included in the event, right?

No, protoinfo is only dumped for non-destroy case.

> This has been requested many times in the past, to debug connectivity
> issues too.
> 
> Probably extending .to_nlattr to take a bool parameter to specify if
> this is the destroy event path, then _only_ include the TCP state
> information there (other TCP information is not relevant and netlink
> bandwidth is limited from the event path).

Sounds reasonable, will send a v2.

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

end of thread, other threads:[~2020-12-10 13:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-10 11:20 [PATCH nf-next] netfilter: ctnetlink: always include remaining timeout Florian Westphal
2020-12-10 13:19 ` Pablo Neira Ayuso
2020-12-10 13:32   ` Florian Westphal

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.