git: 41356c80179c - main - net*: use inlined m_pullup()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 19 Oct 2026 17:32:33 UTC
The branch main has been updated by glebius:
URL: https://cgit.FreeBSD.org/src/commit/?id=41356c80179c708b6a49eabf1be9cedd6bca4444
commit 41356c80179c708b6a49eabf1be9cedd6bca4444
Author: Gleb Smirnoff <glebius@FreeBSD.org>
AuthorDate: 2026-10-19 17:32:00 +0000
Commit: Gleb Smirnoff <glebius@FreeBSD.org>
CommitDate: 2026-10-19 17:32:00 +0000
net*: use inlined m_pullup()
Leverage the fact that m_pullup() in an inline function in mbuf.h and let
compiler to do all optimizations.
Mostly mechanical changes, but in few cases surrounding lines are brought
to style(9). In netinet6, a few input functions changed to set the
input/output `struct mbuf **` pointer to NULL at a single place.
Reviewed by: pouria, zlei, gallatin
Differential Revision: https://reviews.freebsd.org/D60689
---
sys/net/bridgestp.c | 9 +-
sys/net/debugnet.c | 30 ++--
sys/net/debugnet_inet.c | 42 ++---
sys/net/ieee8023ad_lacp.c | 16 +-
sys/net/if_bridge.c | 75 +++------
sys/net/if_ethersubr.c | 10 +-
sys/net/if_geneve.c | 15 +-
sys/net/if_gif.c | 20 +--
sys/net/if_gre.c | 7 +-
sys/net/if_me.c | 12 +-
sys/net/if_stf.c | 22 +--
sys/net/if_tuntap.c | 3 +-
sys/net/if_vlan.c | 3 +-
sys/net/if_vxlan.c | 3 +-
sys/net/rtsock.c | 3 +-
sys/net80211/ieee80211_adhoc.c | 3 +-
sys/net80211/ieee80211_hostap.c | 3 +-
sys/net80211/ieee80211_input.c | 5 +-
sys/net80211/ieee80211_mesh.c | 9 +-
sys/net80211/ieee80211_output.c | 3 +-
sys/net80211/ieee80211_sta.c | 3 +-
sys/net80211/ieee80211_superg.c | 3 +-
sys/net80211/ieee80211_wds.c | 3 +-
sys/netgraph/bluetooth/hci/ng_hci_var.h | 4 +-
sys/netgraph/bluetooth/l2cap/ng_l2cap_misc.c | 2 +-
sys/netgraph/bluetooth/l2cap/ng_l2cap_var.h | 4 +-
.../bluetooth/socket/ng_btsocket_hci_raw.c | 8 +-
sys/netgraph/bluetooth/socket/ng_btsocket_l2cap.c | 17 +--
sys/netgraph/bluetooth/socket/ng_btsocket_rfcomm.c | 11 +-
sys/netgraph/bluetooth/socket/ng_btsocket_sco.c | 10 +-
sys/netgraph/netflow/ng_netflow.c | 9 +-
sys/netgraph/ng_UI.c | 3 +-
sys/netgraph/ng_bridge.c | 2 +-
sys/netgraph/ng_checksum.c | 10 +-
sys/netgraph/ng_eiface.c | 7 +-
sys/netgraph/ng_etf.c | 9 +-
sys/netgraph/ng_ether.c | 6 +-
sys/netgraph/ng_ether_echo.c | 9 +-
sys/netgraph/ng_frame_relay.c | 2 +-
sys/netgraph/ng_gif.c | 4 +-
sys/netgraph/ng_gif_demux.c | 3 +-
sys/netgraph/ng_ipfw.c | 6 +-
sys/netgraph/ng_l2tp.c | 12 +-
sys/netgraph/ng_lmi.c | 2 +-
sys/netgraph/ng_patch.c | 5 +-
sys/netgraph/ng_ppp.c | 14 +-
sys/netgraph/ng_pppoe.c | 34 ++---
sys/netgraph/ng_pptpgre.c | 45 +++---
sys/netgraph/ng_rfc1490.c | 3 +-
sys/netgraph/ng_tcpmss.c | 7 +-
sys/netgraph/ng_vjc.c | 18 +--
sys/netgraph/ng_vlan.c | 2 +-
sys/netgraph/ng_vlan_rotate.c | 9 +-
sys/netinet/if_ether.c | 16 +-
sys/netinet/ip_carp.c | 52 +++----
sys/netinet/ip_divert.c | 6 +-
sys/netinet/ip_icmp.c | 18 +--
sys/netinet/ip_input.c | 20 +--
sys/netinet/ip_mroute.c | 2 +-
sys/netinet/raw_ip.c | 9 +-
sys/netinet/tcp_input.c | 49 +++---
sys/netinet/tcp_stacks/rack_bbr_common.c | 20 +--
sys/netinet/tcp_subr.c | 26 ++--
sys/netinet/udp_usrreq.c | 8 +-
sys/netinet6/dest6.c | 26 +---
sys/netinet6/frag6.c | 20 +--
sys/netinet6/icmp6.c | 169 +++++++--------------
sys/netinet6/ip6_input.c | 40 ++---
sys/netinet6/ip6_mroute.c | 9 +-
sys/netinet6/mld6.c | 19 +--
sys/netinet6/nd6_nbr.c | 18 +--
sys/netinet6/nd6_rtr.c | 20 +--
sys/netinet6/raw_ip6.c | 3 +-
sys/netinet6/route6.c | 29 +---
sys/netinet6/sctp6_usrreq.c | 9 +-
sys/netinet6/send.c | 17 +--
sys/netinet6/udp6_usrreq.c | 24 ++-
sys/netipsec/ipsec_input.c | 5 +-
sys/netipsec/key.c | 88 ++++-------
sys/netipsec/keysock.c | 19 +--
sys/netipsec/xform_ah.c | 13 +-
sys/netipsec/xform_esp.c | 13 +-
sys/netipsec/xform_ipcomp.c | 4 +-
sys/netpfil/ipfw/ip_dn_io.c | 3 +-
sys/netpfil/ipfw/ip_fw2.c | 18 +--
sys/netpfil/ipfw/nat64/nat64_translate.c | 6 +-
sys/netpfil/ipfw/nat64/nat64clat.c | 3 +-
sys/netpfil/ipfw/nat64/nat64lsn.c | 20 +--
sys/netpfil/ipfw/nat64/nat64stl.c | 3 +-
sys/netpfil/ipfw/nptv6/nptv6.c | 3 +-
sys/netpfil/ipfw/pmod/tcpmod.c | 18 +--
sys/netpfil/pf/if_pfsync.c | 20 +--
sys/netpfil/pf/pf.c | 9 +-
93 files changed, 502 insertions(+), 951 deletions(-)
diff --git a/sys/net/bridgestp.c b/sys/net/bridgestp.c
index eb44f893183b..de1b2ea6eaf0 100644
--- a/sys/net/bridgestp.c
+++ b/sys/net/bridgestp.c
@@ -477,8 +477,7 @@ bstp_input(struct bstp_port *bp, struct ifnet *ifp, struct mbuf *m)
if (m->m_pkthdr.len > len)
m_adj(m, len - m->m_pkthdr.len);
- if (m->m_len < sizeof(tpdu) &&
- (m = m_pullup(m, sizeof(tpdu))) == NULL)
+ if ((m = m_pullup(m, sizeof(tpdu))) == NULL)
goto out;
memcpy(&tpdu, mtod(m, char *), sizeof(tpdu));
@@ -543,8 +542,7 @@ bstp_received_stp(struct bstp_state *bs, struct bstp_port *bp,
bstp_received_tcn(bs, bp, &tu);
break;
case BSTP_MSGTYPE_CFG:
- if ((*mp)->m_len < BSTP_BPDU_STP_LEN &&
- (*mp = m_pullup(*mp, BSTP_BPDU_STP_LEN)) == NULL)
+ if ((*mp = m_pullup(*mp, BSTP_BPDU_STP_LEN)) == NULL)
return;
memcpy(&cpdu, mtod(*mp, char *), BSTP_BPDU_STP_LEN);
@@ -564,8 +562,7 @@ bstp_received_rstp(struct bstp_state *bs, struct bstp_port *bp,
if (tpdu->tbu_bpdutype != BSTP_MSGTYPE_RSTP)
return;
- if ((*mp)->m_len < BSTP_BPDU_RSTP_LEN &&
- (*mp = m_pullup(*mp, BSTP_BPDU_RSTP_LEN)) == NULL)
+ if ((*mp = m_pullup(*mp, BSTP_BPDU_RSTP_LEN)) == NULL)
return;
memcpy(&cpdu, mtod(*mp, char *), BSTP_BPDU_RSTP_LEN);
diff --git a/sys/net/debugnet.c b/sys/net/debugnet.c
index 178aefafc6b3..225771a63f4d 100644
--- a/sys/net/debugnet.c
+++ b/sys/net/debugnet.c
@@ -391,13 +391,9 @@ debugnet_handle_rx_msg(struct debugnet_pcb *pcb, struct mbuf **mb)
}
/* Get ND header. */
- if (m->m_len < sizeof(*dnh)) {
- m = m_pullup(m, sizeof(*dnh));
- *mb = m;
- if (m == NULL) {
- DNETDEBUG("m_pullup failed\n");
- return;
- }
+ if ((*mb = m = m_pullup(m, sizeof(*dnh))) == NULL) {
+ DNETDEBUG("m_pullup failed\n");
+ return;
}
dnh = mtod(m, const struct debugnet_msg_hdr *);
@@ -451,13 +447,9 @@ debugnet_handle_ack(struct debugnet_pcb *pcb, struct mbuf **mb, uint16_t sport)
m = *mb;
/* Get Ack. */
- if (m->m_len < sizeof(*dn_ack)) {
- m = m_pullup(m, sizeof(*dn_ack));
- *mb = m;
- if (m == NULL) {
- DNETDEBUG("m_pullup failed\n");
- return;
- }
+ if ((*mb = m = m_pullup(m, sizeof(*dn_ack))) == NULL) {
+ DNETDEBUG("m_pullup failed\n");
+ return;
}
dn_ack = mtod(m, const struct debugnet_ack *);
@@ -495,13 +487,9 @@ debugnet_handle_udp(struct debugnet_pcb *pcb, struct mbuf **mb)
}
/* Get UDP headers. */
- if (m->m_len < sizeof(*udp)) {
- m = m_pullup(m, sizeof(*udp));
- *mb = m;
- if (m == NULL) {
- DNETDEBUG("m_pullup failed\n");
- return;
- }
+ if ((*mb = m = m_pullup(m, sizeof(*udp))) == NULL) {
+ DNETDEBUG("m_pullup failed\n");
+ return;
}
udp = mtod(m, const struct udphdr *);
diff --git a/sys/net/debugnet_inet.c b/sys/net/debugnet_inet.c
index eb228e326f99..f93c8d9b8a1e 100644
--- a/sys/net/debugnet_inet.c
+++ b/sys/net/debugnet_inet.c
@@ -93,13 +93,9 @@ debugnet_handle_ip(struct debugnet_pcb *pcb, struct mbuf **mb)
DNETDEBUG("dropping packet too small for IP header\n");
return;
}
- if (m->m_len < sizeof(struct ip)) {
- m = m_pullup(m, sizeof(struct ip));
- *mb = m;
- if (m == NULL) {
- DNETDEBUG("m_pullup failed\n");
- return;
- }
+ if ((*mb = m = m_pullup(m, sizeof(struct ip))) == NULL) {
+ DNETDEBUG("m_pullup failed\n");
+ return;
}
ip = mtod(m, struct ip *);
@@ -115,15 +111,11 @@ debugnet_handle_ip(struct debugnet_pcb *pcb, struct mbuf **mb)
DNETDEBUG("bad IP header length (%hu)\n", hlen);
return;
}
- if (hlen > m->m_len) {
- m = m_pullup(m, hlen);
- *mb = m;
- if (m == NULL) {
- DNETDEBUG("m_pullup failed\n");
- return;
- }
- ip = mtod(m, struct ip *);
+ if ((*mb = m = m_pullup(m, hlen)) == NULL) {
+ DNETDEBUG("m_pullup failed\n");
+ return;
}
+ ip = mtod(m, struct ip *);
/* Ignore packets with IP options. */
if (hlen > sizeof(struct ip)) {
DNETDEBUG("drop packet with IP options\n");
@@ -287,13 +279,9 @@ debugnet_handle_arp(struct debugnet_pcb *pcb, struct mbuf **mb)
m = *mb;
ifp = m->m_pkthdr.rcvif;
- if (m->m_len < sizeof(struct arphdr)) {
- m = m_pullup(m, sizeof(struct arphdr));
- *mb = m;
- if (m == NULL) {
- DNETDEBUG("runt packet: m_pullup failed\n");
- return;
- }
+ if ((*mb = m = m_pullup(m, sizeof(struct arphdr))) == NULL) {
+ DNETDEBUG("runt packet: m_pullup failed\n");
+ return;
}
ah = mtod(m, struct arphdr *);
@@ -308,13 +296,9 @@ debugnet_handle_arp(struct debugnet_pcb *pcb, struct mbuf **mb)
return;
}
req_len = arphdr_len2(ifp->if_addrlen, sizeof(struct in_addr));
- if (m->m_len < req_len) {
- m = m_pullup(m, req_len);
- *mb = m;
- if (m == NULL) {
- DNETDEBUG("runt packet: m_pullup failed\n");
- return;
- }
+ if ((*mb = m = m_pullup(m, req_len)) == NULL) {
+ DNETDEBUG("runt packet: m_pullup failed\n");
+ return;
}
ah = mtod(m, struct arphdr *);
diff --git a/sys/net/ieee8023ad_lacp.c b/sys/net/ieee8023ad_lacp.c
index 5d5fc88f205f..7861dfe455ca 100644
--- a/sys/net/ieee8023ad_lacp.c
+++ b/sys/net/ieee8023ad_lacp.c
@@ -279,12 +279,8 @@ lacp_pdu_input(struct lacp_port *lp, struct mbuf *m)
goto bad;
}
- if (m->m_len < sizeof(*du)) {
- m = m_pullup(m, sizeof(*du));
- if (m == NULL) {
- return (ENOMEM);
- }
- }
+ if ((m = m_pullup(m, sizeof(*du))) == NULL)
+ return (ENOMEM);
du = mtod(m, struct lacpdu *);
@@ -1922,12 +1918,8 @@ lacp_marker_input(struct lacp_port *lp, struct mbuf *m)
goto bad;
}
- if (m->m_len < sizeof(*mdu)) {
- m = m_pullup(m, sizeof(*mdu));
- if (m == NULL) {
- return (ENOMEM);
- }
- }
+ if ((m = m_pullup(m, sizeof(*mdu))) == NULL)
+ return (ENOMEM);
mdu = mtod(m, struct markerdu *);
diff --git a/sys/net/if_bridge.c b/sys/net/if_bridge.c
index 090b7e055662..04d773a58b45 100644
--- a/sys/net/if_bridge.c
+++ b/sys/net/if_bridge.c
@@ -2520,11 +2520,8 @@ bridge_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *sa,
NET_EPOCH_ASSERT();
- if (m->m_len < ETHER_HDR_LEN) {
- m = m_pullup(m, ETHER_HDR_LEN);
- if (m == NULL)
- return (0);
- }
+ if ((m = m_pullup(m, ETHER_HDR_LEN)) == NULL)
+ return (0);
sbif = ifp->if_bridge;
sc = sbif->bif_sc;
@@ -2855,11 +2852,8 @@ bridge_input(struct ifnet *ifp, struct mbuf *m)
NET_EPOCH_ASSERT();
/* We need the Ethernet header later, so make sure we have it now. */
- if (m->m_len < ETHER_HDR_LEN) {
- m = m_pullup(m, ETHER_HDR_LEN);
- if (m == NULL)
- return (NULL);
- }
+ if ((m = m_pullup(m, ETHER_HDR_LEN)) == NULL)
+ return (NULL);
eh = mtod(m, struct ether_header *);
vlan = VLANTAGOF(m);
@@ -3957,12 +3951,9 @@ bridge_pfil(struct mbuf **mp, struct ifnet *bifp, struct ifnet *ifp, int dir)
if (V_pfil_bridge == 0 && V_pfil_member == 0 && V_pfil_ipfw == 0)
return (0); /* filtering is disabled */
- if ((*mp)->m_len < ETHER_HDR_LEN) {
- *mp = m_pullup(*mp, ETHER_HDR_LEN);
- if (*mp == NULL) {
+ if ((*mp = m_pullup(*mp, ETHER_HDR_LEN)) == NULL) {
printf("%s: m_pullup failed\n", __func__);
return (-1);
- }
}
eh1 = mtod(*mp, struct ether_header *);
@@ -3976,14 +3967,11 @@ bridge_pfil(struct mbuf **mp, struct ifnet *bifp, struct ifnet *ifp, int dir)
i = min((*mp)->m_pkthdr.len,
ETHER_HDR_LEN + sizeof(struct llc));
- if ((*mp)->m_len < i) {
- *mp = m_pullup(*mp, i);
- if (*mp == NULL) {
- printf("%s: m_pullup failed\n", __func__);
- return (-1);
- }
- eh1 = mtod(*mp, struct ether_header *);
+ if ((*mp = m_pullup(*mp, i)) == NULL) {
+ printf("%s: m_pullup failed\n", __func__);
+ return (-1);
}
+ eh1 = mtod(*mp, struct ether_header *);
if ((*mp)->m_len >= ETHER_HDR_LEN + sizeof(struct llc)) {
llc2 = (struct llc *)(eh1 + 1);
@@ -4130,13 +4118,9 @@ bridge_pfil(struct mbuf **mp, struct ifnet *bifp, struct ifnet *ifp, int dir)
hlen = ip->ip_hl << 2;
if (hlen < sizeof(struct ip))
goto bad;
- if (hlen > (*mp)->m_len) {
- if ((*mp = m_pullup(*mp, hlen)) == NULL)
- goto bad;
- ip = mtod(*mp, struct ip *);
- if (ip == NULL)
- goto bad;
- }
+ if ((*mp = m_pullup(*mp, hlen)) == NULL)
+ goto bad;
+ ip = mtod(*mp, struct ip *);
ip->ip_sum = 0;
if (hlen == sizeof(struct ip))
ip->ip_sum = in_cksum_hdr(ip);
@@ -4233,11 +4217,9 @@ bridge_ip_checkbasic(struct mbuf **mp)
KMOD_IPSTAT_INC(ips_toosmall);
goto bad;
}
- } else if (__predict_false(m->m_len < sizeof (struct ip))) {
- if ((m = m_pullup(m, sizeof (struct ip))) == NULL) {
- KMOD_IPSTAT_INC(ips_toosmall);
- goto bad;
- }
+ } else if ((m = m_pullup(m, sizeof (struct ip))) == NULL) {
+ KMOD_IPSTAT_INC(ips_toosmall);
+ goto bad;
}
ip = mtod(m, struct ip *);
if (ip == NULL) goto bad;
@@ -4251,14 +4233,11 @@ bridge_ip_checkbasic(struct mbuf **mp)
KMOD_IPSTAT_INC(ips_badhlen);
goto bad;
}
- if (hlen > m->m_len) {
- if ((m = m_pullup(m, hlen)) == NULL) {
- KMOD_IPSTAT_INC(ips_badhlen);
- goto bad;
- }
- ip = mtod(m, struct ip *);
- if (ip == NULL) goto bad;
+ if ((m = m_pullup(m, hlen)) == NULL) {
+ KMOD_IPSTAT_INC(ips_badhlen);
+ goto bad;
}
+ ip = mtod(m, struct ip *);
if (m->m_pkthdr.csum_flags & CSUM_IP_CHECKED) {
sum = !(m->m_pkthdr.csum_flags & CSUM_IP_VALID);
@@ -4315,6 +4294,7 @@ static int
bridge_ip6_checkbasic(struct mbuf **mp)
{
struct mbuf *m = *mp;
+ struct ifnet *inifp = m->m_pkthdr.rcvif;
struct ip6_hdr *ip6;
/*
@@ -4324,7 +4304,6 @@ bridge_ip6_checkbasic(struct mbuf **mp)
* IPv6 header is in the first mbuf of the chain.
*/
if (IP6_HDR_ALIGNED_P(mtod(m, char *)) == 0) {
- struct ifnet *inifp = m->m_pkthdr.rcvif;
if ((m = m_copyup(m, sizeof(struct ip6_hdr),
(max_linkhdr + 3) & ~3)) == NULL) {
/* XXXJRT new stat, please */
@@ -4332,13 +4311,10 @@ bridge_ip6_checkbasic(struct mbuf **mp)
in6_ifstat_inc(inifp, ifs6_in_hdrerr);
goto bad;
}
- } else if (__predict_false(m->m_len < sizeof(struct ip6_hdr))) {
- struct ifnet *inifp = m->m_pkthdr.rcvif;
- if ((m = m_pullup(m, sizeof(struct ip6_hdr))) == NULL) {
- IP6STAT_INC(ip6s_toosmall);
- in6_ifstat_inc(inifp, ifs6_in_hdrerr);
- goto bad;
- }
+ } else if ((m = m_pullup(m, sizeof(struct ip6_hdr))) == NULL) {
+ IP6STAT_INC(ip6s_toosmall);
+ in6_ifstat_inc(inifp, ifs6_in_hdrerr);
+ goto bad;
}
ip6 = mtod(m, struct ip6_hdr *);
@@ -4373,8 +4349,7 @@ bridge_fragment(struct ifnet *ifp, struct mbuf **mp, struct ether_header *eh,
struct ip *ip;
int error = -1;
- if (m->m_len < sizeof(struct ip) &&
- (m = m_pullup(m, sizeof(struct ip))) == NULL) {
+ if ((m = m_pullup(m, sizeof(struct ip))) == NULL) {
KMOD_IPSTAT_INC(ips_odropped);
goto dropit;
}
diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c
index 69b4e1470d4b..e44308201a4f 100644
--- a/sys/net/if_ethersubr.c
+++ b/sys/net/if_ethersubr.c
@@ -575,8 +575,7 @@ ether_input_internal(struct ifnet *ifp, struct mbuf *m)
((etype == ETHERTYPE_VLAN) || (etype == ETHERTYPE_QINQ))) {
struct ether_vlan_header *evl;
- if (m->m_len < sizeof(*evl) &&
- (m = m_pullup(m, sizeof(*evl))) == NULL) {
+ if ((m = m_pullup(m, sizeof(*evl))) == NULL) {
#ifdef DIAGNOSTIC
if_printf(ifp, "cannot pullup VLAN header\n");
#endif
@@ -1259,11 +1258,8 @@ ether_vlanencap_proto(struct mbuf *m, uint16_t tag, uint16_t proto)
return (NULL);
/* M_PREPEND takes care of m_len, m_pkthdr.len for us */
- if (m->m_len < sizeof(*evl)) {
- m = m_pullup(m, sizeof(*evl));
- if (m == NULL)
- return (NULL);
- }
+ if ((m = m_pullup(m, sizeof(*evl))) == NULL)
+ return (NULL);
/*
* Transform the Ethernet header into an Ethernet header
diff --git a/sys/net/if_geneve.c b/sys/net/if_geneve.c
index 7d18e45741a3..e68bdfb76e4b 100644
--- a/sys/net/if_geneve.c
+++ b/sys/net/if_geneve.c
@@ -3096,18 +3096,14 @@ geneve_input_ether(struct geneve_softc *sc, struct mbuf **m0,
if (m->m_pkthdr.len < ETHER_HDR_LEN)
return (EINVAL);
- if (m->m_len < ETHER_HDR_LEN &&
- (m = m_pullup(m, ETHER_HDR_LEN)) == NULL) {
- *m0 = NULL;
+ if ((*m0 = m = m_pullup(m, ETHER_HDR_LEN)) == NULL)
return (ENOBUFS);
- }
eh = mtod(m, struct ether_header *);
info->ethertype = ntohs(eh->ether_type);
if (sc->gnv_flags & GENEVE_FLAG_LEARN)
geneve_ftable_learn(sc, sa, eh->ether_shost);
- *m0 = m;
return (0);
}
@@ -3128,8 +3124,7 @@ geneve_input_inherit(struct geneve_softc *sc, struct mbuf **m0,
if (m->m_pkthdr.len < offset)
return (EINVAL);
- if (m->m_len < offset &&
- (*m0 = m = m_pullup(m, offset)) == NULL)
+ if ((*m0 = m = m_pullup(m, offset)) == NULL)
return (ENOBUFS);
iphdr = mtodo(m, offset - sizeof(struct ip));
@@ -3147,8 +3142,7 @@ geneve_input_inherit(struct geneve_softc *sc, struct mbuf **m0,
if (m->m_pkthdr.len < offset)
return (EINVAL);
- if (m->m_len < offset &&
- (*m0 = m = m_pullup(m, offset)) == NULL)
+ if ((*m0 = m = m_pullup(m, offset)) == NULL)
return (ENOBUFS);
ip6hdr = mtodo(m, offset - sizeof(struct ip6_hdr));
@@ -3171,8 +3165,7 @@ geneve_input_inherit(struct geneve_softc *sc, struct mbuf **m0,
if (m->m_pkthdr.len < offset)
return (EINVAL);
- if (m->m_len < offset &&
- (*m0 = m = m_pullup(m, offset)) == NULL)
+ if ((*m0 = m = m_pullup(m, offset)) == NULL)
return (ENOBUFS);
info->isr = NETISR_ARP;
break;
diff --git a/sys/net/if_gif.c b/sys/net/if_gif.c
index c12c0de98864..82fd76a63103 100644
--- a/sys/net/if_gif.c
+++ b/sys/net/if_gif.c
@@ -470,9 +470,7 @@ gif_transmit(struct ifnet *ifp, struct mbuf *m)
#ifdef INET
case AF_INET:
proto = IPPROTO_IPV4;
- if (m->m_len < sizeof(struct ip))
- m = m_pullup(m, sizeof(struct ip));
- if (m == NULL) {
+ if ((m = m_pullup(m, sizeof(struct ip))) == NULL) {
error = ENOBUFS;
goto err;
}
@@ -484,9 +482,7 @@ gif_transmit(struct ifnet *ifp, struct mbuf *m)
#ifdef INET6
case AF_INET6:
proto = IPPROTO_IPV6;
- if (m->m_len < sizeof(struct ip6_hdr))
- m = m_pullup(m, sizeof(struct ip6_hdr));
- if (m == NULL) {
+ if ((m = m_pullup(m, sizeof(struct ip6_hdr))) == NULL) {
error = ENOBUFS;
goto err;
}
@@ -592,9 +588,7 @@ gif_input(struct mbuf *m, struct ifnet *ifp, int proto, uint8_t ecn)
#ifdef INET
case IPPROTO_IPV4:
af = AF_INET;
- if (m->m_len < sizeof(struct ip))
- m = m_pullup(m, sizeof(struct ip));
- if (m == NULL)
+ if ((m = m_pullup(m, sizeof(struct ip))) == NULL)
goto drop;
ip = mtod(m, struct ip *);
if (ip_ecn_egress((ifp->if_flags & IFF_LINK1) ? ECN_ALLOWED:
@@ -607,9 +601,7 @@ gif_input(struct mbuf *m, struct ifnet *ifp, int proto, uint8_t ecn)
#ifdef INET6
case IPPROTO_IPV6:
af = AF_INET6;
- if (m->m_len < sizeof(struct ip6_hdr))
- m = m_pullup(m, sizeof(struct ip6_hdr));
- if (m == NULL)
+ if ((m = m_pullup(m, sizeof(struct ip6_hdr))) == NULL)
goto drop;
t = htonl((uint32_t)ecn << 20);
ip6 = mtod(m, struct ip6_hdr *);
@@ -675,9 +667,7 @@ gif_input(struct mbuf *m, struct ifnet *ifp, int proto, uint8_t ecn)
case AF_LINK:
n = sizeof(struct etherip_header) +
sizeof(struct ether_header);
- if (n > m->m_len)
- m = m_pullup(m, n);
- if (m == NULL)
+ if ((m = m_pullup(m, n)) == NULL)
goto drop;
eip = mtod(m, struct etherip_header *);
if (eip->eip_ver != ETHERIP_VERSION) {
diff --git a/sys/net/if_gre.c b/sys/net/if_gre.c
index f29a98c1f365..971d7e01be0f 100644
--- a/sys/net/if_gre.c
+++ b/sys/net/if_gre.c
@@ -756,11 +756,8 @@ gre_input(struct mbuf *m, int off, int proto, void *arg)
hlen = off + sizeof(struct grehdr) + 4 * sizeof(uint32_t);
if (m->m_pkthdr.len < hlen)
goto drop;
- if (m->m_len < hlen) {
- m = m_pullup(m, hlen);
- if (m == NULL)
- goto drop;
- }
+ if ((m = m_pullup(m, hlen)) == NULL)
+ goto drop;
gh = (struct grehdr *)mtodo(m, off);
flags = ntohs(gh->gre_flags);
if (flags & ~GRE_FLAGS_MASK)
diff --git a/sys/net/if_me.c b/sys/net/if_me.c
index 9e690daab166..38d33720cd78 100644
--- a/sys/net/if_me.c
+++ b/sys/net/if_me.c
@@ -480,9 +480,7 @@ me_input(struct mbuf *m, int off, int proto, void *arg)
hlen = sizeof(struct mobhdr);
if (m->m_pkthdr.len < sizeof(struct ip) + hlen)
hlen -= sizeof(struct in_addr);
- if (m->m_len < sizeof(struct ip) + hlen)
- m = m_pullup(m, sizeof(struct ip) + hlen);
- if (m == NULL)
+ if ((m = m_pullup(m, sizeof(struct ip) + hlen)) == NULL)
goto drop;
mh = (struct mobhdr *)mtodo(m, sizeof(struct ip));
/* check for wrong flags */
@@ -581,9 +579,7 @@ me_transmit(struct ifnet *ifp, struct mbuf *m)
m_freem(m);
goto drop;
}
- if (m->m_len < sizeof(struct ip))
- m = m_pullup(m, sizeof(struct ip));
- if (m == NULL) {
+ if ((m = m_pullup(m, sizeof(struct ip))) == NULL) {
error = ENOBUFS;
goto drop;
}
@@ -615,9 +611,7 @@ me_transmit(struct ifnet *ifp, struct mbuf *m)
error = ENOBUFS;
goto drop;
}
- if (m->m_len < sizeof(struct ip) + hlen)
- m = m_pullup(m, sizeof(struct ip) + hlen);
- if (m == NULL) {
+ if ((m = m_pullup(m, sizeof(struct ip) + hlen)) == NULL) {
error = ENOBUFS;
goto drop;
}
diff --git a/sys/net/if_stf.c b/sys/net/if_stf.c
index bf0092747d5a..4aaf78291ab2 100644
--- a/sys/net/if_stf.c
+++ b/sys/net/if_stf.c
@@ -537,14 +537,10 @@ stf_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
return (ENETDOWN);
}
- if (m->m_len < sizeof(*ip6)) {
- m = m_pullup(m, sizeof(*ip6));
- if (!m) {
- if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
- SDT_PROBE2(if_stf, , stf_output, error, ENOBUFS,
- __LINE__);
- return (ENOBUFS);
- }
+ if ((m = m_pullup(m, sizeof(*ip6))) == NULL) {
+ if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
+ SDT_PROBE2(if_stf, , stf_output, error, ENOBUFS, __LINE__);
+ return (ENOBUFS);
}
ip6 = mtod(m, struct ip6_hdr *);
tos = IPV6_TRAFFIC_CLASS(ip6);
@@ -762,13 +758,9 @@ in_stf_input(struct mbuf *m, int off, int proto, void *arg)
otos = ip.ip_tos;
m_adj(m, off);
- if (m->m_len < sizeof(*ip6)) {
- m = m_pullup(m, sizeof(*ip6));
- if (!m) {
- SDT_PROBE2(if_stf, , stf_input, out, IPPROTO_DONE,
- __LINE__);
- return (IPPROTO_DONE);
- }
+ if ((m = m_pullup(m, sizeof(*ip6))) == NULL) {
+ SDT_PROBE2(if_stf, , stf_input, out, IPPROTO_DONE, __LINE__);
+ return (IPPROTO_DONE);
}
ip6 = mtod(m, struct ip6_hdr *);
diff --git a/sys/net/if_tuntap.c b/sys/net/if_tuntap.c
index b1ef08783c72..91f4478907ef 100644
--- a/sys/net/if_tuntap.c
+++ b/sys/net/if_tuntap.c
@@ -2005,8 +2005,7 @@ tunwrite_l3(struct tuntap_softc *tp, struct mbuf *m)
TUN_LOCK(tp);
if (tp->tun_flags & TUN_IFHEAD) {
TUN_UNLOCK(tp);
- if (m->m_len < sizeof(family) &&
- (m = m_pullup(m, sizeof(family))) == NULL)
+ if ((m = m_pullup(m, sizeof(family))) == NULL)
return (ENOBUFS);
family = ntohl(*mtod(m, u_int32_t *));
m_adj(m, sizeof(family));
diff --git a/sys/net/if_vlan.c b/sys/net/if_vlan.c
index 959c68a7f32b..73223187364e 100644
--- a/sys/net/if_vlan.c
+++ b/sys/net/if_vlan.c
@@ -1569,8 +1569,7 @@ vlan_input(struct ifnet *ifp, struct mbuf *m)
*/
switch (ifp->if_type) {
case IFT_ETHER:
- if (m->m_len < sizeof(*evl) &&
- (m = m_pullup(m, sizeof(*evl))) == NULL) {
+ if ((m = m_pullup(m, sizeof(*evl))) == NULL) {
if_printf(ifp, "cannot pullup VLAN header\n");
return;
}
diff --git a/sys/net/if_vxlan.c b/sys/net/if_vxlan.c
index fbe022d7fbde..5a23c316f202 100644
--- a/sys/net/if_vxlan.c
+++ b/sys/net/if_vxlan.c
@@ -2875,8 +2875,7 @@ vxlan_input(struct vxlan_socket *vso, uint32_t vni, struct mbuf **m0,
return (ENOENT);
ifp = sc->vxl_ifp;
- if (m->m_len < ETHER_HDR_LEN &&
- (m = *m0 = m_pullup(m, ETHER_HDR_LEN)) == NULL) {
+ if ((m = *m0 = m_pullup(m, ETHER_HDR_LEN)) == NULL) {
error = ENOBUFS;
goto out;
}
diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c
index 61403cde28e7..fffe3e8d32f1 100644
--- a/sys/net/rtsock.c
+++ b/sys/net/rtsock.c
@@ -1085,8 +1085,7 @@ rts_send(struct socket *so, int flags, struct mbuf *m,
fibnum = so->so_fibnum;
#define senderr(e) { error = e; goto flush;}
- if (m == NULL || ((m->m_len < sizeof(long)) &&
- (m = m_pullup(m, sizeof(long))) == NULL))
+ if (m == NULL || (m = m_pullup(m, sizeof(long))) == NULL)
return (ENOBUFS);
if ((m->m_flags & M_PKTHDR) == 0)
panic("route_output");
diff --git a/sys/net80211/ieee80211_adhoc.c b/sys/net80211/ieee80211_adhoc.c
index 16f20c0c636b..cd6ee0ec1202 100644
--- a/sys/net80211/ieee80211_adhoc.c
+++ b/sys/net80211/ieee80211_adhoc.c
@@ -452,8 +452,7 @@ adhoc_input(struct ieee80211_node *ni, struct mbuf *m,
switch (type) {
case IEEE80211_FC0_TYPE_DATA:
hdrspace = ieee80211_hdrspace(ic, wh);
- if (m->m_len < hdrspace &&
- (m = m_pullup(m, hdrspace)) == NULL) {
+ if ((m = m_pullup(m, hdrspace)) == NULL) {
IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_ANY,
ni->ni_macaddr, NULL,
"data too short: expecting %u", hdrspace);
diff --git a/sys/net80211/ieee80211_hostap.c b/sys/net80211/ieee80211_hostap.c
index 3505f7ba66e0..7f14ef2c8859 100644
--- a/sys/net80211/ieee80211_hostap.c
+++ b/sys/net80211/ieee80211_hostap.c
@@ -582,8 +582,7 @@ hostap_input(struct ieee80211_node *ni, struct mbuf *m,
switch (type) {
case IEEE80211_FC0_TYPE_DATA:
hdrspace = ieee80211_hdrspace(ic, wh);
- if (m->m_len < hdrspace &&
- (m = m_pullup(m, hdrspace)) == NULL) {
+ if ((m = m_pullup(m, hdrspace)) == NULL) {
IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_ANY,
ni->ni_macaddr, NULL,
"data too short: expecting %u", hdrspace);
diff --git a/sys/net80211/ieee80211_input.c b/sys/net80211/ieee80211_input.c
index a5f2abd747d6..8a7a7a8b90fd 100644
--- a/sys/net80211/ieee80211_input.c
+++ b/sys/net80211/ieee80211_input.c
@@ -319,8 +319,7 @@ ieee80211_decap(struct ieee80211vap *vap, struct mbuf *m, int hdrlen,
KASSERT(hdrlen <= sizeof(wh),
("hdrlen %d > max %zd", hdrlen, sizeof(wh)));
- if (m->m_len < hdrlen + sizeof(*llc) &&
- (m = m_pullup(m, hdrlen + sizeof(*llc))) == NULL) {
+ if ((m = m_pullup(m, hdrlen + sizeof(*llc))) == NULL) {
vap->iv_stats.is_rx_tooshort++;
/* XXX msg */
return NULL;
@@ -395,7 +394,7 @@ ieee80211_decap1(struct mbuf *m, int *framelen)
* copy the 802.3 header up to where it belongs and
* adjust the mbuf contents to remove the void.
*/
- if (m->m_len < FF_LLC_SIZE && (m = m_pullup(m, FF_LLC_SIZE)) == NULL)
+ if ((m = m_pullup(m, FF_LLC_SIZE)) == NULL)
return NULL;
eh = mtod(m, struct ether_header *); /* 802.3 header is first */
diff --git a/sys/net80211/ieee80211_mesh.c b/sys/net80211/ieee80211_mesh.c
index 900b0c2ad4cd..e2be5bd6fba4 100644
--- a/sys/net80211/ieee80211_mesh.c
+++ b/sys/net80211/ieee80211_mesh.c
@@ -1258,8 +1258,7 @@ mesh_decap(struct ieee80211vap *vap, struct mbuf *m, int hdrlen, int meshdrlen)
struct llc *llc;
int ae;
- if (m->m_len < hdrlen + sizeof(*llc) &&
- (m = m_pullup(m, hdrlen + sizeof(*llc))) == NULL) {
+ if ((m = m_pullup(m, hdrlen + sizeof(*llc))) == NULL) {
IEEE80211_DPRINTF(vap, IEEE80211_MSG_ANY,
"discard data frame: %s", "m_pullup failed");
vap->iv_stats.is_rx_tooshort++;
@@ -1673,9 +1672,8 @@ mesh_input(struct ieee80211_node *ni, struct mbuf *m,
}
/* pull up enough to get to the mesh control */
- if (m->m_len < hdrspace + sizeof(struct ieee80211_meshcntl) &&
- (m = m_pullup(m, hdrspace +
- sizeof(struct ieee80211_meshcntl))) == NULL) {
+ if ((m = m_pullup(m, hdrspace +
+ sizeof(struct ieee80211_meshcntl))) == NULL) {
IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_ANY,
ni->ni_macaddr, NULL,
"data too short: expecting %u", hdrspace);
@@ -1696,7 +1694,6 @@ mesh_input(struct ieee80211_node *ni, struct mbuf *m,
/* pull complete hdrspace = ieee80211_hdrspace + meshcontrol */
if ((meshdrlen > sizeof(struct ieee80211_meshcntl)) &&
- (m->m_len < hdrspace) &&
((m = m_pullup(m, hdrspace)) == NULL)) {
IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_ANY,
ni->ni_macaddr, NULL,
diff --git a/sys/net80211/ieee80211_output.c b/sys/net80211/ieee80211_output.c
index 116fc76a9ce1..fa7e08a4f722 100644
--- a/sys/net80211/ieee80211_output.c
+++ b/sys/net80211/ieee80211_output.c
@@ -365,8 +365,7 @@ ieee80211_start_pkt(struct ieee80211vap *vap, struct mbuf *m)
* mbuf has the 802.3 header present (and contiguous).
*/
ni = NULL;
- if (m->m_len < sizeof(struct ether_header) &&
- (m = m_pullup(m, sizeof(struct ether_header))) == NULL) {
+ if ((m = m_pullup(m, sizeof(struct ether_header))) == NULL) {
IEEE80211_DPRINTF(vap, IEEE80211_MSG_OUTPUT,
"discard frame, %s\n", "m_pullup failed");
vap->iv_stats.is_tx_nobuf++; /* XXX */
diff --git a/sys/net80211/ieee80211_sta.c b/sys/net80211/ieee80211_sta.c
index 550f837a0013..36dacc7da48a 100644
--- a/sys/net80211/ieee80211_sta.c
+++ b/sys/net80211/ieee80211_sta.c
@@ -657,8 +657,7 @@ sta_input(struct ieee80211_node *ni, struct mbuf *m,
switch (type) {
case IEEE80211_FC0_TYPE_DATA:
hdrspace = ieee80211_hdrspace(ic, wh);
- if (m->m_len < hdrspace &&
- (m = m_pullup(m, hdrspace)) == NULL) {
+ if ((m = m_pullup(m, hdrspace)) == NULL) {
IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_ANY,
ni->ni_macaddr, NULL,
"data too short: expecting %u", hdrspace);
diff --git a/sys/net80211/ieee80211_superg.c b/sys/net80211/ieee80211_superg.c
index cd1516302561..88a7b86040c7 100644
--- a/sys/net80211/ieee80211_superg.c
+++ b/sys/net80211/ieee80211_superg.c
@@ -285,8 +285,7 @@ ieee80211_ff_decap(struct ieee80211_node *ni, struct mbuf *m)
*/
if (m->m_pkthdr.len < 3*FF_LLC_SIZE)
return m;
- if (m->m_len < FF_LLC_SIZE &&
- (m = m_pullup(m, FF_LLC_SIZE)) == NULL) {
+ if ((m = m_pullup(m, FF_LLC_SIZE)) == NULL) {
IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_ANY,
ni->ni_macaddr, "fast-frame",
"%s", "m_pullup(llc) failed");
diff --git a/sys/net80211/ieee80211_wds.c b/sys/net80211/ieee80211_wds.c
index 75c37e49423a..5f44c312bf8b 100644
--- a/sys/net80211/ieee80211_wds.c
+++ b/sys/net80211/ieee80211_wds.c
@@ -508,8 +508,7 @@ wds_input(struct ieee80211_node *ni, struct mbuf *m,
switch (type) {
case IEEE80211_FC0_TYPE_DATA:
hdrspace = ieee80211_hdrspace(ic, wh);
- if (m->m_len < hdrspace &&
- (m = m_pullup(m, hdrspace)) == NULL) {
+ if ((m = m_pullup(m, hdrspace)) == NULL) {
IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_ANY,
ni->ni_macaddr, NULL,
"data too short: expecting %u", hdrspace);
diff --git a/sys/netgraph/bluetooth/hci/ng_hci_var.h b/sys/netgraph/bluetooth/hci/ng_hci_var.h
index a3f18779405b..6383e1c13931 100644
--- a/sys/netgraph/bluetooth/hci/ng_hci_var.h
+++ b/sys/netgraph/bluetooth/hci/ng_hci_var.h
@@ -51,9 +51,7 @@ MALLOC_DECLARE(M_NETGRAPH_HCI);
/* Wrapper around m_pullup */
#define NG_HCI_M_PULLUP(m, s) \
do { \
- if ((m)->m_len < (s)) \
- (m) = m_pullup((m), (s)); \
- if ((m) == NULL) \
+ if (((m) = m_pullup((m), (s))) == NULL) \
NG_HCI_ALERT("%s: %s - m_pullup(%zd) failed\n", \
__func__, NG_NODE_NAME(unit->node), (s)); \
} while (0)
diff --git a/sys/netgraph/bluetooth/l2cap/ng_l2cap_misc.c b/sys/netgraph/bluetooth/l2cap/ng_l2cap_misc.c
index d8e55cd07ab9..60cc16ba5433 100644
--- a/sys/netgraph/bluetooth/l2cap/ng_l2cap_misc.c
+++ b/sys/netgraph/bluetooth/l2cap/ng_l2cap_misc.c
@@ -594,7 +594,7 @@ struct mbuf *
ng_l2cap_prepend(struct mbuf *m, int size)
{
M_PREPEND(m, size, M_NOWAIT);
- if (m == NULL || (m->m_len < size && (m = m_pullup(m, size)) == NULL))
+ if (m == NULL || (m = m_pullup(m, size)) == NULL)
return (NULL);
return (m);
diff --git a/sys/netgraph/bluetooth/l2cap/ng_l2cap_var.h b/sys/netgraph/bluetooth/l2cap/ng_l2cap_var.h
index 9a782bea46d2..8a9c55017061 100644
--- a/sys/netgraph/bluetooth/l2cap/ng_l2cap_var.h
+++ b/sys/netgraph/bluetooth/l2cap/ng_l2cap_var.h
@@ -51,9 +51,7 @@ MALLOC_DECLARE(M_NETGRAPH_L2CAP);
/* Wrapper around m_pullup */
#define NG_L2CAP_M_PULLUP(m, s) \
do { \
- if ((m)->m_len < (s)) \
- (m) = m_pullup((m), (s)); \
- if ((m) == NULL) \
+ if (((m) = m_pullup((m), (s))) == NULL) \
NG_L2CAP_ALERT("%s: %s - m_pullup(%zd) failed\n", \
__func__, NG_NODE_NAME(l2cap->node), (s)); \
} while (0)
diff --git a/sys/netgraph/bluetooth/socket/ng_btsocket_hci_raw.c b/sys/netgraph/bluetooth/socket/ng_btsocket_hci_raw.c
index b123322b33aa..a94c2f413f6d 100644
--- a/sys/netgraph/bluetooth/socket/ng_btsocket_hci_raw.c
+++ b/sys/netgraph/bluetooth/socket/ng_btsocket_hci_raw.c
@@ -1586,11 +1586,9 @@ ng_btsocket_hci_raw_send(struct socket *so, int flags, struct mbuf *m,
goto drop;
}
- if (m->m_len < sizeof(ng_hci_cmd_pkt_t)) {
- if ((m = m_pullup(m, sizeof(ng_hci_cmd_pkt_t))) == NULL) {
- error = ENOBUFS;
- goto drop;
- }
+ if ((m = m_pullup(m, sizeof(ng_hci_cmd_pkt_t))) == NULL) {
+ error = ENOBUFS;
+ goto drop;
}
if (*mtod(m, u_int8_t *) != NG_HCI_CMD_PKT) {
error = ENOTSUP;
diff --git a/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap.c b/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap.c
index 1f0c5f1b4751..4a3ba1aea693 100644
--- a/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap.c
+++ b/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap.c
@@ -1431,11 +1431,8 @@ ng_btsocket_l2cap_data_input(struct mbuf *m, hook_p hook)
goto drop;
}
- if (m->m_len < sizeof(*hdr)) {
- m = m_pullup(m, sizeof(*hdr));
- if (m == NULL)
- goto drop;
- }
+ if ((m = m_pullup(m, sizeof(*hdr))) == NULL)
+ goto drop;
/* Strip L2CAP packet header and verify packet length */
*** 2652 LINES SKIPPED ***