aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBartlomiej Grzesik <bag@semihalf.com>2021-09-24 08:17:11 +0000
committerWojciech Macek <wma@FreeBSD.org>2021-09-24 08:17:11 +0000
commit4f3376951d7024d1c3446af2260cef9e4d3404a6 (patch)
tree12818ba2146f23facc1036b2d53806e504fcbe15
parentf9e28f900353ca8681fa1815afaebaca16ef254b (diff)
downloadsrc-4f3376951d7024d1c3446af2260cef9e4d3404a6.tar.gz
src-4f3376951d7024d1c3446af2260cef9e4d3404a6.zip
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
-rw-r--r--sys/netipsec/ipsec_output.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/sys/netipsec/ipsec_output.c b/sys/netipsec/ipsec_output.c
index 2f8cc12c526b..50bbd72f0589 100644
--- a/sys/netipsec/ipsec_output.c
+++ b/sys/netipsec/ipsec_output.c
@@ -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 @@ setdf:
}
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. */