git: cad2df3e90d1 - stable/14 - carp: Fix checking IPv4 multicast address
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 25 Feb 2025 04:01:58 UTC
The branch stable/14 has been updated by zlei:
URL: https://cgit.FreeBSD.org/src/commit/?id=cad2df3e90d19b083de11f940b20678716811459
commit cad2df3e90d19b083de11f940b20678716811459
Author: Zhenlei Huang <zlei@FreeBSD.org>
AuthorDate: 2025-02-22 19:26:33 +0000
Commit: Zhenlei Huang <zlei@FreeBSD.org>
CommitDate: 2025-02-25 04:01:22 +0000
carp: Fix checking IPv4 multicast address
An IPv4 address stored in `struct in_addr` is in network byte order but
`IN_MULTICAST` wants host order.
PR: 284872
Reported by: Steven Perreau
Reported by: Brett Merrick <brett.merrick@itcollective.nz>
Reviewed by: Franco Fichtner <franco@opnsense.org>, ae, kp, glebius
Tested by: Steven Perreau
Fixes: 137818006de5 carp: support unicast
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D49053
(cherry picked from commit 1776633438f24df09cb9815650891bcef0152874)
---
sys/netinet/ip_carp.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/sys/netinet/ip_carp.c b/sys/netinet/ip_carp.c
index ddbc13e7c878..3223a76c7860 100644
--- a/sys/netinet/ip_carp.c
+++ b/sys/netinet/ip_carp.c
@@ -722,7 +722,7 @@ carp_input_c(struct mbuf *m, struct carp_header *ch, sa_family_t af, int ttl)
sc = ifa->ifa_carp;
CARP_LOCK(sc);
if (ifa->ifa_addr->sa_family == AF_INET) {
- multicast = IN_MULTICAST(sc->sc_carpaddr.s_addr);
+ multicast = IN_MULTICAST(ntohl(sc->sc_carpaddr.s_addr));
} else {
multicast = IN6_IS_ADDR_MULTICAST(&sc->sc_carpaddr6);
}
@@ -988,7 +988,7 @@ carp_send_ad_locked(struct carp_softc *sc)
m->m_pkthdr.rcvif = NULL;
m->m_len = len;
M_ALIGN(m, m->m_len);
- if (IN_MULTICAST(sc->sc_carpaddr.s_addr))
+ if (IN_MULTICAST(ntohl(sc->sc_carpaddr.s_addr)))
m->m_flags |= M_MCAST;
ip = mtod(m, struct ip *);
ip->ip_v = IPVERSION;