From nobody Fri Apr 15 15:56:50 2022 X-Original-To: dev-commits-src-main@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 64CC07CD4EB; Fri, 15 Apr 2022 15:56:51 +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 4Kg1D30q4Fz3G4d; Fri, 15 Apr 2022 15:56:51 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1650038211; 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=OESdbxYppBIUgX00CP6YDXO6j9+yzfUWB+Pylf/JxSQ=; b=yHZt0bmNKhVFCXz34mMaTaPcn4UmBc0BTMenxid8tNObLLTYnJ9KDgw0dKns14I7wwTGck FybmUrrN8VYSa3qEuCekS45OsCVODO6/ABK8RBdbuFrzp2hoHY5Z1Wgbm6PHbWtfYQfgzZ j53q04IR5powq6GZ0z/WOgPHiGQ6E0nkPRnHEUEfEYOk+MCeIBHnJXQvngkylCp2R03g/0 X3kHUfT38yWD6o96EWEkW30zv5NDEb3oxdMyH5TwfkNDBP+JaXUhJG0fYy6Nlo+K1ohyT5 banSCnG9+2D2fS6b1Ij9/UgZM/oQk7jW6ASZ6bPDDIsNr+M1RmZioDqoaJdzuw== 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 D85C01830F; Fri, 15 Apr 2022 15:56:50 +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 23FFuogc084310; Fri, 15 Apr 2022 15:56:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 23FFuo0H084309; Fri, 15 Apr 2022 15:56:50 GMT (envelope-from git) Date: Fri, 15 Apr 2022 15:56:50 GMT Message-Id: <202204151556.23FFuo0H084309@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: 349b042b9005 - main - LinuxKPI: skbuff: start implementing skb_copy() List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: 349b042b90057c1e9dbb64dfdb894fe03ea20a1d Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1650038211; 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=OESdbxYppBIUgX00CP6YDXO6j9+yzfUWB+Pylf/JxSQ=; b=rvRbRd3sld869ckI14jVaOKDpcUzc4W+4Ob3kMDwMPql44sNtcgLTYRHMewk/IoFQ9GKk3 hClZQifmbF6RimIjePPXr+4tYTETrHR+YG7kQt3jrSHfpDII+bw38t7bByVCxoiIx/yWLX eJAe5Lj2sde+/Pj+TuY8h8iGPdnlMRTgq817KcXR4x6XReM4/c8xHgEJSA+6ghbWiMkHxG l9rbLzGOQWcJQnxM1P31ZmVahp7tGzpUeW9dxB7xyHQ+T7BhAxCi0kz2luzQbh5036r20J UrBBoP1fWiT43xV+sfwZx12UoLv1eu08jFwdjusiuTVpV3ip0fInBMHFGzjQdA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1650038211; a=rsa-sha256; cv=none; b=GoS38eZdGVCCaYDXppw5tNuvKI10PR9g8BPxvsWX06o6ZuF1+QFdGrBHCM9p2CIsth/+bC FcghiOAjkQwKmNPePcxdWrBjiQThMLQHCSz7u31mNQFAKcIw1vH+5B5YmtNotJdxkHwHS6 5I3t3noow/JU8lWGkUIMUQTI7ONB10VlP5EQx/rqccWX1DQYKXP9cgWwWUTgmglw/I4jyL jqStJrO8YWOYk6U5RgCxOLPeYEvSU1/a0quPoN1qbVXiPsRXqCZqsxmStZLhds3915wTor 0lJPnt6n32o+Z+/CNifXKN3dnnjucYBEsNtBJEcPCgadR9EuqkXY3GxKFCg00A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=349b042b90057c1e9dbb64dfdb894fe03ea20a1d commit 349b042b90057c1e9dbb64dfdb894fe03ea20a1d Author: Bjoern A. Zeeb AuthorDate: 2022-04-15 12:30:51 +0000 Commit: Bjoern A. Zeeb CommitDate: 2022-04-15 15:54:03 +0000 LinuxKPI: skbuff: start implementing skb_copy() Implement skb_copy() with omissions of fragments and possibly other fields for now. Should we hit frags at any point a log message will let us know. For the few cases we need this currently this is enough. Sponsored by: The FreeBSD Foundation MFC after: 3 days --- sys/compat/linuxkpi/common/include/linux/skbuff.h | 10 ++++-- sys/compat/linuxkpi/common/src/linux_skbuff.c | 38 +++++++++++++++++++++++ 2 files changed, 45 insertions(+), 3 deletions(-) diff --git a/sys/compat/linuxkpi/common/include/linux/skbuff.h b/sys/compat/linuxkpi/common/include/linux/skbuff.h index 2b1b66844640..3caf7059dd15 100644 --- a/sys/compat/linuxkpi/common/include/linux/skbuff.h +++ b/sys/compat/linuxkpi/common/include/linux/skbuff.h @@ -172,6 +172,8 @@ 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 *); +struct sk_buff *linuxkpi_skb_copy(struct sk_buff *, gfp_t); + /* -------------------------------------------------------------------------- */ static inline struct sk_buff * @@ -667,9 +669,11 @@ skb_queue_prev(struct sk_buff_head *q, struct sk_buff *skb) static inline struct sk_buff * skb_copy(struct sk_buff *skb, gfp_t gfp) { - SKB_TRACE(skb); - SKB_TODO(); - return (NULL); + struct sk_buff *new; + + new = linuxkpi_skb_copy(skb, gfp); + SKB_TRACE2(skb, new); + return (new); } static inline void diff --git a/sys/compat/linuxkpi/common/src/linux_skbuff.c b/sys/compat/linuxkpi/common/src/linux_skbuff.c index dfa9dfb2ceb4..df1f6439c694 100644 --- a/sys/compat/linuxkpi/common/src/linux_skbuff.c +++ b/sys/compat/linuxkpi/common/src/linux_skbuff.c @@ -111,6 +111,44 @@ linuxkpi_dev_alloc_skb(size_t size, gfp_t gfp) return (skb); } +struct sk_buff * +linuxkpi_skb_copy(struct sk_buff *skb, gfp_t gfp) +{ + struct sk_buff *new; + struct skb_shared_info *shinfo; + size_t len; + unsigned int headroom; + + /* Full buffer size + any fragments. */ + len = skb->end - skb->head + skb->data_len; + + new = linuxkpi_alloc_skb(len, gfp); + if (new == NULL) + return (NULL); + + headroom = skb_headroom(skb); + /* Fixup head and end. */ + skb_reserve(new, headroom); /* data and tail move headroom forward. */ + skb_put(new, skb->len); /* tail and len get adjusted */ + + /* Copy data. */ + memcpy(new->head, skb->data - headroom, headroom + skb->len); + + /* Deal with fragments. */ + shinfo = skb->shinfo; + if (shinfo->nr_frags > 0) { + printf("%s:%d: NOT YET SUPPORTED; missing %d frags\n", + __func__, __LINE__, shinfo->nr_frags); + SKB_TODO(); + } + + /* Deal with header fields. */ + memcpy(new->cb, skb->cb, sizeof(skb->cb)); + SKB_IMPROVE("more header fields to copy?"); + + return (new); +} + void linuxkpi_kfree_skb(struct sk_buff *skb) {