git: 3ae7c763540a - main - netinet: Make in_canforward() return bool
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 02 Mar 2025 15:02:44 UTC
The branch main has been updated by zlei: URL: https://cgit.FreeBSD.org/src/commit/?id=3ae7c763540afc0bc5320eb45f2661d315370eb8 commit 3ae7c763540afc0bc5320eb45f2661d315370eb8 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: Make in_canforward() return bool No functional change intended. MFC after: 5 days --- sys/netinet/in.c | 10 +++++----- sys/netinet/in.h | 2 +- sys/netinet/ip_input.c | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/sys/netinet/in.c b/sys/netinet/in.c index 22adc8277b93..2fcbff8611ff 100644 --- a/sys/netinet/in.c +++ b/sys/netinet/in.c @@ -271,19 +271,19 @@ in_findlocal(uint32_t fibnum, bool loopback_ok) * that may not be forwarded, or whether datagrams to that destination * may be forwarded. */ -int +bool in_canforward(struct in_addr in) { u_long i = ntohl(in.s_addr); if (IN_MULTICAST(i) || IN_LINKLOCAL(i) || IN_LOOPBACK(i) || in_nullhost(in)) - return (0); + return (false); if (IN_EXPERIMENTAL(i) && !V_ip_allow_net240) - return (0); + return (false); if (IN_ZERONET(i) && !V_ip_allow_net0) - return (0); - return (1); + return (false); + return (true); } /* diff --git a/sys/netinet/in.h b/sys/netinet/in.h index 3d087e5b06d5..3f2c388548ec 100644 --- a/sys/netinet/in.h +++ b/sys/netinet/in.h @@ -674,7 +674,7 @@ struct in_ifaddr; bool in_ifnet_broadcast(struct in_addr, struct ifnet *); bool in_ifaddr_broadcast(struct in_addr, struct in_ifaddr *); -int in_canforward(struct in_addr); +bool in_canforward(struct in_addr); bool in_localaddr(struct in_addr); bool in_localip(struct in_addr); bool in_localip_fib(struct in_addr, uint16_t); diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c index 08c48996a798..4d614dfeb0a2 100644 --- a/sys/netinet/ip_input.c +++ b/sys/netinet/ip_input.c @@ -924,7 +924,7 @@ ip_forward(struct mbuf *m, int srcrt) NET_EPOCH_ASSERT(); - if (m->m_flags & (M_BCAST|M_MCAST) || in_canforward(ip->ip_dst) == 0) { + if (m->m_flags & (M_BCAST|M_MCAST) || !in_canforward(ip->ip_dst)) { IPSTAT_INC(ips_cantforward); m_freem(m); return;