Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp287785pxu; Wed, 14 Oct 2020 01:00:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxckKUU59zMyL8ioebdIi1Sl1/mqceHKe0/RxnZSEIWMR8x6oTD94zel6WCrtcv+O3dxCz4 X-Received: by 2002:a05:6402:293:: with SMTP id l19mr3860512edv.227.1602662412300; Wed, 14 Oct 2020 01:00:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602662412; cv=none; d=google.com; s=arc-20160816; b=q5e2sdtCogbYoY3Y2iyXWPT8Dx7yi9NTC2OO8CbIXzRdjFDJ5e1GLHiGKbtzZ2KhUa obnzZ8uftNEL5aMiVHwuwr5ejLGK7ykcZr9HTwmwIn9Db/LZBEJp0w5hDiKrlXQc67XC UOSh0xhN4AN3ee4QNyafednrYlKyt4tA13NHdCAyHuwcXlC/ioc68Vm8RMkG/RDMOglj k4QL5oaUxJgz7GwUpIJdtHaH2yK4i/rBqfT4IAJ6xmUhsa5u/FZ+4rgvKen8Zp7GYsFB ECMfyyWUZYCOFXOX8+fQzkyBFIbCfEURmNI8Pv8OolaWsGE+M0ArUL+xPgNfbHugyhll mP5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=znYyDxWEJWMIQJDSeZHeba7I3qsRBnyVWt6cxFFaCcY=; b=OMu4U5ISB8NJPhT4cvGQjji4bQlhwM24Ju5yRYGheut5yK7Y03sSvsrFEL15UiC01/ egRwOzmvCZrxjzdS9drFHPaFXStOsIaR+D5tEw3ByBTr5DOBUSdLOhOvNEiTGmqX8Qtm Unudf38qQuIERV0xH4pnoIynVeIJZkP5V+0ObK53W3VVoMAkRWpsRTJefRGbG5Ec0gGW EgM7nFgqe9DzOwvDzeOFeIELLnefApQbuJcU35AZclZtCGk1Jc7kpBo9Sol0d7gY8GvS 16ETLnw52eKULJnDAbPlgwRp+D39WvqPFbHYs0bRHyd8PnkoTjk+64Eg6sF43O9+3/Ry +Bnw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u23si1668739edo.41.2020.10.14.00.59.49; Wed, 14 Oct 2020 01:00:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726841AbgJNAGd (ORCPT + 99 others); Tue, 13 Oct 2020 20:06:33 -0400 Received: from correo.us.es ([193.147.175.20]:36372 "EHLO mail.us.es" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726168AbgJNAGc (ORCPT ); Tue, 13 Oct 2020 20:06:32 -0400 Received: from antivirus1-rhel7.int (unknown [192.168.2.11]) by mail.us.es (Postfix) with ESMTP id DDD45E780A for ; Wed, 14 Oct 2020 02:06:30 +0200 (CEST) Received: from antivirus1-rhel7.int (localhost [127.0.0.1]) by antivirus1-rhel7.int (Postfix) with ESMTP id CB71EDA78D for ; Wed, 14 Oct 2020 02:06:30 +0200 (CEST) Received: by antivirus1-rhel7.int (Postfix, from userid 99) id C08E8DA73D; Wed, 14 Oct 2020 02:06:30 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on antivirus1-rhel7.int X-Spam-Level: X-Spam-Status: No, score=-108.2 required=7.5 tests=ALL_TRUSTED,BAYES_50, SMTPAUTH_US2,URIBL_BLOCKED,USER_IN_WELCOMELIST,USER_IN_WHITELIST autolearn=disabled version=3.4.1 Received: from antivirus1-rhel7.int (localhost [127.0.0.1]) by antivirus1-rhel7.int (Postfix) with ESMTP id CA40CDA72F; Wed, 14 Oct 2020 02:06:28 +0200 (CEST) Received: from 192.168.1.97 (192.168.1.97) by antivirus1-rhel7.int (F-Secure/fsigk_smtp/550/antivirus1-rhel7.int); Wed, 14 Oct 2020 02:06:28 +0200 (CEST) X-Virus-Status: clean(F-Secure/fsigk_smtp/550/antivirus1-rhel7.int) Received: from us.es (unknown [90.77.255.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: 1984lsi) by entrada.int (Postfix) with ESMTPSA id A091D42EFB80; Wed, 14 Oct 2020 02:06:28 +0200 (CEST) Date: Wed, 14 Oct 2020 02:06:28 +0200 X-SMTPAUTHUS: auth mail.us.es From: Pablo Neira Ayuso To: Florian Westphal Cc: Jozsef Kadlecsik , Francesco Ruggeri , open list , netdev , coreteam@netfilter.org, netfilter-devel@vger.kernel.org, Jakub Kicinski , David Miller Subject: Re: [PATCH nf v2] netfilter: conntrack: connection timeout after re-register Message-ID: <20201014000628.GA15290@salvia> References: <20201007193252.7009D95C169C@us180.sjc.aristanetworks.com> <20201009110323.GC5723@breakpoint.cc> <20201009185552.GF5723@breakpoint.cc> <20201009200548.GG5723@breakpoint.cc> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20201009200548.GG5723@breakpoint.cc> User-Agent: Mutt/1.10.1 (2018-07-13) X-Virus-Scanned: ClamAV using ClamSMTP Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 09, 2020 at 10:05:48PM +0200, Florian Westphal wrote: > Jozsef Kadlecsik wrote: > > > The "delay unregister" remark was wrt. the "all rules were deleted" > > > case, i.e. add a "grace period" rather than acting right away when > > > conntrack use count did hit 0. > > > > Now I understand it, thanks really. The hooks are removed, so conntrack > > cannot "see" the packets and the entries become stale. > > Yes. > > > What is the rationale behind "remove the conntrack hooks when there are no > > rule left referring to conntrack"? Performance optimization? But then the > > content of the whole conntrack table could be deleted too... ;-) > > Yes, this isn't the case at the moment -- only hooks are removed, > entries will eventually time out. > > > > Conntrack entries are not removed, only the base hooks get unregistered. > > > This is a problem for tcp window tracking. > > > > > > When re-register occurs, kernel is supposed to switch the existing > > > entries to "loose" mode so window tracking won't flag packets as > > > invalid, but apparently this isn't enough to handle keepalive case. > > > > "loose" (nf_ct_tcp_loose) mode doesn't disable window tracking, it > > enables/disables picking up already established connections. > > > > nf_ct_tcp_be_liberal would disable TCP window checking (but not tracking) > > for non RST packets. > > You are right, mixup on my part. > > > But both seems to be modified only via the proc entries. > > Yes, we iterate table on re-register and modify the existing entries. For iptables-nft, it might be possible to avoid this deregister + register ct hooks in the same transaction: Maybe add something like nf_ct_netns_get_all() to bump refcounters by one _iff_ they are > 0 before starting the transaction processing, then call nf_ct_netns_put_all() which decrements refcounters and unregister hooks if they reach 0. The only problem with this approach is that this pulls in the conntrack module, to solve that, struct nf_ct_hook in net/netfilter/core.c could be used to store the reference to ->netns_get_all and ->net_put_all. Legacy would still be flawed though.