From nobody Mon Feb 19 07:00:27 2024 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 4TdYMb43yvz59qR8; Mon, 19 Feb 2024 07:00:27 +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 4TdYMb3TY9z43Pw; Mon, 19 Feb 2024 07:00:27 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708326027; 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=81eATZNTZn4tGaYz4Xb6754t/95rwCI2x/y7lwdhgpk=; b=Iwe7fTy7R8n/qugQ3BphH7PxWeeUne6sUjXIoBcyitbETW6m79Kol9IPpbE9AILYHaWDFG jCJR45fz8pQtMyebHb+sF8doQmmxh65URXVrmBZr6XBW4GUor7FrB+9bUWc+8YNVQk96LQ Jql/5aGLrxgqYrtVVrbxGTZ7VRugtvtemZvZX+ogFc6GZ+VfsDUQwd3ScOMCqZKWncdY7V xlTQuljWuhCxpC6ebnNg3r0HqvHkwMOSoF1GzHa3n4InUespKt6ZS+2lXbcStmWHQt8nSy AjALjTNr4WkLbALqIMjlKEUsAbBSBaONgyEMk5RybHYi8Foidc3KYK9TkLsZsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708326027; 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=81eATZNTZn4tGaYz4Xb6754t/95rwCI2x/y7lwdhgpk=; b=FLH5ad+l+eneMbvGYyBrA9Jzs0JAP3mzqZWTHjKnR1gWHRgTw3+Ond2EDow63e/TQJSdqC Mh9h7O1hHSO3IrrRzGvj+L7YEA1tqHhULj7fiGWB6nZKRPMaLku6FdoPp/L3uK9VPLVryb kMuxqvdxdonPkgwg4PD9yqiYW79BiauOi47WrJp9THAduI/xpEy5j36Dewd6wUlpOqCtRv px/1OPLP94JdYtIBG3/M6PTNlz5TT8TnwSR+iUfNupshvwd27KNr3P3ueVHvkuHPlZ3iyR 53B2Jnqy0oJQzqdGVsri0VOk7MLeyvJYac8tLdrg0xkmw6i4XyUltGaNP7OGCg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1708326027; a=rsa-sha256; cv=none; b=fZIxOOGk+Vxwm7wo8Dz11PlL9WcOGeLF6zJnF7+5aYqrBMh87zs73vtyd4hIJTpwu4dfE4 Eia/OBozta/8req/9kmtZ4yrJgzvUSW2rCbUhahSXppl3vS2l6HnFIbkxHEubsq4xvpAYF +8VLSZIIbJvE52Aa997U1bOY1WaWhhoc2wPsu0LywDDQ4x9IpdpymNiSmEna/7QhNmVKWN UpyDkzpPn0G8k03M47Tf1MFX9WGFKSD9CoMX/XqqfRnZjRy+BDomcdo/4KXRVGisEtFIxS smbNwZM4vsO5u/Oie0dwzy6CiPeTrEoIqy9qbZ8iwlgqWCp2E03TQCHTitKPpw== 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 4TdYMb2YdpzPQm; Mon, 19 Feb 2024 07:00:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 41J70Reo006554; Mon, 19 Feb 2024 07:00:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 41J70R7o006551; Mon, 19 Feb 2024 07:00:27 GMT (envelope-from git) Date: Mon, 19 Feb 2024 07:00:27 GMT Message-Id: <202402190700.41J70R7o006551@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Warner Losh Subject: git: fbbfcab6b850 - releng/13.3 - vtnet: Adjust for ethernet alignment. 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: imp X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.3 X-Git-Reftype: branch X-Git-Commit: fbbfcab6b850fd0125633cc87575b54f0929c1a8 Auto-Submitted: auto-generated The branch releng/13.3 has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=fbbfcab6b850fd0125633cc87575b54f0929c1a8 commit fbbfcab6b850fd0125633cc87575b54f0929c1a8 Author: Warner Losh AuthorDate: 2024-01-29 05:08:55 +0000 Commit: Warner Losh CommitDate: 2024-02-19 06:59:40 +0000 vtnet: Adjust for ethernet alignment. If the header that we add to the packet's size is 0 % 4 and we're strictly aligning, then we need to adjust where we store the header so the packet that follows will have it's struct ip header properly aligned. We do this on allocation (and when we check the length of the mbufs in the lro_nomrg case). We can't just adjust the clustersz in the softc, because it's also used to allocate the mbufs and it needs to be the proper size for that. Since we otherwise use the size of the mbuf (or sometimes the smaller size of the received packet) to compute how much we can buffer, this ensures no overflows. The 2 byte adjustment also does not affect how many packets we can receive in the lro_nomrg case. PR: 271288 Sponsored by: Netflix Reviewed by: bryanv Differential Revision: https://reviews.freebsd.org/D43224 (cherry picked from commit 3be59adbb5a2ae7600d46432d3bc82286e507e95) (cherry picked from commit 778eb6e1f6668864a6eddd2f6f9bcc2aa26344f3) Approved-by: re (cperciva) --- sys/dev/virtio/network/if_vtnet.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/sys/dev/virtio/network/if_vtnet.c b/sys/dev/virtio/network/if_vtnet.c index 9737e964a591..3945826f91a0 100644 --- a/sys/dev/virtio/network/if_vtnet.c +++ b/sys/dev/virtio/network/if_vtnet.c @@ -1545,6 +1545,15 @@ vtnet_rx_alloc_buf(struct vtnet_softc *sc, int nbufs, struct mbuf **m_tailp) } m->m_len = size; +#ifndef __NO_STRICT_ALIGNMENT + /* + * Need to offset the mbuf if the header we're going to add + * will misalign. + */ + if (sc->vtnet_hdr_size % 4 == 0) { + m_adj(m, ETHER_ALIGN); + } +#endif if (m_head != NULL) { m_tail->m_next = m; m_tail = m; @@ -1571,6 +1580,14 @@ vtnet_rxq_replace_lro_nomrg_buf(struct vtnet_rxq *rxq, struct mbuf *m0, sc = rxq->vtnrx_sc; clustersz = sc->vtnet_rx_clustersz; +#ifndef __NO_STRICT_ALIGNMENT + /* + * Need to offset the mbuf if the header we're going to add will + * misalign, account for that here. + */ + if (sc->vtnet_hdr_size % 4 == 0) + clustersz -= ETHER_ALIGN; +#endif m_prev = NULL; m_tail = NULL; @@ -1694,6 +1711,10 @@ vtnet_rxq_enqueue_buf(struct vtnet_rxq *rxq, struct mbuf *m) header_inlined = vtnet_modern(sc) || (sc->vtnet_flags & VTNET_FLAG_MRG_RXBUFS) != 0; /* TODO: ANY_LAYOUT */ + /* + * Note: The mbuf has been already adjusted when we allocate it if we + * have to do strict alignment. + */ if (header_inlined) error = sglist_append_mbuf(sg, m); else {