From patchwork Mon Aug 19 07:53:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hangbin Liu X-Patchwork-Id: 13768036 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) (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 CD46415A87F for ; Mon, 19 Aug 2024 07:53:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724054033; cv=none; b=jY/H/0gRTfzQH1Ujkg7c7NVaJwEnWmRsH90YuI8EdPH8j6q72mogxjbte5RPNMr8WFPfmXHTA2cFObeKuV9JBndHVqPT4PjM7zLzZqadyOL9Rv9baxmybSI/CzW1Xom0ocSPUn2lTfV5/vwg006abKqRwD7hmrP4n9gxOfkSygA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724054033; c=relaxed/simple; bh=H6sez1XWIvu+zlzMFh3M5fFdumBUiPWe/sLQkHhvYHg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uGuTzuYbi1vnHHoGQKus90DPc9KoIwoWxiE2DXRge7L0zsT8TCuCi8qqL7bUWtLhY1g2mlDePDzR9GN5CIF9usM0Bh+5uMH14WyppeOwhnzA2F7T6Slu0SpmFtVhcNwMrKXa9n/KiT64tIS/2lQ7GyunbLg8BWrcmN2NUU938Cc= 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=Bkb7esSh; arc=none smtp.client-ip=209.85.210.180 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="Bkb7esSh" Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-70d23caf8ddso3390666b3a.0 for ; Mon, 19 Aug 2024 00:53:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724054031; x=1724658831; 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=X6I57evoLQvXCTBfsroOrJwSZgG1ZuVr6u69WBxxO90=; b=Bkb7esSh+tWOugKN6pS3+zaKvUNN8XcRPOo1wndaUqZyulXhbfrXXlxdNOEWd19Bg/ NVZxsDtwvaHlHunJyffHcsUzQNQU0ioDJRLOLG78IgfreUs1d2geGHfI2RW8ukD/FC0G 4WiFzaFkX9VuC6QrEIjm+lM7Of4/I7MsT1zi6vy3IrMZ25VDTFcq9u70UBQqrb356tuR uEgpMa2Xp7mkEidRzTr4jY9EIYeXp3x00nQ+LpWT5LZdO5e8YT9hJrQeWS39AQ2iMOjH b2uN/a1pJ8nH2nvQ5pVHgPT5Ow7CT2Raem5gBmR0NUD0EY4u2x1EmVvdYp8+YseXzebo 9eGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724054031; x=1724658831; 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=X6I57evoLQvXCTBfsroOrJwSZgG1ZuVr6u69WBxxO90=; b=HA9yHAX8XTxYb3iX5+eT0J1a9pWpqe6jtZszLks8kpVf5xlxJvuMEE+Tn5fSX3Xe3m dFly61croCyHLmox3w+Ncqxuceh/xld9lhLiH4+hguS4waHpgCE8CZJMKPrqgwhBNjql jgqbDS1+ijd665PWMPYn0h+fSZ9CIhKbf8IUtFWJZONpqjdPSGWQayAOxwo4wsC6iqJf w9Bi2zo1IWZBUpg6dhnKnG5yUoFkod+JELSnYIAIF6Paf/Oj8xNvbWNMtOvZwOPyDly7 SBipYSu0Iknr3aKMGHtdyfXPA3aGT1OpWvPSvjMA5oNAHxo5wO2+yrhOZ2WJmmUewh6r ESGw== X-Gm-Message-State: AOJu0YwsbFMMCWmpYk/tSybR6j1bb5Dk3E0KIGO5dAqmcW1CBm+9GA2d RMmnaleqorBVzsKxv1TSt1ZtqkMLo1kziox6ZxZ8BPkZhLDADwVnlEl9voXksUhg9A== X-Google-Smtp-Source: AGHT+IEq5Dv6jaQc9KtMj6kpe6JPoyjfuLqHas2UiNlZnzBvOD/+VYsfU6DqbBle6q4kTh6V8c4KSA== X-Received: by 2002:a05:6a00:10c9:b0:70e:9383:e166 with SMTP id d2e1a72fcca58-713c5271f80mr11650233b3a.29.1724054030496; Mon, 19 Aug 2024 00:53:50 -0700 (PDT) Received: from Laptop-X1.redhat.com ([43.228.180.230]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7127aef6eeesm6147151b3a.118.2024.08.19.00.53.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Aug 2024 00:53:50 -0700 (PDT) From: Hangbin Liu To: netdev@vger.kernel.org Cc: Jay Vosburgh , "David S . Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet , Nikolay Aleksandrov , Tariq Toukan , Jianbo Liu , Sabrina Dubroca , Hangbin Liu Subject: [PATCHv2 net-next 1/3] bonding: add common function to check ipsec device Date: Mon, 19 Aug 2024 15:53:31 +0800 Message-ID: <20240819075334.236334-2-liuhangbin@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240819075334.236334-1-liuhangbin@gmail.com> References: <20240819075334.236334-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 Signed-off-by: Hangbin Liu --- drivers/net/bonding/bond_main.c | 43 +++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index f9633a6f8571..250a2717b4e9 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -418,6 +418,34 @@ static int bond_vlan_rx_kill_vid(struct net_device *bond_dev, /*---------------------------------- XFRM -----------------------------------*/ #ifdef CONFIG_XFRM_OFFLOAD +/** + * bond_ipsec_dev - return the device for ipsec offload, or NULL if not exist + * caller must hold rcu_read_lock. + * @xs: pointer to transformer state struct + **/ +static struct net_device bond_ipsec_dev(struct xfrm_state *xs) +{ + struct net_device *bond_dev = xs->xso.dev; + struct net_device *real_dev; + struct bonding *bond; + struct slave *slave; + + if (!bond_dev) + return NULL; + + bond = netdev_priv(bond_dev); + slave = rcu_dereference(bond->curr_active_slave); + real_dev = slave ? slave->dev : NULL; + + if ((BOND_MODE(bond) != BOND_MODE_ACTIVEBACKUP) || + !slave || !real_dev || !xs->xso.real_dev) + return NULL; + + WARN_ON(xs->xso.real_dev != slave->dev); + + return real_dev; +} + /** * bond_ipsec_add_sa - program device with a security association * @xs: pointer to transformer state struct @@ -595,23 +623,12 @@ static void bond_ipsec_del_sa_all(struct bonding *bond) **/ 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; int err; - bond = netdev_priv(bond_dev); rcu_read_lock(); - curr_active = rcu_dereference(bond->curr_active_slave); - real_dev = curr_active->dev; - - if (BOND_MODE(bond) != BOND_MODE_ACTIVEBACKUP) { - err = false; - goto out; - } - - if (!xs->xso.real_dev) { + real_dev = bond_ipsec_dev(xs); + if (!real_dev) { err = false; goto out; } From patchwork Mon Aug 19 07:53:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hangbin Liu X-Patchwork-Id: 13768037 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) (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 2375D15A87F for ; Mon, 19 Aug 2024 07:53:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724054036; cv=none; b=F5+bESmLtkTcgvj65C+8bO5aVYvpUA1c7+AfM4d1Qt7pbJRBj4q+vXIind0mdM6+I15JEbOVKYhbwhSNTBq/wmuEruafXGohb/LZ67rrfuHk5vRoC8s8jzH4dS62XuRZcmc1/xrV2CzElgCHl6pX8OlVAGq/RpgYyZ9/qQBZ5Rc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724054036; c=relaxed/simple; bh=WuQHL9vFk9C00Hka/NOaAJM8/avGJfAf8AAqdNbtL9k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tWHR0XYfhkHWyK0sIGpma0tPzMLTYKjbOYZTjgCgVKEp10L+VRxNMURlO0jXwSvwVy7ACOBgPIvBFRkb7Rrq02tlh+W8P0ZvmgbNWrGdpe3Zb/zCJIgic84D2IfBAoqBHQ+Z8s+15ELIZjSn3MOW5L+C77Ll/pqM6iIF+mQJweI= 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=V36x5+tt; arc=none smtp.client-ip=209.85.210.176 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="V36x5+tt" Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-70d28023accso2884783b3a.0 for ; Mon, 19 Aug 2024 00:53:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724054034; x=1724658834; 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=hVycroMdds6D4oPSBhEK7xG3RafQTRbsAV69QyxbLqc=; b=V36x5+ttFGK2uggPtZg5WhWsCnFNv50Dq49Yyawn6/F5pe7CSwKsgpCvmqoBgEJhs4 RcYr6m6fMO8sMNZx8ft4A1Y9Ch37koMOZRBffjvuh8HlrHHy6ehrAvQ8Ud2qzPwR9FPL onU3bAQTSmgObQrfNER96XCkImdpweF/y/nWJPKlQf1Bv5VDxlrWVjuyyZ++Uqwf75Vd MJCsvRuaTjpeiejy8klI6ntTIpnIkLraueMGCiwZdULMn9sHGO04I2I6lfIoY1hBjQM9 Uh0NwjImeXHTrH9Il2fauHx9TTEdE4me53wkUFbzgscx6q0e24oLM/m3lEAs7eB5Jhf5 zFlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724054034; x=1724658834; 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=hVycroMdds6D4oPSBhEK7xG3RafQTRbsAV69QyxbLqc=; b=U35Wsd+lbjI2YdC0/nRKq6gT1A2XHg+LFkhYsHQ5N5bYmY6gsiZ0hQSELAZgQcf5Wl UAf/IUgkgsetJ9zkSoeH4aILWoN9+LgIFsUxBzssB/ps1iJCOncAb1r+GUMpIEbI80I6 F5r6gguUdOZ7td4C9z/tCtYqWerDtZvWs1Tcg4WDN0oBAy2XerdztAjR6ub/zS25WIv2 DMhwm2MZjDvRee2asoDhg+4DJahU5NdelKY/4ziUh9YCU0Ve5uVi3Z/LnAtONWXH7IyU cTlzOKz5XmHaSe/sjMw1p8dsy+J7OKHJu8UscBTYtNyBzUMEnQmGCSvhu8UITwNT+tYy CqSA== X-Gm-Message-State: AOJu0YzIWvTBg3AmYJD0SH8Jf/hpRPrzgHoAvIEn1OPjJ+q7BAxMikVf VgFmE4SBwJcuHMQ1tkyxa/hzfI4TtTFb4tbe0fRHrAZIAeJFgvuU0qBVuFbT6sRVPw== X-Google-Smtp-Source: AGHT+IFLgxZY3Vt69re592/RBHfHPRMn0PO1CmKo27dkkDf56tcefUiCrIDw8MRSNNchVGWGMzMz0w== X-Received: by 2002:a05:6a00:a8d:b0:70d:3777:da8e with SMTP id d2e1a72fcca58-713c4ecba62mr10191081b3a.18.1724054034129; Mon, 19 Aug 2024 00:53:54 -0700 (PDT) Received: from Laptop-X1.redhat.com ([43.228.180.230]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7127aef6eeesm6147151b3a.118.2024.08.19.00.53.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Aug 2024 00:53:53 -0700 (PDT) From: Hangbin Liu To: netdev@vger.kernel.org Cc: Jay Vosburgh , "David S . Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet , Nikolay Aleksandrov , Tariq Toukan , Jianbo Liu , Sabrina Dubroca , Hangbin Liu Subject: [PATCHv2 net-next 2/3] bonding: Add ESN support to IPSec HW offload Date: Mon, 19 Aug 2024 15:53:32 +0800 Message-ID: <20240819075334.236334-3-liuhangbin@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240819075334.236334-1-liuhangbin@gmail.com> References: <20240819075334.236334-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. Signed-off-by: Hangbin Liu Reviewed-by: Nikolay Aleksandrov --- 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 250a2717b4e9..3c04bdba17d4 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -646,10 +646,35 @@ static bool bond_ipsec_offload_ok(struct sk_buff *skb, struct xfrm_state *xs) return err; } +/** + * 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("%s: %s doesn't support xdo_dev_state_advance_esn\n", __func__, real_dev->name); + goto out; + } + + rhel_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_offload_ok = bond_ipsec_offload_ok, + .xdo_dev_state_advance_esn = bond_advance_esn_state, }; #endif /* CONFIG_XFRM_OFFLOAD */ From patchwork Mon Aug 19 07:53:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hangbin Liu X-Patchwork-Id: 13768038 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-oi1-f170.google.com (mail-oi1-f170.google.com [209.85.167.170]) (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 1B88615A87F for ; Mon, 19 Aug 2024 07:53:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724054040; cv=none; b=STVdtKTJCjer2xWQMwf7nR9LAQM1S9AIn2ePkWEcTuUN6KQi5Iwv8GrUBdWJq+3gU1CScAcadRa2sCGqJ9RTduoNw6t0FWgqd9FIntLW5wvZdgctfOWYgR94HNvWB+x2qf/1UrSgapSmbc5VOtnXHmbFlFVUZdfgRSR+aNIozHM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724054040; c=relaxed/simple; bh=rAI4sBFmFhIN8hsDwrCQPROz67K5IinmRRmNqQ7WOkM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=goQkdBuxnGX16IATzZ20LT4AhxDDx3L3Xr2n7ADqzNA+nimlyBWlfAa8eSXR4FgU3PYdxvqFgj/KWUJEbFk66jrFTPO2tfhNGEk5LkP7jYqbZfV5Oqo3GZghEPektUz+ooC5gaIAKrst7ZB9FG2nExyWcvyQphUte/BvItUfml8= 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=LwPsD/6J; arc=none smtp.client-ip=209.85.167.170 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="LwPsD/6J" Received: by mail-oi1-f170.google.com with SMTP id 5614622812f47-3db1e21b0e4so2662930b6e.2 for ; Mon, 19 Aug 2024 00:53:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724054038; x=1724658838; 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=QxUSDe4f7kyANQUlrf0A9ELfzzzlQRcsUZJvA0kRCuU=; b=LwPsD/6J5kvMHBqloLKdq9J84dZ6IpcBpo2mX7TW/PS0I1cSXAhmXFkSS3goQtBG5v WKOeSBwytR9d6U9WqR2QUWUh7NvHiU05VB9M4hX+lLjdImVBFQHJPGAMumcJ3XXF4fSw FOq0Ys65EsDj1Wz/KT4V7fnCVg9gdkFmQt4I2Vd+8Ks2oP11yITy8edlHwz6MhnPJrlX Cr8xnrjkR7X/8Tbkm4oEl0sdhnKJRungxBTbVdKFkLR6dyr16sHzmMRdFaMSFubzfiLH yCmO7DgYuyhWQfGKQJIyulZ19+euFjVEYaIeqUgAZR4r6lWAAt/+fLu7OSyubX6xJMG2 PLZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724054038; x=1724658838; 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=QxUSDe4f7kyANQUlrf0A9ELfzzzlQRcsUZJvA0kRCuU=; b=UOowL949PydUZVYu+3RRMsUemoFY9gBckzxgxDOQRI1ek1zVUTPH+0J6Lc+PDF5yez x3b+yMnyDy0KA1J8f1eGDHgdTJ/sl/HEBUhDwYhlbbCe8e4VAgZEcpuw29BrpOZPj0XE akV11F6D3C7sEsW1CNSt1peAHwIK9zOJYeY70gEnDVuYAmk2kvzhrAI6n3H8zhs3wjjH XcEBlT9OIFFYKCGmw1BogFo8WX6+SVC51CtF9egBfKIad5piTBitgKypqifyIhKE/1vk mlQg9wa6/MUcvH4u/7QLRyR8BNqLtBpbPTpw4sX2vN53sXegWYybb44xa0GcP8HdKRjU PDJA== X-Gm-Message-State: AOJu0YxCnIMXzypuC5pKyfKZJEJni4RV4/mUIdThSFYiyNosWgt4SMT/ aExersa2xiIt/8gStR4txU3UPe2mQEGD0G8rvDvJDjRAJxM+2MCC25dlQY/ER6r8zQ== X-Google-Smtp-Source: AGHT+IG8FkFmG7JysN4OGI6fibUqjbraRks4NUatB9mI7lvWqMvZB87RbpTClZ1jJqDFDAuGGgUaug== X-Received: by 2002:a05:6871:b0f:b0:270:2063:f166 with SMTP id 586e51a60fabf-2702063f600mr9964005fac.23.1724054037838; Mon, 19 Aug 2024 00:53:57 -0700 (PDT) Received: from Laptop-X1.redhat.com ([43.228.180.230]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7127aef6eeesm6147151b3a.118.2024.08.19.00.53.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Aug 2024 00:53:57 -0700 (PDT) From: Hangbin Liu To: netdev@vger.kernel.org Cc: Jay Vosburgh , "David S . Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet , Nikolay Aleksandrov , Tariq Toukan , Jianbo Liu , Sabrina Dubroca , Hangbin Liu Subject: [PATCHv2 net-next 3/3] bonding: support xfrm state update Date: Mon, 19 Aug 2024 15:53:33 +0800 Message-ID: <20240819075334.236334-4-liuhangbin@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240819075334.236334-1-liuhangbin@gmail.com> References: <20240819075334.236334-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. Signed-off-by: Hangbin Liu Reviewed-by: Nikolay Aleksandrov --- 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 3c04bdba17d4..9e41e34e9039 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -670,11 +670,36 @@ 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("%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_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 */