Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 31 Oct 2024 20:33:20 GMT
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 28aafeb83c08 - main - netinet*: Add assertions for some places that don't support M_EXTPG mbufs
Message-ID:  <202410312033.49VKXK29081902@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=28aafeb83c085b83d03c8f2f2fe0a785f640c026

commit 28aafeb83c085b83d03c8f2f2fe0a785f640c026
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2024-10-31 20:32:32 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2024-10-31 20:32:32 +0000

    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
---
 sys/netinet/igmp.c        | 1 +
 sys/netinet/ip_mroute.c   | 4 ++++
 sys/netinet/ip_options.c  | 2 ++
 sys/netinet6/ip6_mroute.c | 5 +++++
 4 files changed, 12 insertions(+)

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,



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202410312033.49VKXK29081902>