git: 70831490663b - stable/14 - netinet: Make in_canforward() return bool
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 07 Mar 2025 04:03:22 UTC
The branch stable/14 has been updated by zlei:
URL: https://cgit.FreeBSD.org/src/commit/?id=70831490663b7509203ff3f87beff1c8eda806a9
commit 70831490663b7509203ff3f87beff1c8eda806a9
Author: Zhenlei Huang <zlei@FreeBSD.org>
AuthorDate: 2025-03-02 15:00:42 +0000
Commit: Zhenlei Huang <zlei@FreeBSD.org>
CommitDate: 2025-03-07 04:02:41 +0000
netinet: Make in_canforward() return bool
No functional change intended.
MFC after: 5 days
(cherry picked from commit 3ae7c763540afc0bc5320eb45f2661d315370eb8)
---
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 bb36ef18d3e2..bafd1b549848 100644
--- a/sys/netinet/in.c
+++ b/sys/netinet/in.c
@@ -273,19 +273,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 8e7e3548c6ad..5c781d39d33e 100644
--- a/sys/netinet/in.h
+++ b/sys/netinet/in.h
@@ -676,7 +676,7 @@ struct in_ifaddr;
int in_broadcast(struct in_addr, struct ifnet *);
int 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 6d8165003950..7c01c4959841 100644
--- a/sys/netinet/ip_input.c
+++ b/sys/netinet/ip_input.c
@@ -932,7 +932,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;