From nobody Thu May 05 19:14:52 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 973971ACA3FF; Thu, 5 May 2022 19:14:53 +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 4KvNgK1gHGz4mkq; Thu, 5 May 2022 19:14:53 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1651778093; 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=3YojqZRvhsiIcsrlDopeMnvAOHG8zQHSyQw1Lf+ez94=; b=RJCMzkwFbivVCuyDjQ+WK5grEtmAvWXgXApjY49vG27mGZFN4adqnO/mh5+LuXIJ85NFBN 23+rUVcIlijgIT/j+3+Lzn+yUhkkhsU6uqBLAIi3d9eNFjTZ5S6cKbJObB1sFtvOehkxz6 MXcP2Su3+j+vafxaKkCl4Lh7k3L6ie1fsgmTjm3gIRb4wO09yrePpOI80kTeUwMaKg0omY MoHLgRAvfDGUt2UfCE3EzoBllVLGefksdTPjrg9q4e3tJz6YNrS7LmUmO6UvjRBq7nr1UC vAxwlohSoMxxf0ZJHs/okrI/MFqtYBXrboRj0oEvOabniu5ZvA0gFP4d89k0sw== 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 EC56C51AD; Thu, 5 May 2022 19:14:52 +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 245JEqxd090323; Thu, 5 May 2022 19:14:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 245JEqTN090322; Thu, 5 May 2022 19:14:52 GMT (envelope-from git) Date: Thu, 5 May 2022 19:14:52 GMT Message-Id: <202205051914.245JEqTN090322@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ed Maste Subject: git: 51f798e761b1 - main - netisr: serialize/restore m_pkthdr.rcvif when queueing mbufs 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: emaste X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 51f798e761b1b30fc2432cce4295271c0689bd1f Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1651778093; 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=3YojqZRvhsiIcsrlDopeMnvAOHG8zQHSyQw1Lf+ez94=; b=jSOsRSZ8qpk7wpsd1j0ox5gRm1mzBAOvOLT+Y1QeIFWNyKGfNhFPwmsVIXUPVS//Cqh+bV fIE08pQ25s28kLerfpIjwgVTO3gxGn12POspo6DnvoVBe4/aj+1XZf4BbQKhS/u58M1hQw D5qqbt51rA4Q0Jh606caex0uwt5LULWtYuKpvrYWkojtjvHy4ebHPtTETudwGjN8zBXlcB pnQtdi/YOiVcZFVl1zKjE3V6eOtayKQiy27t0afVopj3V8v/wU59x1p71W14/+j2OEf8Uy zvOxDfHJXLHG4DjflH3HGyCUJmJMcJz41xsI78Ll8Ov981DEneXvg1tmnsdmjw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1651778093; a=rsa-sha256; cv=none; b=algTLs57HNws4fDov3Y1FJv3B7S/BJz6e7HyOsAIF3ZVFStkEmphE6ffm1WreCy9ULY9GU eVZlto+8meGR6gr656KkTNmPR4oLPPQ43GIQq6ZbR4vz3FB3X1y26b+s0slJG4Vrb0V0iA 37v+v72fqBLczS2bn+JwiYZH5l2oA4Q4w6oY3gDWxnZ/dis9cH41rc1ygu07I8i9ZdaXvW VQS2ONWlAf6NBKBzMvxKOl2F1AEg6SRP3EXrMNoMPsgIeh+phA63xYerC1AzLvptiOxs3e jCisz8Mcz595z2zfzQP4qkn8F9ZlbeccUM9r5Tl8DCOQQQ0zY8qgMhiYD8B0TA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=51f798e761b1b30fc2432cce4295271c0689bd1f commit 51f798e761b1b30fc2432cce4295271c0689bd1f Author: Gleb Smirnoff AuthorDate: 2022-01-27 05:58:50 +0000 Commit: Ed Maste CommitDate: 2022-05-05 18:38:07 +0000 netisr: serialize/restore m_pkthdr.rcvif when queueing mbufs Reviewed by: kp Differential revision: https://reviews.freebsd.org/D33268 (cherry picked from commit 6871de9363e559fef6765f0e49acc47f77544999) --- sys/net/netisr.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/sys/net/netisr.c b/sys/net/netisr.c index e4abea317440..4d0bce3bedfc 100644 --- a/sys/net/netisr.c +++ b/sys/net/netisr.c @@ -700,9 +700,11 @@ netisr_register_vnet(const struct netisr_handler *nhp) static void netisr_drain_proto_vnet(struct vnet *vnet, u_int proto) { + struct epoch_tracker et; struct netisr_workstream *nwsp; struct netisr_work *npwp; struct mbuf *m, *mp, *n, *ne; + struct ifnet *ifp; u_int i; KASSERT(vnet != NULL, ("%s: vnet is NULL", __func__)); @@ -723,11 +725,14 @@ netisr_drain_proto_vnet(struct vnet *vnet, u_int proto) */ m = npwp->nw_head; n = ne = NULL; + NET_EPOCH_ENTER(et); while (m != NULL) { mp = m; m = m->m_nextpkt; mp->m_nextpkt = NULL; - if (mp->m_pkthdr.rcvif->if_vnet != vnet) { + if ((ifp = ifnet_byindexgen(mp->m_pkthdr.rcvidx, + mp->m_pkthdr.rcvgen)) != NULL && + ifp->if_vnet != vnet) { if (n == NULL) { n = ne = mp; } else { @@ -736,10 +741,12 @@ netisr_drain_proto_vnet(struct vnet *vnet, u_int proto) } continue; } - /* This is a packet in the selected vnet. Free it. */ + /* This is a packet in the selected vnet, or belongs + to destroyed interface. Free it. */ npwp->nw_len--; m_freem(mp); } + NET_EPOCH_EXIT(et); npwp->nw_head = n; npwp->nw_tail = ne; NWS_UNLOCK(nwsp); @@ -913,8 +920,10 @@ netisr_process_workstream_proto(struct netisr_workstream *nwsp, u_int proto) if (local_npw.nw_head == NULL) local_npw.nw_tail = NULL; local_npw.nw_len--; - VNET_ASSERT(m->m_pkthdr.rcvif != NULL, - ("%s:%d rcvif == NULL: m=%p", __func__, __LINE__, m)); + if (__predict_false(m_rcvif_restore(m) == NULL)) { + m_freem(m); + continue; + } CURVNET_SET(m->m_pkthdr.rcvif->if_vnet); netisr_proto[proto].np_handler(m); CURVNET_RESTORE(); @@ -986,6 +995,7 @@ netisr_queue_workstream(struct netisr_workstream *nwsp, u_int proto, *dosignalp = 0; if (npwp->nw_len < npwp->nw_qlimit) { + m_rcvif_serialize(m); m->m_nextpkt = NULL; if (npwp->nw_head == NULL) { npwp->nw_head = m;