diff options
author | Andrey V. Elsukov <ae@FreeBSD.org> | 2021-11-02 16:59:06 +0000 |
---|---|---|
committer | Andrey V. Elsukov <ae@FreeBSD.org> | 2021-11-03 12:20:51 +0000 |
commit | 4a9e95286cacce5bf7cd193b43c4a461cf7d69b8 (patch) | |
tree | dd782d9eef93272027d91a9a4e3aa0870b582ca9 | |
parent | 11703705c2f77498246b9523aae44040bd346c00 (diff) | |
download | src-4a9e95286cacce5bf7cd193b43c4a461cf7d69b8.tar.gz src-4a9e95286cacce5bf7cd193b43c4a461cf7d69b8.zip |
ip_divert: calculate delayed checksum for IPv6 adress family
Before passing an IPv6 packet to application apply delayed checksum
calculation. Mbuf flags will be lost when divert listener will return a
packet back, so we will not be able to do delayed checksum calculation
later. Also an application will get a packet with correct checksum.
Reviewed by: donner
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D32807
-rw-r--r-- | sys/netinet/ip_divert.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/sys/netinet/ip_divert.c b/sys/netinet/ip_divert.c index e156b77f44c7..3e1200b1ff1c 100644 --- a/sys/netinet/ip_divert.c +++ b/sys/netinet/ip_divert.c @@ -227,6 +227,25 @@ divert_packet(struct mbuf *m, bool incoming) m->m_pkthdr.csum_flags &= ~CSUM_SCTP; } #endif +#ifdef INET6 + if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA_IPV6) { + m = mb_unmapped_to_ext(m); + if (m == NULL) + return; + in6_delayed_cksum(m, m->m_pkthdr.len - + sizeof(struct ip6_hdr), sizeof(struct ip6_hdr)); + m->m_pkthdr.csum_flags &= ~CSUM_DELAY_DATA_IPV6; + } +#if defined(SCTP) || defined(SCTP_SUPPORT) + if (m->m_pkthdr.csum_flags & CSUM_SCTP_IPV6) { + m = mb_unmapped_to_ext(m); + if (m == NULL) + return; + sctp_delayed_cksum(m, sizeof(struct ip6_hdr)); + m->m_pkthdr.csum_flags &= ~CSUM_SCTP_IPV6; + } +#endif +#endif /* INET6 */ bzero(&divsrc, sizeof(divsrc)); divsrc.sin_len = sizeof(divsrc); divsrc.sin_family = AF_INET; |