From patchwork Thu Aug 29 09:31: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: 13782856 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.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 70FE018E047 for ; Thu, 29 Aug 2024 09:31:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724923910; cv=none; b=skDtq/EFmHlkyDXM4rQ7DKpxeQqjX1HfLVS8XtAbkrJxQuxIgWsTjYl3cNjiG0absrRHDj1xs6msfzN3AanmWW8Pj3Uhzmls9Xv8nu5LhhKKdotVLozgDdOsMBy2Y/9AZrskq3EmIbv5DYuRdP0yTNQmnlrYDwFLXTgL2wHB8SE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724923910; c=relaxed/simple; bh=D+s13BDEUnJeZYrxYWqDLcqwE/73VE4oMFbNYQhetCU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nKo0Irtz9yhJehcEhsXhd6byncV/M27nwXjOKudbP7rp3yGMZ4m5lTkZsxPWP3XAqmYqzvCrDJ3OWD3rzLlFdxVms8RsLEBR9CV2FkbmaJJRKxBdrGu9p5xqJHgJy83XG7zxLFK0sykBz0PIIP3ye3SMGo/LTUIwtioC00eN2mo= 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=bupjNBxJ; arc=none smtp.client-ip=209.85.210.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="bupjNBxJ" Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-7141b04e7b5so261951b3a.2 for ; Thu, 29 Aug 2024 02:31:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724923908; x=1725528708; 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=tPRhluOYd/mm0oVegksOEHKc4Aw+9DxFrTl3DWLVjzw=; b=bupjNBxJU0kiNofYZhncRnESEOCiPsg+FTC7V2ifL8HdKfMqY1DBK/L0Fm4DuAipb4 VfYzdANGyuMvfqWCEKzHqzTaaxmRTlftAVA/f181Uyt6jrlTkDdXOguFy1pr0sG7saQB igQ+QYDp3kYaLsrJK1oLuIL3j2mBrVBXPu5CKacvUFjQpDUiEN+tqrmPHWyfaR74BdQW o0UaTpQvE7sc2OY/vqfb1U6gHRJQWSO3q8cjb87Dgt0CfNyqblB46M72a8P9Zd4xq0ka LRf+MjUFZff7u6W3bZmm2graqIloKKQmWv9JGmbcOw91OqRBfU45iiFf9PrMSEkcLxLC RjIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724923908; x=1725528708; 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=tPRhluOYd/mm0oVegksOEHKc4Aw+9DxFrTl3DWLVjzw=; b=b+J2MarQOPUbUS3ChrNXkrCZ1S1rOTw/+DcmocE+r5bvJxRZpt3dejWFkyMIGlMDzg ZXv0A4LDGhd79NjuplnXClp6VjwJZBfxgLlwm1mC6p/AhsvRLl8+Nkf9I8JIDNrTLEtG 8YaoPR5lakrJ/uM/5nk9FN1Qx5jOtPxhLp3W41aF0L9g8MyO7RkDlsBK2V5qtpw5RUoc i8ZVyUhkKoc3pHoaxYxHnq2N/+OYXjDbHi1JLLUATLCn/pxlt9FFLj1yAN7CHwEYoPZ7 m0KiogPmmIgLBtTv7IZQSItO/HtPoDGMTGEkiHcQWhTn+F6SS9xAs/bSbRNNA+gR8zUM ljWA== X-Gm-Message-State: AOJu0YyFhZUFWLuzyu4AIvbIhpm/0kLPnDxHp26nZxs8gZ5eVSGCcePu eq3TLrvmH1+Sr7PYbCVUDpZbPBnSzYm5QHS3HnSnHDDE24ixF14c2BgVjI28mrscuQ== X-Google-Smtp-Source: AGHT+IHLn8rDWGFw7Cpy+cfjDQt8kLEP3YoKA1qQ3EFKLvFqYR1XOdzJwkMRDwh+7ZFWVICB/TDUPA== X-Received: by 2002:a05:6a20:c78d:b0:1cc:b22d:979f with SMTP id adf61e73a8af0-1cce0ff23f1mr2172558637.4.1724923908140; Thu, 29 Aug 2024 02:31:48 -0700 (PDT) Received: from Laptop-X1.redhat.com ([43.228.180.230]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-715e575c417sm743276b3a.197.2024.08.29.02.31.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2024 02:31:47 -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: [PATCHv6 net-next 1/3] bonding: add common function to check ipsec device Date: Thu, 29 Aug 2024 17:31:31 +0800 Message-ID: <20240829093133.2596049-2-liuhangbin@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240829093133.2596049-1-liuhangbin@gmail.com> References: <20240829093133.2596049-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..4eb4d13fcec9 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 Thu Aug 29 09:31: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: 13782857 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-oa1-f49.google.com (mail-oa1-f49.google.com [209.85.160.49]) (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 44CC818E047 for ; Thu, 29 Aug 2024 09:31:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724923915; cv=none; b=mmcrlBxTMLLFbMzR0zWg0nTEiBju3EvL5kKOqCELLcp49J1TdMVi9X2P3NVDIwNiPwcGrAdNRh90zZbiiThX3PXnFHxMYLJOr438h6/Q15UgN2NueCyHbG+232xeEMe/O97C9wvURAvTHtFYCjhs2V82gPO7JpkFzg6uhMHADGk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724923915; c=relaxed/simple; bh=8g40356MkPjuZIWUbOwfIyP6ezuFvyDzC9eJ8+ejyiI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=N1iVPgn2/fEBAuiwA+0Ez+dWQfFUlqEiluqw8ELsZxLNDXui6P50DpkYk/8GUw/R9BT02ZjwchhWQplvEYM61d8rL68mm2qWYD3NzvWFrDOnu4AJeQi7CsH7JLUElFw1jOd3SpDbewqKBrXQAvtMp/PbMeUqzge2cuoCAdOE2as= 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=mrB2k8uW; arc=none smtp.client-ip=209.85.160.49 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="mrB2k8uW" Received: by mail-oa1-f49.google.com with SMTP id 586e51a60fabf-26fda13f898so295106fac.1 for ; Thu, 29 Aug 2024 02:31:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724923913; x=1725528713; 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=xJuN2WgVTPihSaeD+gIc0BwVQLvX8pr42m/aNkKE+GY=; b=mrB2k8uWsuWXo9RJrqTOV/jxW6QHIlTd6/exHmI0gzgCfxZTtaQwdyp7UUTPW+97AB JE/KUurtwSlc2pl8+AMLhaZ4ck4fbT6ctBsO4sEXrymWugMf4+dF48W6GqNoUMDRZVWC +8FGMtouc5ICnc6JfI0KqF8udALjOyfnEIcMpD4etIXLArToALM591foUTOgaN0RDYMq LbL5IBfJMv8qeg8m6jJ3i6tMDj705swydAQvfAOYsLJGj5fIG/v9XdIRkwISVRKPHqu4 QiMeU7U+4RIgTDj33YVLhhT/frGGH7wPuIkzRKRzfH3Zdm3kiB5zke77ptaNudYsae1T LZcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724923913; x=1725528713; 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=xJuN2WgVTPihSaeD+gIc0BwVQLvX8pr42m/aNkKE+GY=; b=KmNzQn+NoH65lnv3QcPSMbRpvMwHhRSChubztFHxp7U3exwdtgNJYMdFKaFESTPcR9 f6qGhX/IFn2GDNsexs3tIxkx0tok/rO60D5j4/F94WjVjodTeOP23IPyPl4tGkrmJvaC r6wvIM+YL6GwBa5eS0kL++kEB6jOu1REnYFCx7mHFS1i7VPADE7lGqBYsPdJQkYGnjUj ly07jZ4fkL0p3IIiNdlsowJmJIM+yN0pMK6OTu44TOoiTrWY9e9nf8pLtvEAhuUpMcVn n1JsmLF/FqDeCCB+eUxOCcc+NYes8D5txt9LslE/6JCTbHOy56+mWF3FVl1/E70To0pd EHEw== X-Gm-Message-State: AOJu0YxYBeHGKrdpVthibMc/CaIhCo7iKJNNaY2YYu8wbokvOLBBM2UR /pInsJuZOOFKXoG2Bf0Ztq1ING97PgoybPZkPDKIjGyCPCj01xNWUbCDoPE51vBfaw== X-Google-Smtp-Source: AGHT+IEwiZsluC8L8CFb5S9/BfwTEf8vfLG/Xd2tREk6SNs4ATLxfmWKQ4RurFbjw3jai8VsKODW7w== X-Received: by 2002:a05:6871:24c5:b0:269:2708:aff6 with SMTP id 586e51a60fabf-277900cfd38mr2338339fac.16.1724923912752; Thu, 29 Aug 2024 02:31:52 -0700 (PDT) Received: from Laptop-X1.redhat.com ([43.228.180.230]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-715e575c417sm743276b3a.197.2024.08.29.02.31.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2024 02:31:52 -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: [PATCHv6 net-next 2/3] bonding: Add ESN support to IPSec HW offload Date: Thu, 29 Aug 2024 17:31:32 +0800 Message-ID: <20240829093133.2596049-3-liuhangbin@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240829093133.2596049-1-liuhangbin@gmail.com> References: <20240829093133.2596049-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 4eb4d13fcec9..f0d479c95dd9 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 Thu Aug 29 09:31: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: 13782858 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ot1-f42.google.com (mail-ot1-f42.google.com [209.85.210.42]) (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 8F20718DF69 for ; Thu, 29 Aug 2024 09:31:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724923920; cv=none; b=B4DzQ4x8g9b0kRSE34JKzXkJqIYdHLcm3rMw3C3pG87cwJkpsdyIyl+ZA58e24QlE8b10oP0hajywUGzeBnpBBvTzv1WprH1JZfZ1Y5PC+AE5yt2qcWFeWMfKqIDdgjRQvibyvxwnVNHmSjcebdR0XfSWg3b2fVfjIvgbPTVrjs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724923920; c=relaxed/simple; bh=68XUardSUckQHYyfMhUALNt1L0KrfGhAAB+I/H6w2Cw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PQyAl1Sjjcmshbb07lEdqppL7l4y9RA3GpKsQ6ftObZCRZrLefyZWh+NDNij721VyvV9svxKtv4XBRKPfUwIMBTB1FF4adW9CvyOD5dqWampyi/G8/WNSbMdKRC8+j4hQSf+HwQKQZvLfiJkk1pDYFj1uBloCTqnyqEisz84lVk= 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=Bp38AaYd; arc=none smtp.client-ip=209.85.210.42 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="Bp38AaYd" Received: by mail-ot1-f42.google.com with SMTP id 46e09a7af769-70df4b5cdd8so304506a34.1 for ; Thu, 29 Aug 2024 02:31:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724923917; x=1725528717; 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=uu6a/TmKbClbhkXYyeBBpO+MmkyfaTsSMktSnKqxaG4=; b=Bp38AaYdQZ2+r/snQqie7OO/S4mbVW/Wty5OXP9HuWD5w2BfNtmzKtPIJUJzeNX0Fu 9ioFOMVBNlwrSDFmCAYZJ/b+lzN8Hd+4n9Eq78cpbDn+zW58QRserqdXTth8iNdXyTWN thIlgwSpjYhIRn0UHmT3Z3pp9O/AZQKXne4ONxLdus9nQWZU97CfiJuz6U5pqsiDAeZp 3hM2xSXtVdbFYD4wd8pdD0lWR3qJPbKDzWde2m738o90OzYJotNSJf33sIThFG9YU5O/ XuZ0T6YBV5SW6NbcDcg1yFK8iQqaJn1WMwftPUxMxbsMn/2/RyB5vAkX24a4k1/zfD6O Sz1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724923917; x=1725528717; 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=uu6a/TmKbClbhkXYyeBBpO+MmkyfaTsSMktSnKqxaG4=; b=o3FFhm0vWH4Es7VsQ09kvN9Zqd4Zh1VtuL1NPZhR7TkvAirYWP4WcfpRbyRoj2kt96 M8f/uaTg+T2aIJo0jIz85/x/FVSemiGxuGv2lOgdNidXZNSDlRwoSkjh9dpo6ejLprUc EbO2Avi3RI7GSRd5B0Levpq291uinyIkRdZRCA8tK1eCEH5WF/evCzp4GiI+Q8aN89d/ OMjr5IrzGlFRYuXTw3b59+SVke1WgKVm+P38/BUww2EoIwQvxQx+9jNJtlVUrtxtsNMJ n6AKgwEsO9mDHgFpFCHSQIhc9/ROnvSyagY6yTJfSIxWMBjgZNm4CjoYGIPB2OsgTgIh oBKw== X-Gm-Message-State: AOJu0YzdeLVGxW7f6Sn0TmW1Wy6HLGhtsgLirNFDTkuSMzyaYNkil0Ag L0qKvbL8ULTB0sqoqIPUFOUHbDWBMlZOnlZJjS61qx7J90sfLAdxXZlov2p8oUWikQ== X-Google-Smtp-Source: AGHT+IGlPThBRVDWM9pi9MUygktSqEaADY4R6Ht0xvwOPsEwW2dcbjvI3LTh/kpJAKcjfnrAGNs5zA== X-Received: by 2002:a05:6870:c151:b0:261:236c:2bc0 with SMTP id 586e51a60fabf-277900c6be8mr2710485fac.13.1724923917292; Thu, 29 Aug 2024 02:31:57 -0700 (PDT) Received: from Laptop-X1.redhat.com ([43.228.180.230]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-715e575c417sm743276b3a.197.2024.08.29.02.31.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2024 02:31: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 , Simon Horman , Steffen Klassert , Hangbin Liu , Jay Vosburgh Subject: [PATCHv6 net-next 3/3] bonding: support xfrm state update Date: Thu, 29 Aug 2024 17:31:33 +0800 Message-ID: <20240829093133.2596049-4-liuhangbin@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240829093133.2596049-1-liuhangbin@gmail.com> References: <20240829093133.2596049-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 f0d479c95dd9..79929a12fcb2 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 */