From nobody Tue Mar 08 01:02:13 2022 X-Original-To: freebsd-net@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 3DE111A051CF for ; Tue, 8 Mar 2022 01:02:17 +0000 (UTC) (envelope-from rionda@gmail.com) Received: from mail-qt1-x836.google.com (mail-qt1-x836.google.com [IPv6:2607:f8b0:4864:20::836]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4KCH9N40cRz3CPN for ; Tue, 8 Mar 2022 01:02:16 +0000 (UTC) (envelope-from rionda@gmail.com) Received: by mail-qt1-x836.google.com with SMTP id a1so14853634qta.13 for ; Mon, 07 Mar 2022 17:02:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=59Hki+bl+IK/wsEJ9snLZaT48IlrUO9HzQHD/FM1pyE=; b=bshtkphtAEBypmUnUY/aCl6Ecju4UPF+IKVqzHkhy74rrUuHw3BF3BBEn0WuzTj2ts zNK5NxP+gmFrjLOeS11xOUVrcb7dcTtoppwBD+N9niSWJcRJOpG1tzA+kkgzEeYqGxeb r957nTik1wRV7bMBzLQwJl9QyfpsA+imb6Ywmf7KMew4s8dxijpNmu8VLdOwn1xB7zyK z3GINyP4yEW9ZHxubJXNk+EyTl+hV9W4MdJaVVvYy+XY/xHzHm5FxKF4jsRBC5l5+Mhd JLlchmmYdwuRVWhMlCy+xM7of5PihnD+tGMokIJDg/8V1DW3PxspsWwLBdq4NAYKOvCT OVuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:mime-version:subject:from:in-reply-to :date:cc:content-transfer-encoding:message-id:references:to; bh=59Hki+bl+IK/wsEJ9snLZaT48IlrUO9HzQHD/FM1pyE=; b=d9+JDSDVCdYD6Hz8DmnsV5rV5Me5olJAHrcDlo4daM21FBWlPOu+PmQuAMd9Vqpsk0 jq/O8i78JlJa/0hFwQbR+D2ejorgPa5cyg8WgTYyKujS1erqK3VVvpb3hNXbAUuc0A2+ RlnENMj8W76eluRSZ79O4TAK66BYKB2zcrMmRNYq/Eg9fmfXnSMrdcbXn+aSY8vd6lGP 3iY8PrgvHCelJQsgoe9ttAkM/jXtjsXjPddI2GvPZV+4k8sYG7W2O/uMXEZK+/bbn9fm N3eYxSQGL4k4epqc9sigOWJ0Bxf6k1fjfrhsjQegQzXbmjX0iqXaM0mCLxcfw84k66CJ BkfQ== X-Gm-Message-State: AOAM5315IOlnst+s678U6HsXTE/9zAR38bJnanSLQsqTXp2PjMxg6ifK Zo1ILUSmYHMns7wk3yCMI4c= X-Google-Smtp-Source: ABdhPJywkOcHEZWKUU292g/ell4Z072GB4CYJkhTyw1p8ja7K1zTmtXcTKXvg2nwfmAqntSvnR0jYw== X-Received: by 2002:a05:622a:58b:b0:2de:9260:a1ef with SMTP id c11-20020a05622a058b00b002de9260a1efmr11386576qtb.254.1646701335708; Mon, 07 Mar 2022 17:02:15 -0800 (PST) Received: from smtpclient.apple ([2601:19b:4400:1779::1000]) by smtp.gmail.com with ESMTPSA id 70-20020a370649000000b0067b4cd8ffbasm1091719qkg.60.2022.03.07.17.02.14 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Mar 2022 17:02:15 -0800 (PST) Content-Type: text/plain; charset=utf-8 List-Id: Networking and TCP/IP with FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-net List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-net@freebsd.org Mime-Version: 1.0 (Mac OS X Mail 15.0 \(3693.60.0.1.1\)) Subject: Re: if_enc(4) and net.inet.ipcomp.ipcomp_enable From: Matteo Riondato In-Reply-To: <2eb08961-3db2-ee21-e434-e058cd360170@yandex.ru> Date: Mon, 7 Mar 2022 20:02:13 -0500 Cc: freebsd-net@freebsd.org Content-Transfer-Encoding: quoted-printable Message-Id: References: <00EA8894-6B8C-4D21-8D5D-DA490FD24697@FreeBSD.org> <2eb08961-3db2-ee21-e434-e058cd360170@yandex.ru> To: "Andrey V. Elsukov" X-Mailer: Apple Mail (2.3693.60.0.1.1) X-Rspamd-Queue-Id: 4KCH9N40cRz3CPN X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20210112 header.b=bshtkpht; dmarc=none; spf=pass (mx1.freebsd.org: domain of rionda@gmail.com designates 2607:f8b0:4864:20::836 as permitted sender) smtp.mailfrom=rionda@gmail.com X-Spamd-Result: default: False [-2.70 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; TO_DN_SOME(0.00)[]; MV_CASE(0.50)[]; R_SPF_ALLOW(-0.20)[+ip6:2607:f8b0:4000::/36]; RCVD_COUNT_THREE(0.00)[3]; DKIM_TRACE(0.00)[gmail.com:+]; RCPT_COUNT_TWO(0.00)[2]; NEURAL_HAM_SHORT(-1.00)[-1.000]; FREEMAIL_TO(0.00)[yandex.ru]; FORGED_SENDER(0.30)[matteo@FreeBSD.org,rionda@gmail.com]; MIME_TRACE(0.00)[0:+]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; MID_RHS_MATCH_FROM(0.00)[]; FROM_NEQ_ENVFROM(0.00)[matteo@FreeBSD.org,rionda@gmail.com]; DWL_DNSWL_NONE(0.00)[gmail.com:dkim]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20210112]; FROM_HAS_DN(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-net@freebsd.org]; DMARC_NA(0.00)[FreeBSD.org]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCVD_IN_DNSWL_NONE(0.00)[2607:f8b0:4864:20::836:from]; MLMMJ_DEST(0.00)[freebsd-net]; RCVD_TLS_ALL(0.00)[] X-ThisMailContainsUnwantedMimeParts: N > On Mar 1, 2022, at 5:52 AM, Andrey V. Elsukov = wrote: >=20 > 28.02.2022 02:54, Matteo Riondato =D0=BF=D0=B8=D1=88=D0=B5=D1=82: >> Hello net@, >> I am trying to use pf to filter packets in ipsec tunnels by filtering >> on enc0 from if_enc(4). >> I have the following values for the net.enc sysctl subtree: = net.enc.out.ipsec_bpf_mask: 1 net.enc.out.ipsec_filter_mask: 1 = net.enc.in.ipsec_bpf_mask: 2 net.enc.in.ipsec_filter_mask: 2 >> and I have >> net.inet.ipsec.filtertunnel: 1 >> Everything works well when the tunnel does not use ipcomp, but when >> it does, the incoming packets seem to ignore the value of the = net.enc.in.ipsec_filter_mask sysctl, thus they show up in pf = =E2=80=9Ctwice=E2=80=9D: >> once with both external and internall headers, and once only with >> internal (the value of 2 for this sysctl should make these packets >> show up only with internal headers). The same can be observed with >> tcpdump on enc0. This behavior makes it hard to do filtering. >> Is this behavior expected? >=20 > Hi, >=20 > are you sure that it is not just on ingress and egress? You can use -Q = flag for tcpdump to make sure. >=20 > The first time when you see IPcomp packet in PF, it is when it arrives = into IP stack on a physical interface (em, igb, ix, etc.). The second = time is after decompression on if_enc interface, it is called from IPsec = stack. Hi Andrey, Sorry for the late reply, somehow your message went into my spam folder. = :/ It'll take me a few days to check, but I'll try your suggestion of using = -Q to better understand what I=E2=80=99m seeing. Thanks, Matteo