From nobody Wed Dec 01 12:48:38 2021 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id DF4FE18BA2FE; Wed, 1 Dec 2021 12:48:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4J3zRC2WyMz3jfK; Wed, 1 Dec 2021 12:48:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5B82D18FF; Wed, 1 Dec 2021 12:48:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1B1Cmccg065974; Wed, 1 Dec 2021 12:48:38 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1B1Cmc7r065972; Wed, 1 Dec 2021 12:48:38 GMT (envelope-from git) Date: Wed, 1 Dec 2021 12:48:38 GMT Message-Id: <202112011248.1B1Cmc7r065972@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: f763c81c95bb - stable/13 - netinet: Remove unneeded mb_unmapped_to_ext() calls List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: f763c81c95bb5b68a11b12c9716ba2ee2b5d08fa Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1638362919; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=3rLaBg1XzmtYsHOLaTcr2FJN5Oz3/de/p8QRBh28RDA=; b=p3W2Y3L4Y1XnkqudljdpobgCKlajGgO1FhkINVlWkrvWSS6xALGOZAnFaUCOBDdcLFFV5/ HfPSkiTYBUf27wjyNyJ8N211QPQjpgRtEZvSWUI1gjc8HHRmMuOpAuhF6JxV9pzrcWwrZ7 i+lMx9oGNnny/rGGFO33aqxS388YLhJIua6ZG9kA9hz/jqNa1+rntt9gZAVONIK0CsU2Wu quWPlu7Rj6OT551iBzjlnZW0BHjOwuCoMH70nHI6y0Ch6c4Dv+jdIFWk8ByBL+gK8kfKy8 OoK1izWXP2WS2J15Df5nKn8XJ+wba6glh/dBI8RGBVPEaozWUwjCyxK3smM3uQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1638362919; a=rsa-sha256; cv=none; b=UeUordXsRXmQyZlpAaRFCcZvibWYVaIzzdG4qgfViHx8BbdU7xwyFNx7Hr/CkbRem8s+eZ x2MeS67chVRVYHzIz12+n74NF6pr8QVtbej8I8nN0aB+3fy/fFiWCMqpO5cH0GqMrlL0xy KaiJIfRkaTK285vWXD33oLhDGz2JyiGWm9E5Je5j1bxyYVktvScMRzxPyTIjoxBjyM10q7 Jo7lgd85DoNyA+/p1ybN2D6VFisDGSYHsbMQaJ5FDAi7/5qP6LF2odXbTa5pgSTMmi1mcV madIpnYlxpTgKxyyWggPo7Kqabj3vTF745gEDjYDfSLdtiMOymKj0i0f2IbDfw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=f763c81c95bb5b68a11b12c9716ba2ee2b5d08fa commit f763c81c95bb5b68a11b12c9716ba2ee2b5d08fa Author: Mark Johnston AuthorDate: 2021-11-24 18:20:09 +0000 Commit: Mark Johnston CommitDate: 2021-12-01 12:43:18 +0000 netinet: Remove unneeded mb_unmapped_to_ext() calls in_cksum_skip() now handles unmapped mbufs on platforms where they're permitted. Reviewed by: glebius, jhb Sponsored by: The FreeBSD Foundation (cherry picked from commit 44775b163bfa902ea96658343e852062e2e67a8e) --- sys/netinet/ip_divert.c | 6 ---- sys/netinet/ip_output.c | 21 ++++------- sys/netinet6/ip6_output.c | 62 ++++++++++++++------------------ sys/netipsec/ipsec_output.c | 12 ------- sys/netpfil/ipfw/nat64/nat64_translate.c | 10 ------ sys/netpfil/pf/pf.c | 6 ---- 6 files changed, 32 insertions(+), 85 deletions(-) diff --git a/sys/netinet/ip_divert.c b/sys/netinet/ip_divert.c index 936e216e0926..ab9f0c4febc6 100644 --- a/sys/netinet/ip_divert.c +++ b/sys/netinet/ip_divert.c @@ -212,9 +212,6 @@ divert_packet(struct mbuf *m, bool incoming) /* Delayed checksums are currently not compatible with divert. */ if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA) { - m = mb_unmapped_to_ext(m); - if (m == NULL) - return; in_delayed_cksum(m); m->m_pkthdr.csum_flags &= ~CSUM_DELAY_DATA; } @@ -226,9 +223,6 @@ divert_packet(struct mbuf *m, bool incoming) #endif #ifdef INET6 if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA_IPV6) { - m = mb_unmapped_to_ext(m); - if (m == NULL) - return; in6_delayed_cksum(m, m->m_pkthdr.len - sizeof(struct ip6_hdr), sizeof(struct ip6_hdr)); m->m_pkthdr.csum_flags &= ~CSUM_DELAY_DATA_IPV6; diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c index 4acec2bb877c..a011c28441bd 100644 --- a/sys/netinet/ip_output.c +++ b/sys/netinet/ip_output.c @@ -730,23 +730,20 @@ sendit: } } - m->m_pkthdr.csum_flags |= CSUM_IP; - if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA & ~ifp->if_hwassist) { + /* Ensure the packet data is mapped if the interface requires it. */ + if ((ifp->if_capenable & IFCAP_MEXTPG) == 0) { m = mb_unmapped_to_ext(m); if (m == NULL) { IPSTAT_INC(ips_odropped); error = ENOBUFS; goto bad; } + } + + m->m_pkthdr.csum_flags |= CSUM_IP; + if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA & ~ifp->if_hwassist) { in_delayed_cksum(m); m->m_pkthdr.csum_flags &= ~CSUM_DELAY_DATA; - } else if ((ifp->if_capenable & IFCAP_MEXTPG) == 0) { - m = mb_unmapped_to_ext(m); - if (m == NULL) { - IPSTAT_INC(ips_odropped); - error = ENOBUFS; - goto bad; - } } #if defined(SCTP) || defined(SCTP_SUPPORT) if (m->m_pkthdr.csum_flags & CSUM_SCTP & ~ifp->if_hwassist) { @@ -891,12 +888,6 @@ ip_fragment(struct ip *ip, struct mbuf **m_frag, int mtu, * fragmented packets, then do it here. */ if (m0->m_pkthdr.csum_flags & CSUM_DELAY_DATA) { - m0 = mb_unmapped_to_ext(m0); - if (m0 == NULL) { - error = ENOBUFS; - IPSTAT_INC(ips_odropped); - goto done; - } in_delayed_cksum(m0); m0->m_pkthdr.csum_flags &= ~CSUM_DELAY_DATA; } diff --git a/sys/netinet6/ip6_output.c b/sys/netinet6/ip6_output.c index 2b49a9f7c351..209169dbdabd 100644 --- a/sys/netinet6/ip6_output.c +++ b/sys/netinet6/ip6_output.c @@ -212,42 +212,26 @@ in6_delayed_cksum(struct mbuf *m, uint32_t plen, u_short offset) *(u_short *)mtodo(m, offset) = csum; } -static int +static void ip6_output_delayed_csum(struct mbuf *m, struct ifnet *ifp, int csum_flags, - int plen, int optlen, bool frag) + int plen, int optlen) { KASSERT((plen >= optlen), ("%s:%d: plen %d < optlen %d, m %p, ifp %p " - "csum_flags %#x frag %d\n", - __func__, __LINE__, plen, optlen, m, ifp, csum_flags, frag)); + "csum_flags %#x", + __func__, __LINE__, plen, optlen, m, ifp, csum_flags)); - if ((csum_flags & CSUM_DELAY_DATA_IPV6) || -#if defined(SCTP) || defined(SCTP_SUPPORT) - (csum_flags & CSUM_SCTP_IPV6) || -#endif - (!frag && (ifp->if_capenable & IFCAP_MEXTPG) == 0)) { - m = mb_unmapped_to_ext(m); - if (m == NULL) { - if (frag) - in6_ifstat_inc(ifp, ifs6_out_fragfail); - else - IP6STAT_INC(ip6s_odropped); - return (ENOBUFS); - } - if (csum_flags & CSUM_DELAY_DATA_IPV6) { - in6_delayed_cksum(m, plen - optlen, - sizeof(struct ip6_hdr) + optlen); - m->m_pkthdr.csum_flags &= ~CSUM_DELAY_DATA_IPV6; - } + if (csum_flags & CSUM_DELAY_DATA_IPV6) { + in6_delayed_cksum(m, plen - optlen, + sizeof(struct ip6_hdr) + optlen); + m->m_pkthdr.csum_flags &= ~CSUM_DELAY_DATA_IPV6; + } #if defined(SCTP) || defined(SCTP_SUPPORT) - if (csum_flags & CSUM_SCTP_IPV6) { - sctp_delayed_cksum(m, sizeof(struct ip6_hdr) + optlen); - m->m_pkthdr.csum_flags &= ~CSUM_SCTP_IPV6; - } -#endif + if (csum_flags & CSUM_SCTP_IPV6) { + sctp_delayed_cksum(m, sizeof(struct ip6_hdr) + optlen); + m->m_pkthdr.csum_flags &= ~CSUM_SCTP_IPV6; } - - return (0); +#endif } int @@ -1104,6 +1088,16 @@ nonh6lookup: passout: if (vlan_pcp > -1) EVL_APPLY_PRI(m, vlan_pcp); + + /* Ensure the packet data is mapped if the interface requires it. */ + if ((ifp->if_capenable & IFCAP_MEXTPG) == 0) { + m = mb_unmapped_to_ext(m); + if (m == NULL) { + IP6STAT_INC(ip6s_odropped); + return (ENOBUFS); + } + } + /* * Send the packet to the outgoing interface. * If necessary, do IPv6 fragmentation before sending. @@ -1136,9 +1130,7 @@ passout: * XXX-BZ Need a framework to know when the NIC can handle it, even * with ext. hdrs. */ - error = ip6_output_delayed_csum(m, ifp, sw_csum, plen, optlen, false); - if (error != 0) - goto bad; + ip6_output_delayed_csum(m, ifp, sw_csum, plen, optlen); /* XXX-BZ m->m_pkthdr.csum_flags &= ~ifp->if_hwassist; */ tlen = m->m_pkthdr.len; @@ -1217,10 +1209,8 @@ passout: * fragmented packets, then do it here. * XXX-BZ handle the hw offloading case. Need flags. */ - error = ip6_output_delayed_csum(m, ifp, m->m_pkthdr.csum_flags, - plen, optlen, true); - if (error != 0) - goto bad; + ip6_output_delayed_csum(m, ifp, m->m_pkthdr.csum_flags, plen, + optlen); /* * Change the next header field of the last header in the diff --git a/sys/netipsec/ipsec_output.c b/sys/netipsec/ipsec_output.c index a2deef95cdb5..99855e7209de 100644 --- a/sys/netipsec/ipsec_output.c +++ b/sys/netipsec/ipsec_output.c @@ -323,12 +323,6 @@ ipsec4_common_output(struct mbuf *m, struct inpcb *inp, int forwarding) * this is done in the normal processing path. */ if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA) { - m = mb_unmapped_to_ext(m); - if (m == NULL) { - IPSECSTAT_INC(ips_out_nomem); - key_freesp(&sp); - return (ENOBUFS); - } in_delayed_cksum(m); m->m_pkthdr.csum_flags &= ~CSUM_DELAY_DATA; } @@ -624,12 +618,6 @@ ipsec6_common_output(struct mbuf *m, struct inpcb *inp, int forwarding) * this is done in the normal processing path. */ if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA_IPV6) { - m = mb_unmapped_to_ext(m); - if (m == NULL) { - IPSEC6STAT_INC(ips_out_nomem); - key_freesp(&sp); - return (ENOBUFS); - } in6_delayed_cksum(m, m->m_pkthdr.len - sizeof(struct ip6_hdr), sizeof(struct ip6_hdr)); m->m_pkthdr.csum_flags &= ~CSUM_DELAY_DATA_IPV6; diff --git a/sys/netpfil/ipfw/nat64/nat64_translate.c b/sys/netpfil/ipfw/nat64/nat64_translate.c index aa6f47656d9d..fecc8ff334d2 100644 --- a/sys/netpfil/ipfw/nat64/nat64_translate.c +++ b/sys/netpfil/ipfw/nat64/nat64_translate.c @@ -1292,11 +1292,6 @@ nat64_do_handle_ip4(struct mbuf *m, struct in6_addr *saddr, /* Handle delayed checksums if needed. */ if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA) { - m = mb_unmapped_to_ext(m); - if (m == NULL) { - NAT64STAT_INC(&cfg->stats, nomem); - return (NAT64RETURN); - } in_delayed_cksum(m); m->m_pkthdr.csum_flags &= ~CSUM_DELAY_DATA; } @@ -1674,11 +1669,6 @@ nat64_do_handle_ip6(struct mbuf *m, uint32_t aaddr, uint16_t aport, /* Handle delayed checksums if needed. */ if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA_IPV6) { - m = mb_unmapped_to_ext(m); - if (m == NULL) { - NAT64STAT_INC(&cfg->stats, nomem); - return (NAT64RETURN); - } in6_delayed_cksum(m, plen, hlen); m->m_pkthdr.csum_flags &= ~CSUM_DELAY_DATA_IPV6; } diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c index 84db11d2f0ef..1e6911c16f73 100644 --- a/sys/netpfil/pf/pf.c +++ b/sys/netpfil/pf/pf.c @@ -5968,9 +5968,6 @@ pf_route(struct mbuf **m, struct pf_krule *r, int dir, struct ifnet *oifp, /* Copied from FreeBSD 10.0-CURRENT ip_output. */ m0->m_pkthdr.csum_flags |= CSUM_IP; if (m0->m_pkthdr.csum_flags & CSUM_DELAY_DATA & ~ifp->if_hwassist) { - m0 = mb_unmapped_to_ext(m0); - if (m0 == NULL) - goto done; in_delayed_cksum(m0); m0->m_pkthdr.csum_flags &= ~CSUM_DELAY_DATA; } @@ -6157,9 +6154,6 @@ pf_route6(struct mbuf **m, struct pf_krule *r, int dir, struct ifnet *oifp, if (m0->m_pkthdr.csum_flags & CSUM_DELAY_DATA_IPV6 & ~ifp->if_hwassist) { uint32_t plen = m0->m_pkthdr.len - sizeof(*ip6); - m0 = mb_unmapped_to_ext(m0); - if (m0 == NULL) - goto done; in6_delayed_cksum(m0, plen, sizeof(struct ip6_hdr)); m0->m_pkthdr.csum_flags &= ~CSUM_DELAY_DATA_IPV6; }