From 7d73d211bdbcef2b485b05bc15b0b328f2e93680 Mon Sep 17 00:00:00 2001 From: David Hauweele Date: Thu, 18 Dec 2025 17:36:43 +0100 Subject: [PATCH 1/2] fix: use ifnet kernel interfaces --- ndpacket.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ndpacket.c b/ndpacket.c index 004c006..0a70ffe 100644 --- a/ndpacket.c +++ b/ndpacket.c @@ -183,7 +183,7 @@ int packet(void *packet_arg, struct mbuf **packet_mp, struct ifnet *packet_ifnet // create a new mbuf to send a neighbor advertisement // ICMPv6 options are rounded up to 8 bytes alignment maxlen = (sizeof(struct ip6_hdr) + sizeof(struct nd_neighbor_advert) + - sizeof(struct nd_opt_hdr) + packet_ifnet->if_addrlen + 7) & ~7; + sizeof(struct nd_opt_hdr) + if_getaddrlen(packet_ifnet) + 7) & ~7; if (max_linkhdr + maxlen > MCLBYTES) { printf("NDPROXY ERROR: reply length > MCLBYTES\n"); return 0; @@ -203,7 +203,7 @@ int packet(void *packet_arg, struct mbuf **packet_mp, struct ifnet *packet_ifnet // packet content: // IPv6 header + ICMPv6 Neighbor Advertisement including target address + target link-layer ICMPv6 address option mreply->m_pkthdr.len = mreply->m_len = (sizeof(struct ip6_hdr) + sizeof(struct nd_neighbor_advert) - + sizeof(struct nd_opt_hdr) + packet_ifnet->if_addrlen + 7) & ~7; + + sizeof(struct nd_opt_hdr) + if_getaddrlen(packet_ifnet) + 7) & ~7; // reserve space for the link-layer header mreply->m_data += max_linkhdr; From 808e23b9ce0d582b75b2952bc5f12b9104994a43 Mon Sep 17 00:00:00 2001 From: David Hauweele Date: Sat, 20 Dec 2025 21:58:50 +0100 Subject: [PATCH 2/2] fix: add missing ifnet function in FreeBSD 13 --- ndpacket.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ndpacket.c b/ndpacket.c index 0a70ffe..d499ca2 100644 --- a/ndpacket.c +++ b/ndpacket.c @@ -59,6 +59,12 @@ // called by pfil_run_hooks() @ ip6_input.c:ip_input() +#if __FreeBSD_version < 1400000 +static uint8_t if_getaddrlen(if_t ifp) { + return (ifp->if_addrlen); +} +#endif + #ifdef PFIL_VERSION pfil_return_t packet(struct mbuf **packet_mp, struct ifnet *packet_ifnet, const int packet_dir, void *packet_arg, struct inpcb *packet_inpcb) {