ipsec: Add PMTUD support for IPsec IPv4 over IPv6 tunnel

Add support for checking PMTU for IPv4 packets encapsulated in IPv6 tunnels.

Differential revision:	https://reviews.freebsd.org/D31769
Sponsored by:		Stormshield
Obtained from:		Semihalf
This commit is contained in:
Bartlomiej Grzesik 2021-09-24 10:17:11 +02:00 committed by Wojciech Macek
parent f9e28f9003
commit 4f3376951d

View File

@ -305,7 +305,6 @@ ipsec4_check_pmtu(struct mbuf *m, struct secpolicy *sp, int forwarding)
uint32_t idx;
int error;
/* Don't check PMTU if the frame won't have DF bit set. */
if (!V_ip4_ipsec_dfbit)
return (0);
@ -335,15 +334,22 @@ ipsec4_check_pmtu(struct mbuf *m, struct secpolicy *sp, int forwarding)
}
dst = &sav->sah->saidx.dst;
/* Final header is not ipv4. */
if (dst->sa.sa_family != AF_INET) {
memset(&inc, 0, sizeof(inc));
switch (dst->sa.sa_family) {
case AF_INET:
inc.inc_faddr = satosin(&dst->sa)->sin_addr;
break;
#ifdef INET6
case AF_INET6:
inc.inc6_faddr = satosin6(&dst->sa)->sin6_addr;
inc.inc_flags |= INC_ISIPV6;
break;
#endif
default:
key_freesav(&sav);
return (0);
}
memset(&inc, 0, sizeof(inc));
inc.inc_faddr = satosin(&dst->sa)->sin_addr;
key_freesav(&sav);
pmtu = tcp_hc_getmtu(&inc);
/* No entry in hostcache. */