From patchwork Wed Sep 4 00:34:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hangbin Liu X-Patchwork-Id: 13789523 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-oa1-f52.google.com (mail-oa1-f52.google.com [209.85.160.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9D280391 for ; Wed, 4 Sep 2024 00:35:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725410113; cv=none; b=ksTCJE4cxCUyedZS2NwMA4AeGGOhpne+8Nk/cleKWUZXnlWQZfST9XPAAR34SJptSDl7C+cYESyvPcnUd9SJcs4WdLIULbMubY+0E4Il6yc93WkAlz0AZHR9Mj1F/dBmGuYW9Hv61TE9F2UExGaVMHKuo/mcQYXrYtLRRORPT84= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725410113; c=relaxed/simple; bh=nH9cie4EipFRr9xRf7dHReaZsoy6tTleh5bMiQVIWvA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=t/aNyNwPHmbp2snFr38t5TB8F+HVFIaFeGgFTUhJ9MmrUzu7zuV09tI/2PA/0hWQzlg7iRAOqojIasxTU21abK0ToabMthr3JvNBdSk1BVBMuwGQjPGx5ClLQtowPKJEvpUdPIjT+SiAwIb5ZjOzC69jKD2VrEixuNyL/ZYtMAQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Qz8qNlx5; arc=none smtp.client-ip=209.85.160.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Qz8qNlx5" Received: by mail-oa1-f52.google.com with SMTP id 586e51a60fabf-27806115eafso109802fac.3 for ; Tue, 03 Sep 2024 17:35:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725410110; x=1726014910; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=sRYpxeP62juRhoXXN4rMqIUv1DTtYurPPQTT9nnc0mU=; b=Qz8qNlx5WdMXY9zC2Pgs/2Krg4tBjcgHFpVNuFWfLZGkTsWdYN5umNY0mnU7b2An/n zdObiXEury1ffWxKjHGPKlBB0S9TujYaLgbhd9w3cb9FlFePv3/UreHIaNEP795GR/yd JyBPAen7wP71cxPJwtPGcoOB4+xLFh6Sr1AuH4ckrOIn5SpyyTID1NoLBaiwBZdDHjYw DUE8CGBq5cqzHTFniHNwC5TI9jdZ1OsEQNyIvzfjEBKRXFAYraFZcbMMdD449/pwXnwu VLk2x5VKRLSp5LZK9+vmpnXEIhQ1TRRnTCc856BF3PKQ52g/ixasocnp5JZ+x8EJtboy r1Pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725410110; x=1726014910; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sRYpxeP62juRhoXXN4rMqIUv1DTtYurPPQTT9nnc0mU=; b=nyUXEHSd6ql7nf6qZaINHagZrgL0WxID+7UWpBzAlNtFqTiuC83MHCENh6Xbeh/uDT ueZpMcrszGx6LLEJ4iE/AwfRSf5x2ZhyKW+NmOZvso4GyCfRNtDnjDKx5EV0wLfgfMia ezjggBiSX7B5uld22nEwdmfW/Mu8sPOXOk/dPn+IhOSp3K4iqSjpUn9/XHzcMe1MAvKR dCszTtmEOOadvQZbboeB1H4zqBLVpM/2huD1plUwtdeC8BGXZz2BhDMJ226teiYpYE+H +6/00s4ITpTR4+VtWLDguuV/VYlWa7t92A9tiLqhWj+fHFhfY4+7TljoZPna34omf/E4 9tXg== X-Gm-Message-State: AOJu0YyS/EU6PBmR/sRuBm+LKRjrsaCdyUhLA6lL/M3ofqeBrUZsVu8O 0CZHHzjh9BUWKeNBqOhiF0f3aZWxbQUOM33Wh70B8QlGQ7xekb9Jm7qsFGfFVmXSfQ== X-Google-Smtp-Source: AGHT+IHrWS0YJuQs8JtjAoruHphpJbMPa4JSx65jYPTxS8ZkdXS9EyF3I63La/GW1y3NsF4NAZcZbw== X-Received: by 2002:a05:6871:79a6:b0:25e:fb:af8c with SMTP id 586e51a60fabf-277900edeb3mr20312878fac.18.1725410109969; Tue, 03 Sep 2024 17:35:09 -0700 (PDT) Received: from Laptop-X1.redhat.com ([43.228.180.230]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71778589133sm444218b3a.109.2024.09.03.17.35.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2024 17:35:09 -0700 (PDT) From: Hangbin Liu To: netdev@vger.kernel.org Cc: Jay Vosburgh , Andy Gospodarek , "David S . Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet , Nikolay Aleksandrov , Tariq Toukan , Jianbo Liu , Sabrina Dubroca , Simon Horman , Steffen Klassert , Hangbin Liu , Jay Vosburgh Subject: [PATCHv7 net-next 1/3] bonding: add common function to check ipsec device Date: Wed, 4 Sep 2024 08:34:55 +0800 Message-ID: <20240904003457.3847086-2-liuhangbin@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240904003457.3847086-1-liuhangbin@gmail.com> References: <20240904003457.3847086-1-liuhangbin@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org This patch adds a common function to check the status of IPSec devices. This function will be useful for future implementations, such as IPSec ESN and state offload callbacks. Suggested-by: Nikolay Aleksandrov Reviewed-by: Nikolay Aleksandrov Acked-by: Jay Vosburgh Signed-off-by: Hangbin Liu --- drivers/net/bonding/bond_main.c | 50 ++++++++++++++++++++++++--------- 1 file changed, 37 insertions(+), 13 deletions(-) diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index f13d413ad26c..46f46fea9152 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -418,6 +418,41 @@ static int bond_vlan_rx_kill_vid(struct net_device *bond_dev, /*---------------------------------- XFRM -----------------------------------*/ #ifdef CONFIG_XFRM_OFFLOAD +/** + * bond_ipsec_dev - Get active device for IPsec offload + * @xs: pointer to transformer state struct + * + * Context: caller must hold rcu_read_lock. + * + * Return: the device for ipsec offload, or NULL if not exist. + **/ +static struct net_device *bond_ipsec_dev(struct xfrm_state *xs) +{ + struct net_device *bond_dev = xs->xso.dev; + struct bonding *bond; + struct slave *slave; + + if (!bond_dev) + return NULL; + + bond = netdev_priv(bond_dev); + if (BOND_MODE(bond) != BOND_MODE_ACTIVEBACKUP) + return NULL; + + slave = rcu_dereference(bond->curr_active_slave); + if (!slave) + return NULL; + + if (!xs->xso.real_dev) + return NULL; + + if (xs->xso.real_dev != slave->dev) + pr_warn_ratelimited("%s: (slave %s): not same with IPsec offload real dev %s\n", + bond_dev->name, slave->dev->name, xs->xso.real_dev->name); + + return slave->dev; +} + /** * bond_ipsec_add_sa - program device with a security association * @xs: pointer to transformer state struct @@ -640,23 +675,12 @@ static void bond_ipsec_free_sa(struct xfrm_state *xs) **/ static bool bond_ipsec_offload_ok(struct sk_buff *skb, struct xfrm_state *xs) { - struct net_device *bond_dev = xs->xso.dev; struct net_device *real_dev; - struct slave *curr_active; - struct bonding *bond; bool ok = false; - bond = netdev_priv(bond_dev); rcu_read_lock(); - curr_active = rcu_dereference(bond->curr_active_slave); - if (!curr_active) - goto out; - real_dev = curr_active->dev; - - if (BOND_MODE(bond) != BOND_MODE_ACTIVEBACKUP) - goto out; - - if (!xs->xso.real_dev) + real_dev = bond_ipsec_dev(xs); + if (!real_dev) goto out; if (!real_dev->xfrmdev_ops || From patchwork Wed Sep 4 00:34:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hangbin Liu X-Patchwork-Id: 13789524 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-oo1-f43.google.com (mail-oo1-f43.google.com [209.85.161.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 955D6646 for ; Wed, 4 Sep 2024 00:35:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725410118; cv=none; b=CVcpJauRPtqd08ErV+qHvtX9gbaFvci8ED51+/mXQyup+WpiKJN1oAbkI2gY3gVnu8TMiZHnhUYfQDuw9Hp7w0z47DhLqo4uhXHPRobB/21s2cbRKsHyQmhnyw3qnQZ5CHT8SIznNzFDGSxlV4xHhDjwd++8bjJa4f3GMaa8h50= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725410118; c=relaxed/simple; bh=Ilk/r3EqQMJreOmj91JPQuwrxQIJ/C1rFi8Z1C5hXug=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Trbvm7SlxwNr0dKSYPBgp2AL6EgYiyltB+MqRPvj4GProgr297bfoh8aNSbrVF3fGX0rL1OxkAB/IqjuMMk6J04E7Uey9czFtpvHU5I7WwwkFoLJtTXxu6mk6lpItsFkd0GPOK8WGDeS7tkp+j3l0DHmXlQDkzvWcUyZzk64yMg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Pj6+Qr4a; arc=none smtp.client-ip=209.85.161.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Pj6+Qr4a" Received: by mail-oo1-f43.google.com with SMTP id 006d021491bc7-5dca9cc71b2so175844eaf.2 for ; Tue, 03 Sep 2024 17:35:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725410115; x=1726014915; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=YP+kyHfxNs79ILywdhtEjvX/1fKjka7Zb78lPonahLs=; b=Pj6+Qr4an4ceHaYg+nYI5cO9M6JinM4AGrhEvjDNESN27OTQFN/Fm3CgCBndO6AUfb G4fP+bczFARCe99+kZleviM/6AATulk3EI6AW8NmY9odyB6XcYPKdV40VUfLhCxKSq3F TKEfHxlBHikuktURaGsM93s7ivEtBGrNAKr6uLrB19tsGgP5pk/QKaGRlPouzu+lGTUU HqUC6QAsa4eGmFarGFl5sOlskrc9a6dnctRN1PDnqVLYsHbX+TXF993cNB38avxfMRFX wUe3hQiYAbLWaLvH7XzWkecFG45bXcbBs5wORtgN3yUILYsqk4ZdlTO697I0Cz4ZYTcy Yn8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725410115; x=1726014915; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YP+kyHfxNs79ILywdhtEjvX/1fKjka7Zb78lPonahLs=; b=XPSRdo78UzbL0yWhttqam4+uDz847bn13QqEup1L2AxkpjYh8OL4DbZLdiJgS0hQb4 XYRCQXDMicqUaRrYkWlKs0PmQu0bIsbv08vPHNxwdOngCjY796ohn8ejsqSDdWBjoDqA N19bl+KQIBDj740FU1Jzg2O4RtMCxy6SNDXfWV56/PStqeAElP/Xvp6bkjYl1hG292bk RoW161ugV57hcwSfdnStsvEJJ2iQsMiIu/jtH+PSqWariTXH4xplAoHSIugHYlZ2+Kru gGEJIF+6/L/N+/e3eHDH0pEm0NZGUNqzhR3XmlfY6FaNGnm+dU4WfbTiOQwX9YMm1y4n Nz4g== X-Gm-Message-State: AOJu0YzV9NX+87cgxpCGMM5pKQa2rQ850ttjdw2xg7zEIsQw33ZKUIv5 sNwMntNm7lXIV2SJ+IkEoPqxk67Dw8CZ7YBrHL8UPfIU6lk75d78awhokeoJ04P/3Q== X-Google-Smtp-Source: AGHT+IFNn2EceYt6pq6dnoO3LsKl/54/jki6skUFoG4ewHvjc22dQFTBWIXXcxEoFN+YivIL4A4mPQ== X-Received: by 2002:a05:6870:961d:b0:278:2316:8422 with SMTP id 586e51a60fabf-2782316dc23mr3645919fac.27.1725410115267; Tue, 03 Sep 2024 17:35:15 -0700 (PDT) Received: from Laptop-X1.redhat.com ([43.228.180.230]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71778589133sm444218b3a.109.2024.09.03.17.35.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2024 17:35:14 -0700 (PDT) From: Hangbin Liu To: netdev@vger.kernel.org Cc: Jay Vosburgh , Andy Gospodarek , "David S . Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet , Nikolay Aleksandrov , Tariq Toukan , Jianbo Liu , Sabrina Dubroca , Simon Horman , Steffen Klassert , Hangbin Liu , Jay Vosburgh Subject: [PATCHv7 net-next 2/3] bonding: Add ESN support to IPSec HW offload Date: Wed, 4 Sep 2024 08:34:56 +0800 Message-ID: <20240904003457.3847086-3-liuhangbin@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240904003457.3847086-1-liuhangbin@gmail.com> References: <20240904003457.3847086-1-liuhangbin@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Currently, users can see that bonding supports IPSec HW offload via ethtool. However, this functionality does not work with NICs like Mellanox cards when ESN (Extended Sequence Numbers) is enabled, as ESN functions are not yet supported. This patch adds ESN support to the bonding IPSec device offload, ensuring proper functionality with NICs that support ESN. Reviewed-by: Nikolay Aleksandrov Acked-by: Jay Vosburgh Signed-off-by: Hangbin Liu --- drivers/net/bonding/bond_main.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 46f46fea9152..a6628b1f33a7 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -694,11 +694,36 @@ static bool bond_ipsec_offload_ok(struct sk_buff *skb, struct xfrm_state *xs) return ok; } +/** + * bond_advance_esn_state - ESN support for IPSec HW offload + * @xs: pointer to transformer state struct + **/ +static void bond_advance_esn_state(struct xfrm_state *xs) +{ + struct net_device *real_dev; + + rcu_read_lock(); + real_dev = bond_ipsec_dev(xs); + if (!real_dev) + goto out; + + if (!real_dev->xfrmdev_ops || + !real_dev->xfrmdev_ops->xdo_dev_state_advance_esn) { + pr_warn_ratelimited("%s: %s doesn't support xdo_dev_state_advance_esn\n", __func__, real_dev->name); + goto out; + } + + real_dev->xfrmdev_ops->xdo_dev_state_advance_esn(xs); +out: + rcu_read_unlock(); +} + static const struct xfrmdev_ops bond_xfrmdev_ops = { .xdo_dev_state_add = bond_ipsec_add_sa, .xdo_dev_state_delete = bond_ipsec_del_sa, .xdo_dev_state_free = bond_ipsec_free_sa, .xdo_dev_offload_ok = bond_ipsec_offload_ok, + .xdo_dev_state_advance_esn = bond_advance_esn_state, }; #endif /* CONFIG_XFRM_OFFLOAD */ From patchwork Wed Sep 4 00:34:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hangbin Liu X-Patchwork-Id: 13789525 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-oo1-f48.google.com (mail-oo1-f48.google.com [209.85.161.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C77B8804 for ; Wed, 4 Sep 2024 00:35:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725410123; cv=none; b=Z20sItP5oSdxhTNzbIl9DEMNWjr114Dbm10ZC7tjviz9ufE9tZNgDRvJgXkHtllmYyrYbrJ2nzTmvye5ngu3h6LGowZlCTNDj+ZtEjAhZob0NJtbetFG32LOuf1LxI/TVZYKW1b5U2M6dYlshbR3NoSteQtdusX6aCanQcbU1dY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725410123; c=relaxed/simple; bh=i/d40otUL9KwuiJ93P+2ZTlijq0lv1Unw/Tv+U8sYtc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DsWipeEIESesZYxUmAz8lxnH9shMA/Yg45D8sc2oEkQrqGG6icCF+Ml82nLW0grgtpddS4YrNozxQmv7UPACach5QFxTyvyrLlMzD3OZSgtyHnLKl9zMm41d3yxg7wSyLtDmpUoQvgw6yo4dcJtYDiIbfTS2lC1oQA/j1z9aT1E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=DkXSh5/n; arc=none smtp.client-ip=209.85.161.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DkXSh5/n" Received: by mail-oo1-f48.google.com with SMTP id 006d021491bc7-5e172cc6d66so1435161eaf.2 for ; Tue, 03 Sep 2024 17:35:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725410120; x=1726014920; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=tXpwzSuczk2LKlfBSBX+16h6YaFfQEhasngzGrGdCag=; b=DkXSh5/n81a5V9SOg0COwm2UR3DVt3ilA9Sl9flzNs0FGzrAPakCNL/LIf65+RKGnR RQa2FOZXpM5w4DJBN1Qu08tN/Va0qCDm2QgoJBR+hF5LcLvBq6SZVzakDAPhwkNKKzOd uFEfEDTCoEnmctdlmUZjLygg9wSjOfkfHEz65JmfA0WR4xoHSfDHsLVF/XaaAjv1cI0X kEWRjpVbV3GBvbsyV4kw9mdWv8xRXTgpY4BQPscP0PbSO0i00jp7SZ45dcCr4Yg9RoYW YzSKJ1T4GHQAeJWpKTV+nFybsPFQBPcEvSDakYw7gqYI1srxXv2zapvq+yT+te/Tk6ll uN1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725410120; x=1726014920; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tXpwzSuczk2LKlfBSBX+16h6YaFfQEhasngzGrGdCag=; b=PT9gdjzjrcmaG+Gr+Vidk2qi9Zr3xyppiMFa5dHRRayHbYba50Lj1cmbtKi3gDWHv2 JO+dHwyU+IsEAYxFdu7F34GhEoQw2SpqJivzMNpMP5bqUmv6CkC2Ghgx4//DfTnC0jsM off4lEHHYuZGHmD+tzXHOIkMvIvZTIycr/RTkvdUZOsNYohEvxfnnjw7L8+4VjFASpkM axlllwCBLXfJ4JEa04+mE//lHysA/sYIqp/+gstKdaRu0l2FKdrC7Q4pMMHIAyDPBIWJ ZhZxj83y2YnZZZMcb5VzlCHpsTt/iGF/7siMIl0cWhZ/T5D9Sv/x4NSHJ7Ez1KVxzX23 Qn5Q== X-Gm-Message-State: AOJu0YxUHLO3/dPxVNIsK7I8O1oXkBjrn5kKEttMSpTWFJWSnOKP63nz 54oItz0UQd6KdDqXQetA/NDu06yf4puIRlWwUQ/wGyFZkJEC4f95btmlUQTYQeG4HQ== X-Google-Smtp-Source: AGHT+IHj2uEKKPbJ00Pvx+7wLRAtKRIM1omnqzkkhvqh5Y7Ph+MXI4EBmuZAw/hBSGcICdWeUu85LA== X-Received: by 2002:a05:6871:3a09:b0:25e:1edb:5bcf with SMTP id 586e51a60fabf-2781a75e938mr4889775fac.6.1725410120248; Tue, 03 Sep 2024 17:35:20 -0700 (PDT) Received: from Laptop-X1.redhat.com ([43.228.180.230]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71778589133sm444218b3a.109.2024.09.03.17.35.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2024 17:35:20 -0700 (PDT) From: Hangbin Liu To: netdev@vger.kernel.org Cc: Jay Vosburgh , Andy Gospodarek , "David S . Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet , Nikolay Aleksandrov , Tariq Toukan , Jianbo Liu , Sabrina Dubroca , Simon Horman , Steffen Klassert , Hangbin Liu , Jay Vosburgh Subject: [PATCHv7 net-next 3/3] bonding: support xfrm state update Date: Wed, 4 Sep 2024 08:34:57 +0800 Message-ID: <20240904003457.3847086-4-liuhangbin@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240904003457.3847086-1-liuhangbin@gmail.com> References: <20240904003457.3847086-1-liuhangbin@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org The patch add xfrm statistics update for bonding IPsec offload. Reviewed-by: Nikolay Aleksandrov Acked-by: Jay Vosburgh Signed-off-by: Hangbin Liu --- drivers/net/bonding/bond_main.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index a6628b1f33a7..47ab4ccd6fc1 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -718,12 +718,37 @@ static void bond_advance_esn_state(struct xfrm_state *xs) rcu_read_unlock(); } +/** + * bond_xfrm_update_stats - Update xfrm state + * @xs: pointer to transformer state struct + **/ +static void bond_xfrm_update_stats(struct xfrm_state *xs) +{ + struct net_device *real_dev; + + rcu_read_lock(); + real_dev = bond_ipsec_dev(xs); + if (!real_dev) + goto out; + + if (!real_dev->xfrmdev_ops || + !real_dev->xfrmdev_ops->xdo_dev_state_update_stats) { + pr_warn_ratelimited("%s: %s doesn't support xdo_dev_state_update_stats\n", __func__, real_dev->name); + goto out; + } + + real_dev->xfrmdev_ops->xdo_dev_state_update_stats(xs); +out: + rcu_read_unlock(); +} + static const struct xfrmdev_ops bond_xfrmdev_ops = { .xdo_dev_state_add = bond_ipsec_add_sa, .xdo_dev_state_delete = bond_ipsec_del_sa, .xdo_dev_state_free = bond_ipsec_free_sa, .xdo_dev_offload_ok = bond_ipsec_offload_ok, .xdo_dev_state_advance_esn = bond_advance_esn_state, + .xdo_dev_state_update_stats = bond_xfrm_update_stats, }; #endif /* CONFIG_XFRM_OFFLOAD */