From owner-dev-commits-src-all@freebsd.org Sat Jan 9 21:02:06 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id DC2164E2D69; Sat, 9 Jan 2021 21:02:06 +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 "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DCsq25xWjz4Vls; Sat, 9 Jan 2021 21:02:06 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 BF0841C47B; Sat, 9 Jan 2021 21:02:06 +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 109L26HQ017632; Sat, 9 Jan 2021 21:02:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 109L26Fu017631; Sat, 9 Jan 2021 21:02:06 GMT (envelope-from git) Date: Sat, 9 Jan 2021 21:02:06 GMT Message-Id: <202101092102.109L26Fu017631@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Vincenzo Maffione Subject: git: 1d238b07d5d4 - main - netmap: iflib: stop krings during interface reset MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: vmaffione X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 1d238b07d5d4d9660ae0e08daede6da7e91c7853 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Jan 2021 21:02:06 -0000 The branch main has been updated by vmaffione: URL: https://cgit.FreeBSD.org/src/commit/?id=1d238b07d5d4d9660ae0e08daede6da7e91c7853 commit 1d238b07d5d4d9660ae0e08daede6da7e91c7853 Author: Vincenzo Maffione AuthorDate: 2021-01-09 20:54:11 +0000 Commit: Vincenzo Maffione CommitDate: 2021-01-09 21:01:46 +0000 netmap: iflib: stop krings during interface reset When different processes open separate subsets of the available rings of a same netmap interface, a device reset may be performed while one of the processes is actively using some rings (e.g., caused by another process executing a nmport_open()). With this patch, such situation will cause the active process to get a POLLERR, so that it can have a chance to detect the situation. We also guarantee that no process is running a txsync or rxsync (ioctl or poll) while an iflib device reset is in progress. PR: 252453 MFC after: 1 week --- sys/dev/netmap/netmap.c | 2 +- sys/net/iflib.c | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/sys/dev/netmap/netmap.c b/sys/dev/netmap/netmap.c index d2c0f8f1c5c4..aa3bb1843ba5 100644 --- a/sys/dev/netmap/netmap.c +++ b/sys/dev/netmap/netmap.c @@ -4236,7 +4236,7 @@ nm_set_native_flags(struct netmap_adapter *na) struct ifnet *ifp = na->ifp; /* We do the setup for intercepting packets only if we are the - * first user of this adapapter. */ + * first user of this adapter. */ if (na->active_fds > 0) { return; } diff --git a/sys/net/iflib.c b/sys/net/iflib.c index cc401a5db24d..1b86fd670ac4 100644 --- a/sys/net/iflib.c +++ b/sys/net/iflib.c @@ -809,6 +809,13 @@ iflib_netmap_register(struct netmap_adapter *na, int onoff) if (!CTX_IS_VF(ctx)) IFDI_CRCSTRIP_SET(ctx, onoff, iflib_crcstrip); + /* + * Stop any pending txsync/rxsync and prevent new ones + * form starting. Processes blocked in poll() will get + * POLLERR. + */ + netmap_disable_all_rings(ifp); + iflib_stop(ctx); /* @@ -828,6 +835,8 @@ iflib_netmap_register(struct netmap_adapter *na, int onoff) if (status) nm_clear_native_flags(na); CTX_UNLOCK(ctx); + /* Re-enable txsync/rxsync. */ + netmap_enable_all_rings(ifp); return (status); }