From patchwork Wed Aug 28 10:32:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hangbin Liu X-Patchwork-Id: 13781086 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) (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 CBAFC16087B for ; Wed, 28 Aug 2024 10:33:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724841190; cv=none; b=Mqu8c2EHZiw0u964G3KjBxM8Pzpo6tWsZwfyf3IsJDwsBo9uVCgYEcGCQEFzzQl6/vB58a0lJ63ghCACxUfoHn9WLF3JUe/hg1eS3In2mLnA7qFqosF/zS2dqxl8LzoImIhaawN7Gad+nN9PsmwafAlBmNkvEx1UlZjDSP8ECX8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724841190; c=relaxed/simple; bh=hWEdMYIVxWFBoN/vtuEcjWh8etmv1bwlfhmtqhlWI1A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VNR8t+rAbYgLgfLEzAQaE77ttlvJP7Za9lS+03O+3hrVm98EaJx0FLV/z9f5OfOjCvF9EUryuUw0/HMnb+as5fZ0D6gW0SOfyCS3zxvnqch7xodQZjh/cI4h5ous5M5/uJkmFohpcfgqyPMJyytDYj87+dRmrpYue/bGOHu6Kv4= 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=ETs31IWJ; arc=none smtp.client-ip=209.85.214.174 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="ETs31IWJ" Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-20231aa8908so52303955ad.0 for ; Wed, 28 Aug 2024 03:33:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724841188; x=1725445988; 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=YUJk5mVFW3si3tuxhc7HSbmdH4wdSm60g5pd0yn/6gA=; b=ETs31IWJri9vwI6i8j2z8y7tjuuGYzkV5gkTBPs0RzraJ/elEEAVAcLpc4QU2GudaR wrbOyIJ2nZ98nsNcBFXdLnWQgHSi1Rq8joiegYVvLxjtAZTyL6YQHagssZco0SOQK853 rsMa4/HmnGlDI/Se0m1bICQ+guqEP/lmsUQMwPv5zqykONFd3SVrugqCviVp8IOzW7iD 9aatbP9bpI0iYxihZgTvGgcYhD+MqMq4sgiVEZHH12piW03MECRlylVOaSKayU/dyN0E eTACBuJuK6DAi++Q1FQbSCY65E+LqOrdVdsDWrd8/uRsBVzjISOgheFOJh01+Bk+2EtE r7zA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724841188; x=1725445988; 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=YUJk5mVFW3si3tuxhc7HSbmdH4wdSm60g5pd0yn/6gA=; b=v286J38c/ngxWSnja5Oj8277XUdIl5TE9dUEj6XElWNKxMMe5PwmgtzotCY2OomWwg vYeaJLTENG7SbdxFgAqUjlc28hI6GCruXS4WSTcZpZXJoVDnRwHyxq6BXmwezClkPWJk A74MCsijwQDkUPZ/Mnr5FC/ywfVCmdpBUkFpJORfg/576jBvC/QOfnVtrqAx0X0wLizY s8knkCa7PNdq+RtbUMqJdpwXp9+Ub7smtD2OzcK5H1SsuvIvq6pS67S/7icv9cq90aJT WPCD3E3Ks00rodK86ZzsYL64BpPh+M0Ppw4IdQZKJS/zae7EoA1U/fKmjXkc+fR/8o2M CN+Q== X-Gm-Message-State: AOJu0Yx3ZpZpoK8/mvVeEXOo4qfNp006X3QwoO+H3xJsChuXdNZWMb3Q EzUGu2d3D9kXMklRRfJswBMbUs4nTnaGXMKZ/h6V52Nam+19fFJX6M+6K1G9inSCfA== X-Google-Smtp-Source: AGHT+IFk9za7/fA6v5jbv0nF+yOP0ddhNlpdGeVkvR7PEWwC7teqrKLkKSfjzhmlAmvuyIFnNhtWaw== X-Received: by 2002:a17:903:3547:b0:1fc:4f9b:6055 with SMTP id d9443c01a7336-204f9a60e54mr14839895ad.1.1724841187669; Wed, 28 Aug 2024 03:33:07 -0700 (PDT) Received: from Laptop-X1.redhat.com ([43.228.180.230]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-203855ddaeesm96298835ad.124.2024.08.28.03.33.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Aug 2024 03:33:07 -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 , Simon Horman , Steffen Klassert , Hangbin Liu , Jay Vosburgh Subject: [PATCHv5 net-next 1/3] bonding: add common function to check ipsec device Date: Wed, 28 Aug 2024 18:32:52 +0800 Message-ID: <20240828103254.2359215-2-liuhangbin@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240828103254.2359215-1-liuhangbin@gmail.com> References: <20240828103254.2359215-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 a3b6e6c696b4..adc47e6e6d19 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 @@ -594,23 +629,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; 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 Aug 28 10:32:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hangbin Liu X-Patchwork-Id: 13781087 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (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 2C55F15B0F9 for ; Wed, 28 Aug 2024 10:33:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724841195; cv=none; b=Hy1r9uPxKExX40UQzcWPK7vADGh5+0Rj5L28r0ZIngxCpf4jGayrqC2VvQdjM9iMnUqcbjabJpnx5LYrxGkZskRpMDe5/EWp2M73HbeWK1d7j2WtPIrWJNmpWTBT7xISrUyz7NWqwmzq9sEu9ttlG7SVyJeJmKajLLMwqPeE4/c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724841195; c=relaxed/simple; bh=ClqbiPv5F2QqJM8Yj3VbTynT2F5L6UKPt4B/V8VqkSU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Xx3EYu7oD9oyq0B5vFUdaoLJv0gb5gSd3sqb5JuvEYZlSQBPknC81NJMPmk5J+iMURToPcn40cIsNPO4MLxgyHpC0332FJPfICzEPXecewFCOOkMHVPjUTs8Dx5zwN3t20FpCDz9lmwyYEoFcx5rSWXAn4bJjolDqXgecNv3PJQ= 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=SrUMj2J3; arc=none smtp.client-ip=209.85.214.179 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="SrUMj2J3" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-201e64607a5so46896965ad.2 for ; Wed, 28 Aug 2024 03:33:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724841193; x=1725445993; 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=2F3B7sBLl8yLVD29O4UtpiYlRm9MEK77/El8e5ciEPc=; b=SrUMj2J3O0Zs2/04d9H4v8EYikaWBxdFeMzI0u08KKR2KKZ2XD91kdKIYGcLdxoneC c3b+YsYhO4K+PA7plJ3DzY/AVPF3xmoEojF8SNiIhClG8pyQwyqzz+cLFiqRVkA8W+SV gQIvjO6lHF1+oL8G3ZovYNbnVRX42s1F4NxwvDrP6JbLNL9cBTShHXsUBKMWjbA/XEhH ol5RR4Jg9N0PZ7Tb0BwQw0nlEgdqlYCHv9pnqH5sSQLdHc/n1JdalvX3CGzyIOJOjanY aj+34lwsmKnQff7iXkT6gdHCNnDiwSTC21D4KTS/RZseuHE4lS5sps/HGQcs5vcGCS0o uTsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724841193; x=1725445993; 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=2F3B7sBLl8yLVD29O4UtpiYlRm9MEK77/El8e5ciEPc=; b=RFEgxASThRCW/sO7k9gB2msB97vzYE1JsCc0OXgaX5cWPzudIhQ4QSxHmoyqOElGoL xM4ulbOGKs1yj3zivYoyTEerKL0G85KojiK16TMmpo/v1OwK4VfR5YCKJ/Mn229QuX3u twuH3xTGYqesSpbk3a1r0WpKIlXXhTTSW/ve/aUeos2GNuxdktPRS4AGJT4y5vLGrkJV TNCuWZOjGSc8bBZqPm0eR1f1MY2fVBfk+pAW/csRrepvUUMDVBOQT+WzqmZHkxv3cfzs mxi0MsZA6QNH7R9cTxtrIQ4ZOf17EHeziiardgq51YbjEMeiWHe2v2XKR4hCA0THg4UR AvLQ== X-Gm-Message-State: AOJu0Yw7OKmiWHPeP9okYqdJrHUOtZ7wwpOOdJwmHIWV3rAzEIeHQBsk wlwdBhLFoAs0fAmyRCOwV6PZT/zyMRHkO8ghG0DlBb8f8oe18ECKHQjt7d6TvAVF6w== X-Google-Smtp-Source: AGHT+IGFH/IcDkGb2mx55h50ILZD2hC1Y6UNi6BojKGfkA2pOaVnEJWjXsqB6mjAZQCbyO5L+fpMEA== X-Received: by 2002:a17:903:1c8:b0:202:cf5:1014 with SMTP id d9443c01a7336-2039e44159bmr200328455ad.4.1724841192665; Wed, 28 Aug 2024 03:33:12 -0700 (PDT) Received: from Laptop-X1.redhat.com ([43.228.180.230]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-203855ddaeesm96298835ad.124.2024.08.28.03.33.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Aug 2024 03:33:12 -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 , Simon Horman , Steffen Klassert , Hangbin Liu , Jay Vosburgh Subject: [PATCHv5 net-next 2/3] bonding: Add ESN support to IPSec HW offload Date: Wed, 28 Aug 2024 18:32:53 +0800 Message-ID: <20240828103254.2359215-3-liuhangbin@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240828103254.2359215-1-liuhangbin@gmail.com> References: <20240828103254.2359215-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 adc47e6e6d19..c0a20b834c87 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -648,10 +648,35 @@ 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_offload_ok = bond_ipsec_offload_ok, + .xdo_dev_state_advance_esn = bond_advance_esn_state, }; #endif /* CONFIG_XFRM_OFFLOAD */ From patchwork Wed Aug 28 10:32:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hangbin Liu X-Patchwork-Id: 13781088 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (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 B4D7F16C6B5 for ; Wed, 28 Aug 2024 10:33:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724841200; cv=none; b=G/fw9IeRbO6JMC+YPQd9jys726W1t+u2T4XiUDodbML66DeqqD+njjNoT+KOBqP4Tx5hb4Twjn3bZ01gx8cvr3CXRILiPWN3DXfdyAinH0t7597dobUIlQsyYDxLIL14+j2dm3Hwf/JbyP4ch6mzm5JLFfGGBsNkm7lCh263M1M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724841200; c=relaxed/simple; bh=3HbmtqVFcODeXE3G34ocVPAEW6flRYhn/scAA7N9xLk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OiMqDBqwzXETPF3l5jZET70DaJx1SBRBPVJTgG/BOoqbxM0pGj/9PmqDISdIM2f1MOC98qrFOc4V2CNOGySTcyokWfaSLFQYHZbTZHeEVxxA7fS+oIq02AMlLEa9KMOVJ0KNuT6DPWjH+Up2GlbAjHFbqKU8m2mWeuARrqvZXbc= 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=ApmTtTCy; arc=none smtp.client-ip=209.85.214.179 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="ApmTtTCy" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-204f52fe74dso7510765ad.1 for ; Wed, 28 Aug 2024 03:33:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724841198; x=1725445998; 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=13kCqpXieHBRS9c9vlRFrwDqk66N5epm1Ti3AnVC+XE=; b=ApmTtTCyQC7CoABspZMUopIyT8imrgJjnituF9KzhXPfmMQZi8epZTnvoV0TjZeFjG zniHBqvgyza+cGqJ3vYfXEOmnYuJyw9vDUewumDD1bVQzwKX9RfV09KBc3eqGyZLQ+mY w1xyn8opEVapeo+iKOsSeLsCLCdmWVRrtwaUOYHnPzg+alOnj26riFktYFoF69vVyx7f UM0jGWWwVkWE1+gjZEuFjEktabbKDAnhHa+XsJ3znSi2v+jJab2ol2WH0GF5MNFMH55I wLGJxzhYAIA7fhRgNcNAl1o5ihhelKdFlJ8SodQkLMx+XC2n0T13Iq+zb30rxswlQ62j GrwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724841198; x=1725445998; 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=13kCqpXieHBRS9c9vlRFrwDqk66N5epm1Ti3AnVC+XE=; b=S6wfAtwBho0gwvCAoVn4+Pr0VRyWUNKr7XXSvsTruFdOkjkAmwlSNju5qLKGcA6WNQ rbjSZwdojln7zH/GsQwiB90HqMsbfG5Sc24YwEWEw/3cwyP2OEnomkVG4trhfxNRNqM7 8et5F0iPLpMIAPN+ciFAGDrihSmP7cT3hKF1dRlhbezWeLs8oH5eBaDL+saYDofIl4jg EhoYK/q7/0NDw1BsmyT5UQts5S0Na0OeufkIrr0FAjZzx7R7MD9TBM+4un8HcQ0HGxvT zoF2scVHj4935PVogKpkUu8Ox6CiCruVsk6xIqoArM6I6Nvk9rpQIUHwf8eiUuWXoRWt 34AA== X-Gm-Message-State: AOJu0YxORjAKuiIAH4zCw435a4V+6Vu6haorHRe91tiq0c5oMjtxN9Ja S8M9XJdO7WdrXOpNy6TKDQbe1PSjvaDp0CLTobYGMCPHWG+CNRMXewS63Ti6dsJ22g== X-Google-Smtp-Source: AGHT+IFyCL6oPmY5Dp099alQe2RXskyeA6EpmoEO608urHo67ZDuOqO9PeKbus4F+s9AcaGFhfZZCw== X-Received: by 2002:a17:902:f790:b0:1fd:6bfa:f59 with SMTP id d9443c01a7336-204f9b7cbbbmr21478935ad.19.1724841197737; Wed, 28 Aug 2024 03:33:17 -0700 (PDT) Received: from Laptop-X1.redhat.com ([43.228.180.230]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-203855ddaeesm96298835ad.124.2024.08.28.03.33.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Aug 2024 03:33:17 -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 , Simon Horman , Steffen Klassert , Hangbin Liu , Jay Vosburgh Subject: [PATCHv5 net-next 3/3] bonding: support xfrm state update Date: Wed, 28 Aug 2024 18:32:54 +0800 Message-ID: <20240828103254.2359215-4-liuhangbin@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240828103254.2359215-1-liuhangbin@gmail.com> References: <20240828103254.2359215-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 c0a20b834c87..042d7627bdc6 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -672,11 +672,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_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_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 */