Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp398258pxy; Wed, 5 May 2021 05:06:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyVJwQ4H4dTQxMBB1Ekrp/S/ctG9pXfzEJ0JpqGFa8vqZjpNUVG1b73qDaJR/bAv5O5Sp4d X-Received: by 2002:aa7:8a87:0:b029:27d:a1e:bc71 with SMTP id a7-20020aa78a870000b029027d0a1ebc71mr28186872pfc.14.1620216382718; Wed, 05 May 2021 05:06:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620216382; cv=none; d=google.com; s=arc-20160816; b=ASH3rTQYNkFeDqfbkrfzjQk53/gaOrc7MYWoCvn7zfsOEItErP2q5CnKwIkdEf7MpT q/eKdb0op1eZtebroMQeQGIKknbYw54x5rayzHK5vzYjRwr6ZM0QMlgplYqz2rXNeQIB zvAZEPcmoRlYi+Jl3BB9GQwnL8ta2/RkBLDxPrAX7NIKYyw1fDqqBNWaEa7L8zjtrEq/ 7fmwyvF9GYA5oEkFurSL+LmBvqDEXFTDfj80Wfnyebm5hLcqxHO1LKrAI7GPCQ6jNlxY 7HafrkAJv5p/in5F44I0pFgXrN3TtMnS1v03DPwUzAixlORTf0PvQe7LfT9f0Pyd36ZT 7yTA== 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=zdPIgwcUWOz0OISrjspIUE0h+il5NuXZKl6qxNMgd5k=; b=ARRequ4yOTfUrBPGhyOE4Q+Wtg5pWD0HDcIEmSeRDnPkH4Oeg5NAjLjQZZJWvwtfpJ sJEfeyTCdKL1IZ004TyJZmn1uruCZovKzJ4cM4hjNWFmWvIhMV1MeZa2TToJfXkeH0XZ EE6ewRDZfa9iP9N/e7dYZYacnv4H1+drmaRpUiz9mO+v2Vyfj04Kb1G/0cMDe4IchIPu vPFR8XvK1eNWwZMz6vgV1eXVXT/4nlKQ7Ac7AprUVFqoYNym20wM/cljtrWbGdXVORVN 7XjFmT0nWbYbZ9H8xZhBM46sox+2zjttxy6dnMJwBhUU51tDC5tbpdWijj/ZZlHW8ZvX yGZg== 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 m4si7026602plt.179.2021.05.05.05.06.08; Wed, 05 May 2021 05:06: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 S232816AbhEELLg (ORCPT + 99 others); Wed, 5 May 2021 07:11:36 -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).