Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F178116471
D62119.1796013395.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
3 KB
Referenced Files
None
Subscribers
None
D62119.1796013395.diff
View Options
diff --git a/sys/netipsec/ipsec_output.c b/sys/netipsec/ipsec_output.c
--- a/sys/netipsec/ipsec_output.c
+++ b/sys/netipsec/ipsec_output.c
@@ -830,6 +830,17 @@
key_freesav(&sav);
if (m_length(m, NULL) + hlen > pmtu) {
+ /*
+ * Senders do not go below IPV6_MMTU whatever a Packet Too
+ * Big says (RFC 8201), so never ask for less. A packet of
+ * that size goes on, and the outer packet is fragmented
+ * (RFC 2473 section 7.1).
+ */
+ if (pmtu < hlen + IPV6_MMTU) {
+ if (m_length(m, NULL) <= IPV6_MMTU)
+ return (0);
+ pmtu = hlen + IPV6_MMTU;
+ }
/*
* If we're forwarding generate ICMPv6 message here,
* so that it contains pmtu subtracted by header size.
@@ -837,11 +848,7 @@
* to be dropped silently.
*/
if (forwarding) {
- if (pmtu > hlen)
- icmp6_error(m, ICMP6_PACKET_TOO_BIG, 0, pmtu - hlen);
- else
- m_freem(m);
-
+ icmp6_error(m, ICMP6_PACKET_TOO_BIG, 0, pmtu - hlen);
key_freesp(&sp);
return (EINPROGRESS); /* Pretend that we consumed it. */
}
diff --git a/tests/sys/netipsec/tunnel/Makefile b/tests/sys/netipsec/tunnel/Makefile
--- a/tests/sys/netipsec/tunnel/Makefile
+++ b/tests/sys/netipsec/tunnel/Makefile
@@ -15,6 +15,7 @@
chacha20_poly1305 \
esp_iv \
flowlabel \
+ pmtu \
sa_flowid
TEST_METADATA+= execenv="jail" \
diff --git a/tests/sys/netipsec/tunnel/pmtu.sh b/tests/sys/netipsec/tunnel/pmtu.sh
new file mode 100755
--- /dev/null
+++ b/tests/sys/netipsec/tunnel/pmtu.sh
@@ -0,0 +1,43 @@
+
+. $(atf_get_srcdir)/utils.subr
+
+# A plain ESP tunnel over IPv6, with a path MTU of 1300 between the
+# gateways: less than IPV6_MMTU is left once the estimated IPsec headers
+# are taken off. A forwarded packet of 1280 bytes must get through, as the
+# outer packet can be fragmented, and a larger one must be answered with a
+# Packet Too Big for 1280, as senders ignore one for less.
+atf_test_case "ptb_floor_v6" "cleanup"
+ptb_floor_v6_head()
+{
+ atf_set descr 'The PMTU check does not ask for less than the IPv6 minimum MTU'
+ atf_set require.user root
+}
+ptb_floor_v6_body()
+{
+ ist_init
+ ist_labsetup
+ atf_check -s exit:0 jexec ipsecA ifconfig ${epair_PUB_A}a mtu 1300
+ atf_check -s exit:0 jexec router ifconfig ${epair_PUB_A}b mtu 1300
+ atf_check -s exit:0 jexec router ifconfig ${epair_PUB_B}b mtu 1300
+ atf_check -s exit:0 jexec ipsecB ifconfig ${epair_PUB_B}a mtu 1300
+ ist_v6_setup
+ ist_setkey ipsecA out 6 aes-gcm-16 "12345678901234567890"
+ atf_check -s exit:0 -o ignore jexec ipsecA setkey -f ${TMPDIR}/ipsec.ipsecA.conf
+ ist_setkey ipsecB in 6 aes-gcm-16 "12345678901234567890"
+ atf_check -s exit:0 -o ignore jexec ipsecB setkey -f ${TMPDIR}/ipsec.ipsecB.conf
+
+ atf_check -s exit:0 -o ignore \
+ jexec hostA ping -6 -c 3 -i 0.2 -s 1232 2001:db8:45::1
+ # Without -u, ping -6 fragments to the minimum IPv6 MTU.
+ atf_check -s exit:2 -o match:"Packet too big mtu = 1280" \
+ jexec hostA ping -6 -c 1 -t 2 -u -v -s 1352 2001:db8:45::1
+}
+ptb_floor_v6_cleanup()
+{
+ ist_cleanup
+}
+
+atf_init_test_cases()
+{
+ atf_add_test_case "ptb_floor_v6"
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Nov 30, 4:36 AM (19 h, 43 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
42100617
Default Alt Text
D62119.1796013395.diff (3 KB)
Attached To
Mode
D62119: netipsec: Do not send a Packet Too Big below the IPv6 minimum MTU
Attached
Detach File
Event Timeline