Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 3 Dec 2022 09:54:52 -0500
From:      Matteo Riondato <matteo@freebsd.org>
To:        freebsd-net@freebsd.org
Subject:   Re: if_enc(4) and net.inet.ipcomp.ipcomp_enable
Message-ID:  <20221203145452.eh6gs4w3xalelanb@ubertino.local>
In-Reply-To: <00EA8894-6B8C-4D21-8D5D-DA490FD24697@FreeBSD.org>
References:  <00EA8894-6B8C-4D21-8D5D-DA490FD24697@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help

--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 <matteo@FreeBSD.org> 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--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20221203145452.eh6gs4w3xalelanb>