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
This commit is contained in:
Alexander V. Chernikov 2023-05-17 09:06:04 +00:00
parent 4c63ecf5c7
commit b50e1465e8

View File

@ -198,9 +198,12 @@ ip6_forward(struct mbuf *m, int srcrt)
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;
}