From nobody Thu Apr 14 18:01:23 2022 X-Original-To: dev-commits-src-branches@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 EDAFB1B43F50; Thu, 14 Apr 2022 18:01:23 +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 4KfS2C5s5Nz3wB2; Thu, 14 Apr 2022 18:01:23 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1649959283; 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=I+yI0kI07EZp3his6BkyWMg7KQ79PpVpUXN2v7suz+8=; b=s7zLISioU+BvxSngKLvzZKOKQyt2WyBn/EvjtTB9IXxgSzFnG2/LSVWTNv35Wg9owUs6LJ 7YH0GxQItyktKrmI/MdS0NP1x2SW4Cja+KQUHEzx1TucwS1k8omJ4IqN6+jKJFM3f8MvTo BwhPYyc/nwriBzHy4Mo9VXeyhYAsmjD34wiN/oV3Denk/nJ6xiErbye3eDxVvhH/+hXh5L XEhOKsEr3stBxdAka533jOzv0vwbr2YWf1K0/Tw23cb3vg9HFWMP00NXcHxDxD1QvhayGL sAO42r5Ptnj9BCNALqPaSBOWa9G3S4bUWIvfizbE8maqzmIqhXdvA5zx+kQqXA== 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 A0F5524DE6; Thu, 14 Apr 2022 18:01:23 +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 23EI1Nua015920; Thu, 14 Apr 2022 18:01:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 23EI1N1s015919; Thu, 14 Apr 2022 18:01:23 GMT (envelope-from git) Date: Thu, 14 Apr 2022 18:01:23 GMT Message-Id: <202204141801.23EI1N1s015919@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: 48e84cceac14 - stable/13 - LinuxKPI: skbuff: handle dev_alloc_skb() correctly List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bz X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 48e84cceac14038ae1f9a51bc28f305a29f04af7 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1649959283; 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=I+yI0kI07EZp3his6BkyWMg7KQ79PpVpUXN2v7suz+8=; b=NixQb1OBy+CLSeQD3mSWT+Wbf+7QpeLNA84hPTgDC8/dbS9VYQ2b15cKxAfN0K1WuFTsBx l6PfmEa+PRojNpK2R//56mWQfdwF2c/2fpqfCFftiX1DAvtH2cQYhEjy6CBjJps1Nwj826 hUa0/k1IELJaVeFfxQHa170DHpzTsSH20xQ/IaojU1QXto9VQ1iBtEnJVGcvtpFUFVmUx5 RecAm/rQEyrkLWrxvgQ9irNXH0fTi2zBeVbZK5yBP3HaDJFl9uZxMlwuZgDPkSVN+pJWnK 6tmHs+z63DJmqPSZaGDBkFsApnN91ij++HWsN2jk47jKaz+J2XZrEKodOW6xHQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1649959283; a=rsa-sha256; cv=none; b=dJjPPAnqwXnpQEAtsalp1CksS62eDXKf//2SgSow4xDw3vDLXigmJqbIX/J9jqLnqiNJC9 ndQYDdov24BzWKgUyW6Rl7ycxQqPw49YzFm053SvMLCSV6IBCu0bzA+8MaKUqWRtxdU73w qQCA2Ge3hdTtvOPVmudapccACnVfDSOp4EkWd8SsjWhxUl/Fo5LHYjx9cUmPFsgxRGMqLl aPoXIBeqVGPZN7JJgSBcJyHvcew2VlcRoD5QxzcDCpiQ+RoD7fSjPA8p4PagS+VmStn5x6 p6YaV/ryw7QDbxTfnMhATgPVC4lp04eLKY5Bctv4YtJeQJhCQqAFRF50rNlIww== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=48e84cceac14038ae1f9a51bc28f305a29f04af7 commit 48e84cceac14038ae1f9a51bc28f305a29f04af7 Author: Bjoern A. Zeeb AuthorDate: 2022-04-07 18:06:55 +0000 Commit: Bjoern A. Zeeb CommitDate: 2022-04-14 16:38:01 +0000 LinuxKPI: skbuff: handle dev_alloc_skb() correctly dev_alloc_skb() comapred to alloc_skb() reserves some headroom at the beginning of the skb which is used by drivers. Split the code for the two cases and reserve NET_SKB_PAD space, which should at least be 32 octets. Sponsored by: The FreeBSD Foundation (cherry picked from commit 9df5f29caf1a818999d0e908cab95c83bd1f4323) --- sys/compat/linuxkpi/common/include/linux/skbuff.h | 8 +++++--- sys/compat/linuxkpi/common/src/linux_skbuff.c | 21 +++++++++++++++++++-- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/sys/compat/linuxkpi/common/include/linux/skbuff.h b/sys/compat/linuxkpi/common/include/linux/skbuff.h index 21ea7ee560e2..79d65c0169b3 100644 --- a/sys/compat/linuxkpi/common/include/linux/skbuff.h +++ b/sys/compat/linuxkpi/common/include/linux/skbuff.h @@ -38,6 +38,7 @@ #ifndef _LINUXKPI_LINUX_SKBUFF_H #define _LINUXKPI_LINUX_SKBUFF_H +#include #include #include #include @@ -84,7 +85,7 @@ enum sk_buff_pkt_type { PACKET_OTHERHOST, }; -#define NET_SKB_PAD CACHE_LINE_SIZE /* ? */ +#define NET_SKB_PAD max(CACHE_LINE_SIZE, 32) struct sk_buff_head { /* XXX TODO */ @@ -168,6 +169,7 @@ struct sk_buff { /* -------------------------------------------------------------------------- */ struct sk_buff *linuxkpi_alloc_skb(size_t, gfp_t); +struct sk_buff *linuxkpi_dev_alloc_skb(size_t, gfp_t); void linuxkpi_kfree_skb(struct sk_buff *); /* -------------------------------------------------------------------------- */ @@ -187,7 +189,7 @@ __dev_alloc_skb(size_t len, gfp_t gfp) { struct sk_buff *skb; - skb = alloc_skb(len, gfp); + skb = linuxkpi_dev_alloc_skb(len, gfp); SKB_IMPROVE(); SKB_TRACE(skb); return (skb); @@ -198,7 +200,7 @@ dev_alloc_skb(size_t len) { struct sk_buff *skb; - skb = alloc_skb(len, GFP_NOWAIT); + skb = __dev_alloc_skb(len, GFP_NOWAIT); SKB_IMPROVE(); SKB_TRACE(skb); return (skb); diff --git a/sys/compat/linuxkpi/common/src/linux_skbuff.c b/sys/compat/linuxkpi/common/src/linux_skbuff.c index efb97fa2f126..dfa9dfb2ceb4 100644 --- a/sys/compat/linuxkpi/common/src/linux_skbuff.c +++ b/sys/compat/linuxkpi/common/src/linux_skbuff.c @@ -80,7 +80,7 @@ linuxkpi_alloc_skb(size_t size, gfp_t gfp) skb = malloc(len, M_LKPISKB, linux_check_m_flags(gfp) | M_ZERO); if (skb == NULL) return (skb); - skb->_alloc_len = size; + skb->_alloc_len = len; skb->truesize = size; skb->head = skb->data = skb->tail = (uint8_t *)(skb+1); @@ -90,7 +90,24 @@ linuxkpi_alloc_skb(size_t size, gfp_t gfp) skb->shinfo = (struct skb_shared_info *)(skb->end); - SKB_TRACE_FMT(skb, "data %p size %zu", skb->data, size); + SKB_TRACE_FMT(skb, "data %p size %zu", (skb) ? skb->data : NULL, size); + return (skb); +} + +struct sk_buff * +linuxkpi_dev_alloc_skb(size_t size, gfp_t gfp) +{ + struct sk_buff *skb; + size_t len; + + len = size + NET_SKB_PAD; + skb = linuxkpi_alloc_skb(len, gfp); + + if (skb != NULL) + skb_reserve(skb, NET_SKB_PAD); + + SKB_TRACE_FMT(skb, "data %p size %zu len %zu", + (skb) ? skb->data : NULL, size, len); return (skb); }