aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2024-10-31 20:32:32 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2024-10-31 20:32:32 +0000
commit28aafeb83c085b83d03c8f2f2fe0a785f640c026 (patch)
treea3419f4010104e41b833ae87c954bbc3b3838c0c
parentf02d9edfb5d695734b8866c81d2da0c7700c8779 (diff)
downloadsrc-28aafeb83c08.tar.gz
src-28aafeb83c08.zip
netinet*: Add assertions for some places that don't support M_EXTPG mbufs
Found while auditing calls to M_WRITABLE to see if M_EXTPG could be removed from its checks. Reviewed by: gallatin Differential Revision: https://reviews.freebsd.org/D46785
-rw-r--r--sys/netinet/igmp.c1
-rw-r--r--sys/netinet/ip_mroute.c4
-rw-r--r--sys/netinet/ip_options.c2
-rw-r--r--sys/netinet6/ip6_mroute.c5
4 files changed, 12 insertions, 0 deletions
diff --git a/sys/netinet/igmp.c b/sys/netinet/igmp.c
index 454668c2aadc..5082b6294ebb 100644
--- a/sys/netinet/igmp.c
+++ b/sys/netinet/igmp.c
@@ -1471,6 +1471,7 @@ igmp_input(struct mbuf **mp, int *offp, int proto)
m = *mp;
ifp = m->m_pkthdr.rcvif;
*mp = NULL;
+ M_ASSERTMAPPED(m);
IGMPSTAT_INC(igps_rcv_total);
diff --git a/sys/netinet/ip_mroute.c b/sys/netinet/ip_mroute.c
index afa199ce0691..501b3e0d9a43 100644
--- a/sys/netinet/ip_mroute.c
+++ b/sys/netinet/ip_mroute.c
@@ -1311,6 +1311,8 @@ X_ip_mforward(struct ip *ip, struct ifnet *ifp, struct mbuf *m,
u_long hash;
int hlen;
+ M_ASSERTMAPPED(m);
+
CTR3(KTR_IPMF, "ip_mforward: delete mfc orig 0x%08x group %lx ifp %p",
ntohl(ip->ip_src.s_addr), (u_long)ntohl(ip->ip_dst.s_addr), ifp);
@@ -1562,6 +1564,7 @@ ip_mdq(struct mbuf *m, struct ifnet *ifp, struct mfc *rt, vifi_t xmt_vif)
vifi_t vifi;
int plen = ntohs(ip->ip_len);
+ M_ASSERTMAPPED(m);
MRW_LOCK_ASSERT();
NET_EPOCH_ASSERT();
@@ -1745,6 +1748,7 @@ phyint_send(struct ip *ip, struct vif *vifp, struct mbuf *m)
int hlen = ip->ip_hl << 2;
MRW_LOCK_ASSERT();
+ M_ASSERTMAPPED(m);
/*
* Make a new reference to the packet; make sure that
diff --git a/sys/netinet/ip_options.c b/sys/netinet/ip_options.c
index 41f77a7491f2..a9d6836d9e97 100644
--- a/sys/netinet/ip_options.c
+++ b/sys/netinet/ip_options.c
@@ -514,6 +514,8 @@ ip_insertoptions(struct mbuf *m, struct mbuf *opt, int *phlen)
*phlen = 0;
return (m); /* XXX should fail */
}
+ KASSERT((m->m_flags & M_EXTPG) == 0, ("%s: mbuf %p is unmapped",
+ __func__, m));
if (p->ipopt_dst.s_addr)
ip->ip_dst = p->ipopt_dst;
if (!M_WRITABLE(m) || M_LEADINGSPACE(m) < optlen) {
diff --git a/sys/netinet6/ip6_mroute.c b/sys/netinet6/ip6_mroute.c
index 3e849e5b36dd..f3c68d61f245 100644
--- a/sys/netinet6/ip6_mroute.c
+++ b/sys/netinet6/ip6_mroute.c
@@ -1073,6 +1073,7 @@ X_ip6_mforward(struct ip6_hdr *ip6, struct ifnet *ifp, struct mbuf *m)
GET_TIME(tp);
#endif /* UPCALL_TIMING */
+ M_ASSERTMAPPED(m);
MRT6_DLOG(DEBUG_FORWARD, "src %s, dst %s, ifindex %d",
ip6_sprintf(ip6bufs, &ip6->ip6_src),
ip6_sprintf(ip6bufd, &ip6->ip6_dst), ifp->if_index);
@@ -1364,6 +1365,8 @@ ip6_mdq(struct mbuf *m, struct ifnet *ifp, struct mf6c *rt)
u_int32_t iszone, idzone, oszone, odzone;
int error = 0;
+ M_ASSERTMAPPED(m);
+
/*
* Don't forward if it didn't arrive from the parent mif
* for its origin.
@@ -1527,6 +1530,8 @@ phyint_send(struct ip6_hdr *ip6, struct mif6 *mifp, struct mbuf *m)
int error __unused = 0;
u_long linkmtu;
+ M_ASSERTMAPPED(m);
+
/*
* Make a new reference to the packet; make sure that
* the IPv6 header is actually copied, not just referenced,