Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 12 Jul 2024 11:25:00 GMT
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 1b1cd327d905 - main - setkey(8): print out SA sw/hw offload counters
Message-ID:  <202407121125.46CBP0Tw092770@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=1b1cd327d905fab5920e7af2582d15d48ad26999

commit 1b1cd327d905fab5920e7af2582d15d48ad26999
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2023-06-03 22:56:19 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2024-07-12 03:29:31 +0000

    setkey(8): print out SA sw/hw offload counters
    
    Sponsored by:   NVIDIA networking
---
 lib/libipsec/pfkey.c      |  2 ++
 lib/libipsec/pfkey_dump.c | 23 ++++++++++++++++++++---
 2 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/lib/libipsec/pfkey.c b/lib/libipsec/pfkey.c
index 31464d063241..2308dd3281a7 100644
--- a/lib/libipsec/pfkey.c
+++ b/lib/libipsec/pfkey.c
@@ -1713,6 +1713,8 @@ pfkey_align(struct sadb_msg *msg, caddr_t *mhp)
 		case SADB_X_EXT_SA_REPLAY:
 		case SADB_X_EXT_NEW_ADDRESS_SRC:
 		case SADB_X_EXT_NEW_ADDRESS_DST:
+		case SADB_X_EXT_LFT_CUR_SW_OFFL:
+		case SADB_X_EXT_LFT_CUR_HW_OFFL:
 			mhp[ext->sadb_ext_type] = (caddr_t)ext;
 			break;
 		default:
diff --git a/lib/libipsec/pfkey_dump.c b/lib/libipsec/pfkey_dump.c
index cd5961822751..2e69277fe6c2 100644
--- a/lib/libipsec/pfkey_dump.c
+++ b/lib/libipsec/pfkey_dump.c
@@ -201,7 +201,7 @@ pfkey_sadump(struct sadb_msg *m)
 	caddr_t mhp[SADB_EXT_MAX + 1];
 	struct sadb_sa *m_sa;
 	struct sadb_x_sa2 *m_sa2;
-	struct sadb_lifetime *m_lftc, *m_lfth, *m_lfts;
+	struct sadb_lifetime *m_lftc, *m_lfth, *m_lfts, *m_lft_sw, *m_lft_hw;
 	struct sadb_address *m_saddr, *m_daddr, *m_paddr;
 	struct sadb_key *m_auth, *m_enc;
 	struct sadb_ident *m_sid, *m_did;
@@ -240,7 +240,8 @@ pfkey_sadump(struct sadb_msg *m)
 	natt_dport = (struct sadb_x_nat_t_port *)mhp[SADB_X_EXT_NAT_T_DPORT];
 	natt_oai = (struct sadb_address *)mhp[SADB_X_EXT_NAT_T_OAI];
 	natt_oar = (struct sadb_address *)mhp[SADB_X_EXT_NAT_T_OAR];
-
+	m_lft_sw = (struct sadb_lifetime *)mhp[SADB_X_EXT_LFT_CUR_SW_OFFL];
+	m_lft_hw = (struct sadb_lifetime *)mhp[SADB_X_EXT_LFT_CUR_HW_OFFL];
 
 	/* source address */
 	if (m_saddr == NULL) {
@@ -381,7 +382,23 @@ pfkey_sadump(struct sadb_msg *m)
 	/* XXX DEBUG */
 	printf("refcnt=%u\n", m->sadb_msg_reserved);
 
-	return;
+	if (m_lft_sw != NULL) {
+		printf("\tsw offl use: %s",
+		    str_time(m_lft_sw->sadb_lifetime_usetime));
+		printf("\tsw offl allocated: %lu",
+		    (unsigned long)m_lft_sw->sadb_lifetime_allocations);
+		str_lifetime_byte(m_lft_sw, "sw offl");
+		printf("\n");
+	}
+
+	if (m_lft_hw != NULL) {
+		printf("\thw offl use: %s",
+		    str_time(m_lft_hw->sadb_lifetime_usetime));
+		printf("\thw offl allocated: %lu",
+		    (unsigned long)m_lft_hw->sadb_lifetime_allocations);
+		str_lifetime_byte(m_lft_hw, "hw offl");
+		printf("\n");
+	}
 }
 
 void



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202407121125.46CBP0Tw092770>