git: f6561ff8ee10 - stable/14 - icmp6: rate limit our echo replies

From: Zhenlei Huang <zlei_at_FreeBSD.org>
Date: Wed, 26 Jun 2024 04:50:25 UTC
The branch stable/14 has been updated by zlei:

URL: https://cgit.FreeBSD.org/src/commit/?id=f6561ff8ee103194e2551efdfda1cd6d655b183d

commit f6561ff8ee103194e2551efdfda1cd6d655b183d
Author:     Gleb Smirnoff <glebius@FreeBSD.org>
AuthorDate: 2024-03-24 16:13:23 +0000
Commit:     Zhenlei Huang <zlei@FreeBSD.org>
CommitDate: 2024-06-26 04:48:43 +0000

    icmp6: rate limit our echo replies
    
    The generation of ICMP6_ECHO_REPLY bypasses icmp6_error(), thus rate
    limit was not applied.
    
    Reviewed by:            tuexen, zlei
    Differential Revision:  https://reviews.freebsd.org/D44480
    
    (cherry picked from commit 32aeee8ce7e72738fff236ccd5629d55035458f8)
---
 sys/netinet6/icmp6.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/sys/netinet6/icmp6.c b/sys/netinet6/icmp6.c
index ba66e18b6524..5b384889d422 100644
--- a/sys/netinet6/icmp6.c
+++ b/sys/netinet6/icmp6.c
@@ -548,6 +548,8 @@ icmp6_input(struct mbuf **mp, int *offp, int proto)
 		icmp6_ifstat_inc(ifp, ifs6_in_echo);
 		if (code != 0)
 			goto badcode;
+		if (icmp6_ratelimit(&ip6->ip6_src, ICMP6_ECHO_REPLY, 0))
+			break;
 		if ((n = m_copym(m, 0, M_COPYALL, M_NOWAIT)) == NULL) {
 			/* Give up remote */
 			break;