From nobody Tue Jun 07 10:59:28 2022 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 04B9F5D6553; Tue, 7 Jun 2022 10:59:28 +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 4LHS6S3yfpz4mkL; Tue, 7 Jun 2022 10:59:28 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1654599568; 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=hX7h1gOUQA8fsExJEoDzp8JfJVcfvbs1TQ54VmR4tb4=; b=A3RNfpdd5oT1KFJqM4oMd79bvsTeusYfCTCJG8DCqzeUszC+9jC6AOcefBPnXe2HLMIPIU oTJ4ifBLnTCTWQJKg37yZTEHhFX0FAzcp6xyJ5hs391K6hAguC7uM9Q1v92se1u5vDuweO 29nYDuKL8n2JIC8zv0GEGDAE9waQ+6RK4/g4Gv+2Xk22oteo1YhutLv8/0OntL7eWp54Sm hzEz1iFpF3bZk9ufrMyM99+eQMyyH+ATdXqEsa/rDEzwVfeqctqed4BXuGtLtVJJziMabw 7b/Ru+qRnvSwWMhDf/NbHxZc7k5meXOG8015TKWAgm9n5jLmYW+mzOw7bBwnCQ== 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 2AE0319B5A; Tue, 7 Jun 2022 10:59:28 +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 257AxSmm035497; Tue, 7 Jun 2022 10:59:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 257AxSdX035496; Tue, 7 Jun 2022 10:59:28 GMT (envelope-from git) Date: Tue, 7 Jun 2022 10:59:28 GMT Message-Id: <202206071059.257AxSdX035496@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Hans Petter Selasky Subject: git: 4d88d81c3166 - main - mbuf(9): Implement a leaf network interface field in the mbuf packet header. 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: hselasky X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4d88d81c3166a80df8098d23a3cc26c2463da33d Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1654599568; 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=hX7h1gOUQA8fsExJEoDzp8JfJVcfvbs1TQ54VmR4tb4=; b=bNiNy1W80d/MLW+EMh0ckrtEf2ZzXkCMrlQnBxj8erxrEMT6xPjLn7UdTZjrtd+bncBusQ 6oBoPw90DUyFtj2iYqPHd8fhC8udq4axQOQK0wk7IHBAB6i1P7Df1V9RhPUBk9WBYttI3j z3ztpDHQ6IT/tH6yPY0a+LveILLuOQ6GruMIfClUBl8y8sRkmc+XbAgtYBGLrAEJ5tVkkg v4nrUuYJh9BJ0JVfaocAjKQ9tkb9uKLuIl/h9xkXS6apaZrgl1teMRfesFLUjsr4Pd5eSM UO6Z+viOHvk+Fpb/H17g14ABz9GYCHmKLvpfVXfMEPIhX6USCrp5lcXRiVaOvQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1654599568; a=rsa-sha256; cv=none; b=ux/JV1ePQlBErny0UR/ETlsWYXP9d/OVJw2ZdmdWW65F/JbYMLP/kUxxHh6X+ttJ2NG7v4 DdJSKgAeDazZ+M+p2qTKCE6lUR7rQQYEoBKwi/9kBdQqrtZPMHsphhfFXCRRbLtUVqo9IU 2b66qD3hGWthgTflQWT/s9LGg885SZcDnh+IaUFCYFonThLwhP1QFTvxFk0JsT28VJ3cJI qlc/3wzWenK5te/r15qNf8JpJJHzbpZNBYJhn+DDj0jNOAL8LVKgQTmMjSG4cmO1kv3zhd w2Alb6+Hx9F2Swx/SnEP6w4/sie1G1Zr07u5uwyDeA0OTGe9FMzT0mTjBvJCtQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by hselasky: URL: https://cgit.FreeBSD.org/src/commit/?id=4d88d81c3166a80df8098d23a3cc26c2463da33d commit 4d88d81c3166a80df8098d23a3cc26c2463da33d Author: Hans Petter Selasky AuthorDate: 2022-05-25 12:08:50 +0000 Commit: Hans Petter Selasky CommitDate: 2022-06-07 10:54:42 +0000 mbuf(9): Implement a leaf network interface field in the mbuf packet header. When packets are received they may traverse several network interfaces like vlan(4) and lagg(9). When doing receive side offloads it is important to know the first network interface entry point, because that is where all offloading is taking place. This makes it possible to track receive side route changes for multiport setups, for example when lagg(9) receives traffic from more than one port. This avoids having to install multiple offloading rules for the same stream. This field works similar to the existing "rcvif" mbuf packet header field. Submitted by: jhb@ Reviewed by: gallatin@ and gnn@ Differential revision: https://reviews.freebsd.org/D35339 Sponsored by: NVIDIA Networking Sponsored by: Netflix --- sys/kern/kern_mbuf.c | 25 +++++++++++++++++++++++-- sys/kern/uipc_mbuf.c | 4 ++-- sys/sys/mbuf.h | 11 +++++++++-- 3 files changed, 34 insertions(+), 6 deletions(-) diff --git a/sys/kern/kern_mbuf.c b/sys/kern/kern_mbuf.c index 23050e991418..2e307975b9ca 100644 --- a/sys/kern/kern_mbuf.c +++ b/sys/kern/kern_mbuf.c @@ -1645,12 +1645,21 @@ m_rcvif_serialize(struct mbuf *m) gen = m->m_pkthdr.rcvif->if_idxgen; m->m_pkthdr.rcvidx = idx; m->m_pkthdr.rcvgen = gen; + if (__predict_false(m->m_pkthdr.leaf_rcvif != NULL)) { + idx = m->m_pkthdr.leaf_rcvif->if_index; + gen = m->m_pkthdr.leaf_rcvif->if_idxgen; + } else { + idx = -1; + gen = 0; + } + m->m_pkthdr.leaf_rcvidx = idx; + m->m_pkthdr.leaf_rcvgen = gen; } struct ifnet * m_rcvif_restore(struct mbuf *m) { - struct ifnet *ifp; + struct ifnet *ifp, *leaf_ifp; M_ASSERTPKTHDR(m); NET_EPOCH_ASSERT(); @@ -1659,7 +1668,19 @@ m_rcvif_restore(struct mbuf *m) if (ifp == NULL || (ifp->if_flags & IFF_DYING)) return (NULL); - return (m->m_pkthdr.rcvif = ifp); + if (__predict_true(m->m_pkthdr.leaf_rcvidx == (u_short)-1)) { + leaf_ifp = NULL; + } else { + leaf_ifp = ifnet_byindexgen(m->m_pkthdr.leaf_rcvidx, + m->m_pkthdr.leaf_rcvgen); + if (__predict_false(leaf_ifp != NULL && (leaf_ifp->if_flags & IFF_DYING))) + leaf_ifp = NULL; + } + + m->m_pkthdr.leaf_rcvif = leaf_ifp; + m->m_pkthdr.rcvif = ifp; + + return (ifp); } /* diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c index dab068894f54..4a5bb45e9573 100644 --- a/sys/kern/uipc_mbuf.c +++ b/sys/kern/uipc_mbuf.c @@ -180,11 +180,11 @@ CTASSERT(offsetof(struct mbuf, m_pktdat) % 8 == 0); */ #if defined(__LP64__) CTASSERT(offsetof(struct mbuf, m_dat) == 32); -CTASSERT(sizeof(struct pkthdr) == 56); +CTASSERT(sizeof(struct pkthdr) == 64); CTASSERT(sizeof(struct m_ext) == 160); #else CTASSERT(offsetof(struct mbuf, m_dat) == 24); -CTASSERT(sizeof(struct pkthdr) == 48); +CTASSERT(sizeof(struct pkthdr) == 52); #if defined(__powerpc__) && defined(BOOKE) /* PowerPC booke has 64-bit physical pointers. */ CTASSERT(sizeof(struct m_ext) == 184); diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h index 61da52c6e67c..c9b3df075105 100644 --- a/sys/sys/mbuf.h +++ b/sys/sys/mbuf.h @@ -150,8 +150,8 @@ struct m_snd_tag { /* * Record/packet header in first mbuf of chain; valid only if M_PKTHDR is set. - * Size ILP32: 48 - * LP64: 56 + * Size ILP32: 52 + * LP64: 64 * Compile-time assertions in uipc_mbuf.c test these values to ensure that * they are correct. */ @@ -164,6 +164,13 @@ struct pkthdr { uint16_t rcvgen; /* ... and generation count */ }; }; + union { + struct ifnet *leaf_rcvif; /* leaf rcv interface */ + struct { + uint16_t leaf_rcvidx; /* leaf rcv interface index ... */ + uint16_t leaf_rcvgen; /* ... and generation count */ + }; + }; SLIST_HEAD(packet_tags, m_tag) tags; /* list of packet tags */ int32_t len; /* total packet length */