From nobody Sat Dec 31 12:29:21 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 4NkhJf275gz2nMNm; Sat, 31 Dec 2022 12:29:22 +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 4NkhJd6SCZz4L0Y; Sat, 31 Dec 2022 12:29:21 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1672489761; 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=53IKmE+34pYyG5cyf5GcMZTNAXPP8bNXBgxHH500Qtc=; b=VrqUwQeWLNA5JjA3ZDF1JLjWP5ychk8H8pViIbvhzGB13/9+7s+IRyl26cUKEMDWR6J3oX fdjHi+/+JAYT9kLfay3DwSkLQb70P84TnvqgtIqP2vsDjY9qJV76HaAbCGViTX+aZbkgXQ DS7qWuyzcUuAmBmaZvairHKCqyRvLtttTanbdz6cIHt450leV86f8OFWnN1DuCbpQMgjXe R73J9TbNadsfgoMxAuJP0ncHPdmcXFojY7eNxug5VcG16S96V30OWaZLLd2C9NPFHeqHD8 MGyMEQOFsqQ69VXYd9x/PjfBiBqCfAplQCnoiJIN80Zd13Vx7yKtA36WiSfu5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1672489761; 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=53IKmE+34pYyG5cyf5GcMZTNAXPP8bNXBgxHH500Qtc=; b=BbhGT5DllRBqmTd8387lSIhFD3Vq6VG8nJP91b7/cw77se/xf2/+JPnjvY6fA6NcYK6tmv zywyU7m/vWjwBeVf2vGicT7/ILGdL30srQt7lq4p3gItZXhmppv6aiygSOWr7XlG3QZWtA OZjJzyFjIPsTFBZKkHobHco5iBjCCZIwdjR48Xdf8vV0on9gDSwcmhmJq8HvuMHM5eNgrS SKWSJKcGdGceIVqb4gEkUyAit7OkmZVoxgocpzKeFWSVGGFf71i3cIUX8pjFTsq528AI27 MPQCaVxqlj1fSL+xk7Q35DjRDlbpYqdFi+e/iwtEVTHSyUm30vZhYthvmA4iKw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1672489761; a=rsa-sha256; cv=none; b=LQoidZDRDhM4bXmIYTe865dsowgZ4GD46mRlfmaDDbLqrAWHgLJJn+Qm6DCA4vHOr4UCsn x9wnIDPmzN5Rb6X2UzEB7qVi7G75gkxTgepZ6nDBOmZnCEAIb5/Yqi7FRHaV3Go6wbDzg3 aFRehJ4VDL5jJ8K0IMg2m6qQgFt0pDnBV6262KcR5Kj1vDLZA8W6ezHknCDMqbBRfuXFcd dZCZqi1qiWsk142TksaR6ijS2j0Fo3Lds1lwuw21dFr869HGg4VkOYC4omeLd8zMBddAEi bbrDSDNwvC2BQL1ezZSvwxhUNojmWLd03r04FegVh1MBGcTIzgADVMs/QsDHvQ== 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 4NkhJd5Z2fznlg; Sat, 31 Dec 2022 12:29:21 +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 2BVCTLSW070129; Sat, 31 Dec 2022 12:29:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2BVCTLq5070128; Sat, 31 Dec 2022 12:29:21 GMT (envelope-from git) Date: Sat, 31 Dec 2022 12:29:21 GMT Message-Id: <202212311229.2BVCTLq5070128@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Vincenzo Maffione Subject: git: 87c145309ecd - stable/12 - netmap: monitor: add a flag to distinguish packet direction 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: vmaffione X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 87c145309ecd275255935dad0ef694177a46ff90 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by vmaffione: URL: https://cgit.FreeBSD.org/src/commit/?id=87c145309ecd275255935dad0ef694177a46ff90 commit 87c145309ecd275255935dad0ef694177a46ff90 Author: Vincenzo Maffione AuthorDate: 2021-03-29 16:32:54 +0000 Commit: Vincenzo Maffione CommitDate: 2022-12-31 12:24:22 +0000 netmap: monitor: add a flag to distinguish packet direction The netmap monitor intercepts any TX/RX packets on the monitored port. However, before this change there was no way to tell whether an intercepted packet was being transmitted or received on the monitored port. A TXMON flag in the netmap slot has been added for this purpose. (cherry picked from commit 660a47cb991d5a7ca69cd8dd9c09a5288d49e405) --- sys/dev/netmap/netmap_monitor.c | 8 ++++++-- sys/net/netmap.h | 5 +++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/sys/dev/netmap/netmap_monitor.c b/sys/dev/netmap/netmap_monitor.c index ad7274b075af..967288c3bb29 100644 --- a/sys/dev/netmap/netmap_monitor.c +++ b/sys/dev/netmap/netmap_monitor.c @@ -38,6 +38,8 @@ * the traffic transiting on both the tx and rx corresponding rings in the * monitored adapter. During registration, the user can choose if she wants * to intercept tx only, rx only, or both tx and rx traffic. + * The slots containing traffic intercepted in the tx direction will have + * the NS_TXMON flag set. * * If the monitor is not able to cope with the stream of frames, excess traffic * will be dropped. @@ -592,6 +594,7 @@ netmap_zmon_parent_sync(struct netmap_kring *kring, int flags, enum txrx tx) u_int beg, end, i; u_int lim = kring->nkr_num_slots - 1, mlim; // = mkring->nkr_num_slots - 1; + uint16_t txmon = kring->tx == NR_TX ? NS_TXMON : 0; if (mkring == NULL) { nm_prlim(5, "NULL monitor on %s", kring->name); @@ -661,7 +664,7 @@ netmap_zmon_parent_sync(struct netmap_kring *kring, int flags, enum txrx tx) ms->len = s->len; s->len = tmp; - ms->flags = s->flags; + ms->flags = (s->flags & ~NS_TXMON) | txmon; s->flags |= NS_BUF_CHANGED; beg = nm_next(beg, lim); @@ -728,6 +731,7 @@ static void netmap_monitor_parent_sync(struct netmap_kring *kring, u_int first_new, int new_slots) { u_int j; + uint16_t txmon = kring->tx == NR_TX ? NS_TXMON : 0; for (j = 0; j < kring->n_monitors; j++) { struct netmap_kring *mkring = kring->monitors[j]; @@ -779,7 +783,7 @@ netmap_monitor_parent_sync(struct netmap_kring *kring, u_int first_new, int new_ memcpy(dst, src, copy_len); ms->len = copy_len; - ms->flags = s->flags; + ms->flags = (s->flags & ~NS_TXMON) | txmon; sent++; beg = nm_next(beg, lim); diff --git a/sys/net/netmap.h b/sys/net/netmap.h index c1132d02cfaa..b93a5674230e 100644 --- a/sys/net/netmap.h +++ b/sys/net/netmap.h @@ -219,6 +219,11 @@ struct netmap_slot { * The 'len' field refers to the individual fragment. */ +#define NS_TXMON 0x0040 + /* (monitor ports only) the packet comes from the TX + * ring of the monitored port + */ + #define NS_PORT_SHIFT 8 #define NS_PORT_MASK (0xff << NS_PORT_SHIFT) /*