aboutsummaryrefslogtreecommitdiff
path: root/sys/netinet6/ip6_forward.c
diff options
context:
space:
mode:
authorAlexander V. Chernikov <melifaro@FreeBSD.org>2023-05-17 09:06:04 +0000
committerAlexander V. Chernikov <melifaro@FreeBSD.org>2023-05-17 09:06:04 +0000
commitb50e1465e88dcf5f6f008892d802df010e7029d1 (patch)
tree934d1b9725d7a347264041f6a099042e6c590f83 /sys/netinet6/ip6_forward.c
parent4c63ecf5c77cdd023282c2ab585d139aa0408d42 (diff)
routing: plug mbuf leak for the packets hitting IPv6 blackhole route
Reported by: Dmitriy Smirnov <fox@sage.su> Tested by: Dmitriy Smirnov <fox@sage.su> MFC after: 1 day
Diffstat (limited to 'sys/netinet6/ip6_forward.c')
-rw-r--r--sys/netinet6/ip6_forward.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/sys/netinet6/ip6_forward.c b/sys/netinet6/ip6_forward.c
index c8f9079e0aa7..0f7260ccd067 100644
--- a/sys/netinet6/ip6_forward.c
+++ b/sys/netinet6/ip6_forward.c
@@ -198,9 +198,12 @@ again:
if (nh->nh_flags & (NHF_BLACKHOLE | NHF_REJECT)) {
IP6STAT_INC(ip6s_cantforward);
- if ((nh->nh_flags & NHF_REJECT) && (mcopy != NULL)) {
- icmp6_error(mcopy, ICMP6_DST_UNREACH,
- ICMP6_DST_UNREACH_REJECT, 0);
+ if (mcopy != NULL) {
+ if (nh->nh_flags & NHF_REJECT) {
+ icmp6_error(mcopy, ICMP6_DST_UNREACH,
+ ICMP6_DST_UNREACH_REJECT, 0);
+ } else
+ m_freem(mcopy);
}
goto bad;
}