From nobody Sat Dec 03 14:54:52 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 4NPXsV2Jfnz4jb5Q for ; Sat, 3 Dec 2022 14:54:54 +0000 (UTC) (envelope-from matteo@freebsd.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4NPXsV1f4Sz3lGg for ; Sat, 3 Dec 2022 14:54:54 +0000 (UTC) (envelope-from matteo@freebsd.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1670079294; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=/zvjyqj6klTjBqvW/GJUP3asSsaRI/Pb2Mzz8ldQ4yI=; b=UePUQubuwB+mXnQdews1QA7bgTAOSDRT5kBQlINZ8mzUF9m7Nuty87HaWH5HPm5yeDn8SH +4L4MHuu8fKlexI84/4jzF7/QTa7qq/l7U2WqwtASEd0dFFSgbC42PNko3Q3xAHxpZdYSH LACK/rVL4JXB3SXG/A28mLEuhapL981a3lYN724jotE+aZl1fLkyrzbVzh8vz+8lVvd0Wk Ed6Obbp6ru4VPB6vuJiNjjXyZriIbeGMSfQrp+QqPvEo6dbwbIOzuUsQPZ+zwScmt0lW8R kIDUG2j48VoL0pqu70KdH+GSyTFn3wXES1vTD0WdoXUaq3NpomjCOzt2aoyV+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1670079294; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=/zvjyqj6klTjBqvW/GJUP3asSsaRI/Pb2Mzz8ldQ4yI=; b=DyVz1Q6UuQY0U8pQZFi4rnup30pkm4X5WoxM9S9Y9WKKHsi68LYDTYU3ZP/WptJsM0UirA /k5txrQ0NMkIWZQsEmt6tqStRtS8EKt8jw2zBjNhHb9AE7ADO97VWICoBbRf/bOJ6YoJlH Zj3Bw8N/n87c/8F8Ct8TFxeCqs6snry04x4iGbRDnjelRpTOkLPpgQMSAgBv+rRJDTw4uJ /ouTEu26tE841gibohCwpFwYNz4Rx/Pln5weDmldaDit8mmUPoek559r/AZtm4GUJ//t5J L+ewDW6csloWil9GXVXnGahHP8iu9WygUpcdHhnc23YJW+kzsmV02viII7uP7w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1670079294; a=rsa-sha256; cv=none; b=UzKVDaWM44u/HlmlQsYYZVhfJtm8kQvc1UMT2MfEGWS092UKydqW7M9jofTLOn9yKURKcp 1rJkh5xHDifPNEMk+7jx79NbUgWzyMuzErOdypdcMHYz2lnRGdr1mtOxwOHvR6O4e1m8t7 lg66nAXfjh3FullsxJMsflkSW61wjDnQjpsDrKQDOjprHPiF6mWOuH1f34SdiPeko09SAZ v+gELXhxqYBYwfj8p3drxlxvQ0sQdZWTJ9Ms6DKveVHVKiG05gt43B22nC3g+230bdA53m ZG5qVzgu6mAceYjTDN6Wo657ABF4wAsaEBweSGQUugdapf2T03L4Rw1MDgs0CQ== Received: from ubertino.local (unknown [IPv6:2601:19b:4400:1779::102b]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: matteo/mail) by smtp.freebsd.org (Postfix) with ESMTPSA id 4NPXsV00lYz16Sp for ; Sat, 3 Dec 2022 14:54:53 +0000 (UTC) (envelope-from matteo@freebsd.org) Date: Sat, 3 Dec 2022 09:54:52 -0500 From: Matteo Riondato To: freebsd-net@freebsd.org Subject: Re: if_enc(4) and net.inet.ipcomp.ipcomp_enable Message-ID: <20221203145452.eh6gs4w3xalelanb@ubertino.local> X-PGP-Key: http://rionda.to/files/matteogpg.asc References: <00EA8894-6B8C-4D21-8D5D-DA490FD24697@FreeBSD.org> 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 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="xkusc2xloogj4bya" Content-Disposition: inline In-Reply-To: <00EA8894-6B8C-4D21-8D5D-DA490FD24697@FreeBSD.org> X-ThisMailContainsUnwantedMimeParts: N --xkusc2xloogj4bya Content-Type: text/plain; charset=utf-8; format=flowed Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2022-02-27 at 18:54 EST, Matteo Riondato wrote: >Hello net@, > >I am trying to use pf to filter packets in ipsec tunnels by filtering=20 >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=20 >does, the incoming packets seem to ignore the value of the=20 >net.enc.in.ipsec_filter_mask sysctl, thus they show up in pf =E2=80=9Ctwic= e=E2=80=9D:=20 >once with both external and internall headers, and once only with=20 >internal (the value of 2 for this sysctl should make these packets show=20 >up only with internal headers). The same can be observed with tcpdump=20 >on enc0. This behavior makes it hard to do filtering. Sorry to resurrect an old thread, but things are still quite unclear to=20 me. Specifically, I don't understand why, on the VPN server (using=20 strongswan), I'm seeing ipcomp packets with the "public IPs" headers on=20 enc0 with the sysctl as above. Shouldn't the sysctls make it so I only see non-public addresses on=20 enc0, at least for the VPN clients? Example from tcpdump output: # tcpdump -e -n -tttt -vv -Q out -i enc0 proto ipcomp tcpdump: listening on enc0, link-type ENC (OpenBSD encapsulated IP),=20 capture size 262144 bytes 2022-12-03 09:43:12.837006 (authentic,confidential): SPI 0xcdd5f426:=20 (tos 0x0, ttl 64, id 12913, offset 0, flags [none], proto Compressed IP=20 (108), length 93, bad cksum 0 (->96d5)!) serverPublicIP > clientPublicIP: IPComp(cpi=3D0x8b57) 2022-12-03 09:43:12.936234 (authentic,confidential): SPI 0xcdd5f426:=20 (tos 0x0, ttl 64, id 30383, offset 0, flags [none], proto Compressed IP=20 (108), length 106, bad cksum 0 (->528a)!) serverPublicIP > clientPublicIP: IPComp(cpi=3D0x8b57) 2022-12-03 09:43:13.008234 (authentic,confidential): SPI 0xceeb1d8e:=20 (tos 0x0, ttl 53, id 9939, offset 0, flags [none], proto Compressed IP=20 (108), length 430) clientPublicIP > serverPublicIP: IPComp(cpi=3D0x5802) 2022-12-03 09:43:13.355676 (authentic,confidential): SPI 0xceeb1d8e:=20 (tos 0x0, ttl 53, id 56601, offset 0, flags [none], proto Compressed IP=20 (108), length 432) clientPublicIP > serverPublicIP: IPComp(cpi=3D0x5802) 2022-12-03 09:43:13.851280 (authentic,confidential): SPI 0xceeb1d8e:=20 (tos 0x0, ttl 53, id 12461, offset 0, flags [none], proto Compressed IP=20 (108), length 431) clientPublicIP > serverPublicIP: IPComp(cpi=3D0x5802) 2022-12-03 09:43:14.655189 (authentic,confidential): SPI 0xceeb1d8e:=20 (tos 0x0, ttl 53, id 15506, offset 0, flags [none], proto Compressed IP=20 (108), length 429) clientPublicIP > serverPublicIP: IPComp(cpi=3D0x5802) 2022-12-03 09:43:16.055205 (authentic,confidential): SPI 0xceeb1d8e:=20 (tos 0x0, ttl 53, id 3025, offset 0, flags [none], proto Compressed IP=20 (108), length 431) clientPublicIP > serverPublicIP: IPComp(cpi=3D0x5802) 2022-12-03 09:43:18.653248 (authentic,confidential): SPI 0xceeb1d8e:=20 (tos 0x0, ttl 53, id 18351, offset 0, flags [none], proto Compressed IP=20 (108), length 430) clientPublicIP > serverPublicIP: IPComp(cpi=3D0x5802) 2022-12-03 09:43:23.676563 (authentic,confidential): SPI 0xceeb1d8e:=20 (tos 0x0, ttl 53, id 22302, offset 0, flags [none], proto Compressed IP=20 (108), length 427) clientPublicIP > serverPublicIP: IPComp(cpi=3D0x5802) 2022-12-03 09:43:33.471467 (authentic,confidential): SPI 0xceeb1d8e:=20 (tos 0x0, ttl 53, id 48805, offset 0, flags [none], proto Compressed IP=20 (108), length 429) clientPublicIP > serverPublicIP: IPComp(cpi=3D0x5802) 2022-12-03 09:43:52.872815 (authentic,confidential): SPI 0xceeb1d8e:=20 (tos 0x0, ttl 53, id 40015, offset 0, flags [none], proto Compressed IP=20 (108), length 429) clientPublicIP > serverPublicIP: IPComp(cpi=3D0x5802) 2022-12-03 09:44:31.471603 (authentic,confidential): SPI 0xceeb1d8e:=20 (tos 0x0, ttl 53, id 40969, offset 0, flags [none], proto Compressed IP=20 (108), length 429) clientPublicIP > serverPublicIP: IPComp(cpi=3D0x5802) 2022-12-03 09:44:39.370293 (authentic,confidential): SPI 0xcdd5f426:=20 (tos 0x0, ttl 64, id 7537, offset 0, flags [none], proto Compressed IP=20 (108), length 93, bad cksum 0 (->abd5)!) serverPublicIP > clientPublicIP: IPComp(cpi=3D0x8b57) 2022-12-03 09:44:39.396698 (authentic,confidential): SPI 0xcdd5f426:=20 (tos 0x0, ttl 64, id 38574, offset 0, flags [none], proto Compressed IP=20 (108), length 106, bad cksum 0 (->328b)!) serverPublicIP > clientPublicIP: IPComp(cpi=3D0x8b57) 2022-12-03 09:44:39.436956 (authentic,confidential): SPI 0xcdd5f426:=20 (tos 0x0, ttl 64, id 61004, offset 0, flags [none], proto Compressed IP=20 (108), length 94, bad cksum 0 (->daf8)!) serverPublicIP > clientPublicIP: IPComp(cpi=3D0x8b57) 2022-12-03 09:45:35.468389 (authentic,confidential): SPI 0xceeb1d8e:=20 (tos 0x0, ttl 53, id 35714, offset 0, flags [none], proto Compressed IP=20 (108), length 427) I'm also quite confused as to why, even with "-Q out", I'm seeing=20 packets going in both directions. Perhaps that's an if_enc quirk? Thanks, Matteo --xkusc2xloogj4bya Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQJHBAABCgAxFiEEa9uKZL0hP4E8Nl5vGwL9SVQlVQEFAmOLYzgTGGhrcHM6Ly9w Z3AubWl0LmVkdQAKCRAbAv1JVCVVAW/tEADHLrRNrBQ1FEF1nLtbFQbIaq7ggOIf ymVlyEv2JM++3XJ8buI/h5SxSaOUfmVPwXpFSygYByoe+SCeQpSmXq2/oXt7o0sR 5po6K59BkRB9X6BmG1pQTpzq8MIXmsP+SVs7reJ2eTfVQNpQjddCEWDJUu+9GP6H 6hvTuk6N4vlgsQ3OvfZaqIlYN8zOG1Z9TbTaOsehsumqBFd++1gr7hA7dFcdyZpk rUDc3aJD1SA1Bscl+9rde+Q8aFmSgoYmYoIUdZrjjLyhPSNxVu7a2ZokHtzKJDAD zubd9MHWxFCouDjjiLPTOzzU55lPcMoNmQ2JxFvhZhD86/kh2wHpzJzWcWmcwLN+ 5tAL5HymPZXdIf41YhKnNGctccNHB4u2CeET20hHBn9pBLrm9WVFIDKWkzZ8cHQK k2WgJdOfBtUz0diX+966KkiDFLHqhuSagwt1uk4M8JlTTE0JZjKjGHCf/okHCkx4 gycRMvZqOvXZqbLpKF/U7fUMTYhaFWUJEJAaMcRdqK0JXZDaDraVK1cWEnyCP9dn ucOmrde1ks3AediWdGE5/XtEvNsLAJYe5x0gfHKxb5jte3Zr2iP6DQPxB85KYT9s 6jmAPABjEjTuikMts2c7AxF32BNz/+d3tHHephTcd5db5eo89OX28VGwrOosxo4X Pr8E4cbH2qRE1Q== =PPIB -----END PGP SIGNATURE----- --xkusc2xloogj4bya--