Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp2298269pxu; Fri, 9 Oct 2020 13:01:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxta1xiiaESMeFazfEHUmvHGoeIABdTJ1E1Q1byMTzvnBWtnlfCcuOOzKGkQgUMIfH4/IPl X-Received: by 2002:a17:907:208b:: with SMTP id pv11mr16650317ejb.426.1602273682769; Fri, 09 Oct 2020 13:01:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602273682; cv=none; d=google.com; s=arc-20160816; b=mDUDOtM4QswC1fiz+hFyB7QJiG5V1lGPjRbwRam1zIujp+j7jy5qkj2KEoc3FPfJyw FgAWq4/iOqtWNrhhDuDmNcmoScV3zC/zCv26Oy/5rt9omJBiD4EwcWlLK4Rn2s26Xs1s Sco/cgL5J/2r1/u9PwHGg9zzd80ef/p061acHV96tL9ZwV1JJ9Rw66oVIsT18dbgVIo/ KzPbj4IKlP95uF5+Iu2bbc1THW8vMzQ775P1ND2RMBGS4ihmgUvl0+SQaJMDJaGkal54 BDnAZ+8yrY5KGwLHoPpuF5GFXBPh5rZTRGdLzIG6NcBFf+DZqBYqFnYeo0aavrO5vSmT SyCg== 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=kkwOJ2iqnmZ5XqH4TUGWfWuntTeSMxXLjCv2daEu0Qg=; b=xevaTsOPtO8e/WF8pYlsqlXiBNY1iQ5j0x9RLs8mA4qPAT4q2HsS3U5dOb7qTKdM58 oHKb0WA68w5GdLT98OnpqKvCWOA8BtFE2ax2CXt3WWSDsmFp0ll3RhaRsw8Ndj3qg4YH dCQ9K3kMm/8rdRNHdEh1Rp124HW1QGQtxO2i/4i9nmygx01rVK+vcvWKfZhljIs4krl7 OMtsjstuXKpQ+TTZZ0nvakqqpwsAjlO4eJZuDrhji7QnOHtHgKmVjodK6A8c3jUrSxUV +OuF5NBS6mAc3lNV6qfvlOKVEU1RMwi9Cwr3E3p/E0H6+EIqw+SyrqP1xOe5hVcfHIqT GupQ== 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 k12si6391853ejd.562.2020.10.09.13.00.59; Fri, 09 Oct 2020 13:01:22 -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 S2388280AbgJISz7 (ORCPT + 99 others); Fri, 9 Oct 2020 14:55:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388184AbgJISz7 (ORCPT ); Fri, 9 Oct 2020 14:55:59 -0400 Received: from Chamillionaire.breakpoint.cc (Chamillionaire.breakpoint.cc [IPv6:2a0a:51c0:0:12e:520::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 325D7C0613D2; Fri, 9 Oct 2020 11:55:59 -0700 (PDT) Received: from fw by Chamillionaire.breakpoint.cc with local (Exim 4.92) (envelope-from ) id 1kQxYW-0000rj-1m; Fri, 09 Oct 2020 20:55:52 +0200 Date: Fri, 9 Oct 2020 20:55:52 +0200 From: Florian Westphal To: Jozsef Kadlecsik Cc: Florian Westphal , Francesco Ruggeri , open list , netdev , coreteam@netfilter.org, netfilter-devel@vger.kernel.org, Jakub Kicinski , David Miller , fw@strlen.org, Pablo Neira Ayuso Subject: Re: [PATCH nf v2] netfilter: conntrack: connection timeout after re-register Message-ID: <20201009185552.GF5723@breakpoint.cc> References: <20201007193252.7009D95C169C@us180.sjc.aristanetworks.com> <20201009110323.GC5723@breakpoint.cc> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Jozsef Kadlecsik wrote: > > The repro clears all rules, waits 4 seconds, then restores the ruleset. > > using iptables-restore < FOO; sleep 4; iptables-restore < FOO will not > > result in any unregister ops. > > > > We could make kernel defer unregister via some work queue but i don't > > see what this would help/accomplish (and its questionable of how long it > > should wait). > > Sorry, I can't put together the two paragraphs above: in the first you > wrote that no (hook) unregister-register happens and in the second one > that those could be derefed. Sorry, my reply is confusing indeed. Matches/targets that need conntrack increment a refcount. So, when all rules are flushed, refcount goes down to 0 and conntrack is disabled because the hooks get removed.. Just doing iptables-restore doesn't unregister as long as both the old and new rulesets need conntrack. 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. > > We could disallow unregister, but that seems silly (forces reboot...). > > > > I think the patch is fine. > > The patch is fine, but why the packets are handled by conntrack (after the > first restore and during the 4s sleep? And then again after the second > restore?) as if all conntrack entries were removed? 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.