From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 019F4C43460 for ; Wed, 5 May 2021 11:10:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C6992613C7 for ; Wed, 5 May 2021 11:10:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232859AbhEELLl (ORCPT ); Wed, 5 May 2021 07:11:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232596AbhEELLe (ORCPT ); Wed, 5 May 2021 07:11:34 -0400 Received: from Chamillionaire.breakpoint.cc (Chamillionaire.breakpoint.cc [IPv6:2a0a:51c0:0:12e:520::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 701F1C061574; Wed, 5 May 2021 04:10:26 -0700 (PDT) Received: from fw by Chamillionaire.breakpoint.cc with local (Exim 4.92) (envelope-from ) id 1leFPx-0002TT-22; Wed, 05 May 2021 13:10:13 +0200 Date: Wed, 5 May 2021 13:10:13 +0200 From: Florian Westphal To: Cole Dishington Cc: fw@strlen.de, Pablo Neira Ayuso , Jozsef Kadlecsik , "David S. Miller" , Jakub Kicinski , Shuah Khan , open list , "open list:NETFILTER" , "open list:NETFILTER" , "open list:NETWORKING [GENERAL]" , "open list:KERNEL SELFTEST FRAMEWORK" Subject: Re: [PATCH v3] netfilter: nf_conntrack: Add conntrack helper for ESP/IPsec Message-ID: <20210505111013.GB12364@breakpoint.cc> References: <20210426123743.GB975@breakpoint.cc> <20210503010646.11111-1-Cole.Dishington@alliedtelesis.co.nz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210503010646.11111-1-Cole.Dishington@alliedtelesis.co.nz> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Cole Dishington wrote: > +/* esp hdr info to tuple */ > +bool esp_pkt_to_tuple(const struct sk_buff *skb, unsigned int dataoff, > + struct net *net, struct nf_conntrack_tuple *tuple) > +{ [..] > + tuple->dst.u.esp.id = esp_entry->esp_id; > + tuple->src.u.esp.id = esp_entry->esp_id; > + return true; > +} Did not consider this before, and doesn't matter if we'd follow this approach or expectation-based solution: Do we need to be mindful about hole-punching? The above will automatically treat the incoming (never-seen-before) ESP packet as being part of the outgoing one, i.e. this will match ESTABLISHED rule, not NEW. With expectation based approach, this will auto-match a RELATED rule. With normal expectations as used by helpers (ftp, sip and so on), we nowadays don't do such auto-accept schemes anymore but instead require explicit configuation, e.g. something like iptables -t raw -p tcp -A PREROUTING -s $allowed -d $ftpserver -j CT --helper "ftp" ... to make it explicit that the kernel may automatically permit incoming connection requests to $allowed from $ftpserver. Do we need to worry about this for ESP too? If the expectation-based route is taken, another patch could be piled on top that adds a fake ESP helper, whose only function is to let esp_pkt_to_tuple() check if the 'outgoing/seen-before' ESP connection has been configured with the "esp" helper, and then allow the expectation (or, not allow it in case the existing esp ct doesn't have the esp helper).