Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp533525pxu; Thu, 26 Nov 2020 05:12:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJyPCydlArrf/VO5TEVZXCdul+iKJLmZUMec8n0OEG1dvNLtctDFQ1g2ejf+p1vqCoFdIlnx X-Received: by 2002:a17:906:52da:: with SMTP id w26mr2579517ejn.347.1606396363895; Thu, 26 Nov 2020 05:12:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606396363; cv=none; d=google.com; s=arc-20160816; b=TRTN/yVp0zSmA8xcG/l2bo9Y8bTSavLe+Sx6FlrudoaV89IIRi3u6b5cE4FQACjh0K 97usJ0RoJkM/pbLhUJrBb2GXJqE294v+7HVHF1pis1R8PF4i0klIu6Ic9Z8/95nN6q7T Hy+873YKlbELagpHeSXshfH8TYxRu4Y0zHRhjqYTWcEVfyN8w4vRzqhbg3ayz6uh1S2S F6Jr6g7NrGWE0oXm0617Zbs7PT38mI5sqan2SpOIbA4Yh9GH3JgdsmaeKwf6kQhrAyuY Y+5mXCIGDDQNJyqwLt8EA/GVh7/bdbx3YRCAyvc8TyyNpzYZlxn/iIaCEt1ARiM8BG/R bCPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:mail-followup-to:message-id:subject:cc:to :from:date; bh=DFHvPSkU7FADknc6FZT6Ur8vBhRiKVbbf6Q+m08fBsk=; b=JjJtiLOlCnSo/DC1hfR/O2IDGyYlWKVRQd1ibSYiRRB9bAOr2E1yqxqBsZ3MQgmsrt BaiKDXqfPVHZH7JAz1o9yW51KPND/5lolI0ltmRPt24IFYD7kUTJ5wBsnPpm9jG9+fC9 6RYtRokWcUxqXmB5xatpFXTWuCVrOS0hPnqBs9wE8hWleF0SeeDqlREh4u++ed0w7STh 6X5g3fwM7rnPxlTcjQ/ezLs5GPLLgwS82oW5cuy4Hefj0jjLoy5wBneinMdJINavW2uj Qxkvl6VQrFVF3gP5V2RWkwA+CyHv4HL+PkI493NmbKMwswXC33floQGl5aBU5jfFegsw 6Qpw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-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 t22si3049047ejb.186.2020.11.26.05.12.11; Thu, 26 Nov 2020 05:12:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto-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-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389784AbgKZNMD (ORCPT + 99 others); Thu, 26 Nov 2020 08:12:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389604AbgKZNMD (ORCPT ); Thu, 26 Nov 2020 08:12:03 -0500 Received: from orbyte.nwl.cc (orbyte.nwl.cc [IPv6:2001:41d0:e:133a::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E979AC0613D4; Thu, 26 Nov 2020 05:12:02 -0800 (PST) Received: from n0-1 by orbyte.nwl.cc with local (Exim 4.94) (envelope-from ) id 1kiH44-0006pB-KQ; Thu, 26 Nov 2020 14:12:00 +0100 Date: Thu, 26 Nov 2020 14:12:00 +0100 From: Phil Sutter To: Steffen Klassert Cc: linux-crypto@vger.kernel.org, netfilter-devel@vger.kernel.org Subject: Re: XFRM interface and NF_INET_LOCAL_OUT hook Message-ID: <20201126131200.GH4647@orbyte.nwl.cc> Mail-Followup-To: Phil Sutter , Steffen Klassert , linux-crypto@vger.kernel.org, netfilter-devel@vger.kernel.org References: <20201125112342.GA11766@orbyte.nwl.cc> <20201126094021.GK8805@gauss3.secunet.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201126094021.GK8805@gauss3.secunet.de> Sender: Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Hi Steffen, On Thu, Nov 26, 2020 at 10:40:21AM +0100, Steffen Klassert wrote: > On Wed, Nov 25, 2020 at 12:23:42PM +0100, Phil Sutter wrote: > > I am working on a ticket complaining about netfilter policy match > > missing packets in OUTPUT chain if XFRM interface is being used. > > > > I don't fully overlook the relevant code path, but it seems like > > skb_dest(skb)->xfrm is not yet assigned when the skb is routed towards > > XFRM interface and already cleared again (by xfrm_output_one?) before it > > makes its way towards the real output interface. NF_INET_POST_ROUTING > > hook works though. > > > > Is this a bug or an expected quirk when using XFRM interface? > > This is expected behaviour. The xfrm interfaces are plaintext devices, > the plaintext packets are routed to the xfrm interface which guarantees > transformation. So the lookup that assigns skb_dst(skb)->xfrm > happens 'behind' the interface. After transformation, > skb_dst(skb)->xfrm will be cleared. So this assignment exists just > inside xfrm in that case. OK, thanks for the clarification. > Does netfilter match against skb_dst(skb)->xfrm? What is the exact case > that does not work? The reported use-case is a match against tunnel data in output hook: | table t { | chain c { | type filter hook output priority filter | oifname eth0 ipsec out ip daddr 192.168.1.2 | } | } The ipsec expression tries to extract that data from skb_dst(skb)->xfrm if present. In xt_policy (for iptables), code is equivalent. The above works when not using xfrm_interface. Initially I assumed one just needs to adjust the oifname match, but even dropping it doesn't help. Cheers, Phil