git: f7174eb2b4c4 - main - netinet: Do not forward or ICMP response to INADDR_ANY
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 02 Mar 2025 15:02:43 UTC
The branch main has been updated by zlei:
URL: https://cgit.FreeBSD.org/src/commit/?id=f7174eb2b4c45573bb9e836edad2b179a445a88f
commit f7174eb2b4c45573bb9e836edad2b179a445a88f
Author: Zhenlei Huang <zlei@FreeBSD.org>
AuthorDate: 2025-03-02 15:00:42 +0000
Commit: Zhenlei Huang <zlei@FreeBSD.org>
CommitDate: 2025-03-02 15:00:42 +0000
netinet: Do not forward or ICMP response to INADDR_ANY
The section 4 in the draft proposal [1] explicitly states that 0.0.0.0,
aka INADDR_ANY, retains its existing special meanings.
[1] https://datatracker.ietf.org/doc/draft-schoen-intarea-unicast-0
Reviewed by: glebius
Fixes: efe58855f3ea IPv4: experimental changes to allow net 0/8, 240/4, part of 127/8
MFC after: 5 days
Differential Revision: https://reviews.freebsd.org/D49157
---
sys/netinet/in.c | 3 ++-
sys/netinet/ip_icmp.c | 5 +++--
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/sys/netinet/in.c b/sys/netinet/in.c
index 9a644c60e541..22adc8277b93 100644
--- a/sys/netinet/in.c
+++ b/sys/netinet/in.c
@@ -276,7 +276,8 @@ in_canforward(struct in_addr in)
{
u_long i = ntohl(in.s_addr);
- if (IN_MULTICAST(i) || IN_LINKLOCAL(i) || IN_LOOPBACK(i))
+ if (IN_MULTICAST(i) || IN_LINKLOCAL(i) || IN_LOOPBACK(i) ||
+ in_nullhost(in))
return (0);
if (IN_EXPERIMENTAL(i) && !V_ip_allow_net240)
return (0);
diff --git a/sys/netinet/ip_icmp.c b/sys/netinet/ip_icmp.c
index 936f76e7fbe3..17d15d7d9629 100644
--- a/sys/netinet/ip_icmp.c
+++ b/sys/netinet/ip_icmp.c
@@ -783,10 +783,11 @@ icmp_reflect(struct mbuf *m)
if (IN_MULTICAST(ntohl(ip->ip_src.s_addr)) ||
(IN_EXPERIMENTAL(ntohl(ip->ip_src.s_addr)) && !V_ip_allow_net240) ||
- (IN_ZERONET(ntohl(ip->ip_src.s_addr)) && !V_ip_allow_net0) ) {
+ (IN_ZERONET(ntohl(ip->ip_src.s_addr)) && !V_ip_allow_net0) ||
+ in_nullhost(ip->ip_src) ) {
m_freem(m); /* Bad return address */
ICMPSTAT_INC(icps_badaddr);
- goto done; /* Ip_output() will check for broadcast */
+ goto done; /* ip_output() will check for broadcast */
}
t = ip->ip_dst;