Commit 4c25199465 for frr
commit 4c2519946519946233a3d1e3b8407d13a3ee31be
Author: Vincent Jardin <vjardin@free.fr>
Date: Wed Nov 11 10:48:35 2026 +0100
lib,ospfd,eigrpd: use the BSD raw IP header byte order on macOS
With IP_HDRINCL, XNU takes ip_len and ip_off in host byte order, like
the BSDs it comes from.
ospfd and eigrpd give them in network byte order, which makes ip_len
larger than the packet, and sendmsg() fails:
sendmsg in ospf_write failed to 224.0.0.5, id 0, off 0, len 64, interface en0, mtu 1500: Invalid argument
so OSPFv2 and EIGRP never send anything on macOS.
On input, XNU also gives ip_len without the length of the IP header,
like FreeBSD used to do !
Signed-off-by: Vincent Jardin <vjardin@free.fr>
diff --git a/eigrpd/eigrp_packet.c b/eigrpd/eigrp_packet.c
index f72b2f14b0..6222a20cde 100644
--- a/eigrpd/eigrp_packet.c
+++ b/eigrpd/eigrp_packet.c
@@ -732,7 +732,7 @@ static struct stream *eigrp_recv_packet(struct eigrp *eigrp,
ip_len = iph->ip_len;
-#if defined(__FreeBSD__) && (__FreeBSD_version < 1000000)
+#if (defined(__FreeBSD__) && (__FreeBSD_version < 1000000)) || defined(__APPLE__)
/*
* Kernel network code touches incoming IP header parameters,
* before protocol specific processing.
@@ -750,6 +750,11 @@ static struct stream *eigrp_recv_packet(struct eigrp *eigrp,
ip_len = ip_len + (iph->ip_hl << 2);
#endif
+#if defined(__APPLE__)
+ /* eigrp_read() computes the EIGRP length from the header */
+ iph->ip_len = ip_len;
+#endif
+
#if defined(__DragonFly__)
/*
* in DragonFly's raw socket, ip_len/ip_off are read
diff --git a/lib/zebra.h b/lib/zebra.h
index 96b638a487..db7b4a1dec 100644
--- a/lib/zebra.h
+++ b/lib/zebra.h
@@ -127,9 +127,10 @@ extern "C" {
* SunOS: nominally as per BSD. but bug: network order on LE.
* OpenBSD: network byte order, apart from older versions which are as per
* *BSD
+ * macOS: as per *BSD, a length in network byte order is rejected (EINVAL)
*/
-#if defined(__NetBSD__) || \
- (defined(__FreeBSD__) && (__FreeBSD_version < 1100030)) || \
+#if defined(__NetBSD__) || defined(__APPLE__) || \
+ (defined(__FreeBSD__) && (__FreeBSD_version < 1100030)) || \
(defined(__OpenBSD__) && (OpenBSD < 200311))
#define HAVE_IP_HDRINCL_BSD_ORDER
#endif
diff --git a/ospfd/ospf_packet.c b/ospfd/ospf_packet.c
index 2073ee18ab..017b3c3ef8 100644
--- a/ospfd/ospf_packet.c
+++ b/ospfd/ospf_packet.c
@@ -2864,7 +2864,7 @@ static struct stream *ospf_recv_packet(struct ospf *ospf, int fd,
ip_len = iph->ip_len;
-#if defined(__FreeBSD__) && (__FreeBSD_version < 1000000)
+#if (defined(__FreeBSD__) && (__FreeBSD_version < 1000000)) || defined(__APPLE__)
/*
* Kernel network code touches incoming IP header parameters,
* before protocol specific processing.