From patchwork Tue Aug 20 00:48:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hangbin Liu X-Patchwork-Id: 13769236 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) (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 BAF7E17C67 for ; Tue, 20 Aug 2024 00:48:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724114940; cv=none; b=hlCbUFjft4RzMDOnJFiO1unEGRfovLzBjYoVz2H448mx/YtBVPV4IqUgoHojuvDmh51fQgEgk+UpVryhc03JlVBlm9qZ8/t9fT0EHChj30fWy8l6GNc+NY2O2om+EKNg/h0rVlSPAaTdHttTrc9DBEc0+qeQc83qjS8a5iY8Bso= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724114940; c=relaxed/simple; bh=yQt4Cluy6o9c+80+JQfQLD/iktSOdzE/jWhOuRBeKg8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=f7wvDEbnJ0T1Ydx08u6EKmpvqyW6H4oEd+ro3DPkuyR3UIeS32Y1Y1uuJWDDfZKuF2F8AKnnqQsPRbVv0nWTL6Krxv4N2QU9B3mY/veurxggokP0ZJbV/qdVIUUvZ5VwKAzMVQHyLctbgYGpDb4ZXqeWZFleRbz9QLcHrcqTbVo= 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=KSPaWutk; arc=none smtp.client-ip=209.85.214.181 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="KSPaWutk" Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-2021aeee5e4so14212275ad.0 for ; Mon, 19 Aug 2024 17:48:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724114938; x=1724719738; 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=0LVdds2t/ms5NrJUSfJGtrgx0vk+SGHQw8qpuigL9sw=; b=KSPaWutkM5EcsSsEU67BBz65IQinVaO3oWf7rI/TeyeSEax0MxnctAwypu5Ix3eoN5 uMjfdiJ4Q3iQOGFUBOXeqWQ9w1C4OjTOkrHXH9TElsYowSrHknPEe4aCu49CvTqIPiBk b4Qy/LO7lMif6Eu8lJ1mHkbmZlbBTBpvWgXBe00CUtJdiU8FUKZ6MmPBx3anTZbADDG4 L8DPv8ylb4DNafFWEWIxOKyUogghZZXeZ/RS4JJhwBKcpeEKWorscSev48QIz9wGbNAG haR+Yb8hLHG0hUgkbsf8j8lNuTB6YxUqf28SJA/tIdwpkwOT2FyBcjVkWomrf5qEH86j Y2Vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724114938; x=1724719738; 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=0LVdds2t/ms5NrJUSfJGtrgx0vk+SGHQw8qpuigL9sw=; b=fY6pOBY8yYglkrqX/rtqlv5e9igDzRi6d2s8UFaf0Xqm79t1oE+gZXE1QIYdy6kDWj Q3wBx/upDCHhg3+v0QwhKcyQcCvlDMlAFiHd7Y324zIYONB9gKve/CCAFzUW/U5UZKO/ QxoZNUufObFE6bvM6qzS1x0MlsJ+qo9aU3UY4XptR/tOjF2xJiH0/WsEvETCSY2uE0iU PbqS8lZiDTkKUSP8QX+KpCQSx425gPtEi9yHiozAAK9g6xiuZVKboOQIqPSBzswhUWys y4eDMHDEqt8pQn8Cuo1Ljb+GhAGG3Ro1+mhfuDx0oTiw/YSZFJxY8stCpFY4VMXCSgEi fgRQ== X-Gm-Message-State: AOJu0Yxuxl+HAcDUhht9DvGjNZCeh7xULz/J3utbv5bkYkHSzw2BNG0s Li8O+K54XTFwbP8G19cBx0h+6HrKsoCUDnWvJsNNuCfRu4/nIH1GDoPlWesJNeU= X-Google-Smtp-Source: AGHT+IHMibmon6GC8RhXdbPH+VCSiDqpbxOve0Jfm42SRhkBgjPc5TAzt5XMG/yPzCvRB6KBIBf38w== X-Received: by 2002:a17:903:2307:b0:1fa:a89:fd1a with SMTP id d9443c01a7336-20203e4c4a3mr123368505ad.10.1724114937392; Mon, 19 Aug 2024 17:48:57 -0700 (PDT) Received: from localhost.localdomain ([43.228.180.230]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-201f0300522sm67861455ad.6.2024.08.19.17.48.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Aug 2024 17:48: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 , Hangbin Liu Subject: [PATCHv3 net-next 1/3] bonding: add common function to check ipsec device Date: Tue, 20 Aug 2024 08:48:38 +0800 Message-ID: <20240820004840.510412-2-liuhangbin@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240820004840.510412-1-liuhangbin@gmail.com> References: <20240820004840.510412-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 Reviewed-by: Nikolay Aleksandrov --- drivers/net/bonding/bond_main.c | 48 ++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 13 deletions(-) diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index f9633a6f8571..560e3416f6f5 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -418,6 +418,39 @@ 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 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) + slave_warn(bond_dev, slave->dev, + "not same with IPsec offload real dev %s\n", + xs->xso.real_dev->name); + + return slave->dev; +} + /** * bond_ipsec_add_sa - program device with a security association * @xs: pointer to transformer state struct @@ -595,23 +628,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 Tue Aug 20 00:48:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hangbin Liu X-Patchwork-Id: 13769237 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 A4A7017C67 for ; Tue, 20 Aug 2024 00:49:02 +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=1724114945; cv=none; b=lBVsyrNSnLmHlIY+Rm25I2urLz0U2yJdAHNPP16cHD7yshpJpqDg5fdY036oRTzLJCK5OdZjMKk9jaTZr+XDksHhf/ObToyxlnlpYgbBTqopH/CDNzPzw89sA3FEUnoBpjfLvdvY2fHrXGK0ZiJ9fiXbB0dWiX5yPO7MLf2k7tw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724114945; c=relaxed/simple; bh=HhhPTqz3ORhvxNiWIIxAFLFHgn8p1aX7qXZOQ9zf1sI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Pq5hAT9Dr5NxnPm1Dl+gHcJSy7xtG/h7q25wmCtKuoFIleIm/Plo1jDD+2yWGkHp45hwXWvFqQ1g8w++SEnGv6vZHhSvKozAwjoq+2HbsDrCvPff/ymMS9RPvZKm+DlRCSgs2gXY1KDFqA87PJm6xDtnIAOsicEgmsuEiG5S8nw= 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=HnfQfpMG; 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="HnfQfpMG" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-201fae21398so28160765ad.1 for ; Mon, 19 Aug 2024 17:49:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724114942; x=1724719742; 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=4FHcP/x+78WtlB0zWFtFC85FvngH6fYB7gYdJxuvirU=; b=HnfQfpMGZlWWWMaMJ7ILgRKVCM9pHI9RoHH91fPcj4/rJEzV20HmUOY70zDX3uavMX T7y0ERwXEWBViIRTnfCCIWPC3hKnbRO4O5qtWC5Ugo9rEDkPg1K/Q9/2UrRW5sLxIc66 Kg959mwmyzs4E9mK00TNuPgFdvBKGISlXQxUvpfdQOhDXpm2Doq3bk3ft47rewqJlAGN erbpKyC8CuqrO75NtPpNDgdDT2K90BJ3aUCEng/IGhwuF8mp3+wcz3Mtke2dvOnCv8tz UFHpoEV/BR922Yv39TnfGrnK8IqUvLbXfdlzqfxR0XkDz9IxehH3ZUCr5C7+0mfX4Puk HocA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724114942; x=1724719742; 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=4FHcP/x+78WtlB0zWFtFC85FvngH6fYB7gYdJxuvirU=; b=eYeqhW56JZm4T2gU0tvDBfO78CheknmlU7e+WgJ5yQOU/kfURy0QYGAEjEXqaPQKtS czY7OYE4gBQo4eFTFdrqk6x2e0i21N1vrLL9+l9l5mCamYlOzeUqzsmxGwZ/D6p72Lle /pZMTtiEd6a0UQzcjQY6+FfPtbo/LJaptdgyOf23A2aAg2J2lZwI5SycwmQ01ndai61S B09bDCXR1RBbZCPGrTfOa//1AKKZ0VrrseDJYzDYXZcLGDmXTOvxnd27fQi1jEXH58NV 0P1W6ydh8Wrv0BO8H2fAcGG7E2T15UXsZkQxFjcZZ4o7qJeSWbi6lMzMqSnA/NmDjB9R cUyw== X-Gm-Message-State: AOJu0YxAPXjesjVDTPuNKNN1ICG/WOa3gcMtSzl7L2d98bXoya5V0PmM xl/RG/PcDIq2LdPHOZjrXlmfLVL7zqzGxLTau4UtJ5DqjeKl6awnnFF5m9zr4+4= X-Google-Smtp-Source: AGHT+IE/A9auW9+BmtC7quRnP+cX63YcTcD7r77PedGGgrVU0IxsTD8IwlovagJIjxc6qMwCD/AVTw== X-Received: by 2002:a17:902:e5d1:b0:202:54b8:72e5 with SMTP id d9443c01a7336-20254b87406mr39200235ad.22.1724114941598; Mon, 19 Aug 2024 17:49:01 -0700 (PDT) Received: from localhost.localdomain ([43.228.180.230]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-201f0300522sm67861455ad.6.2024.08.19.17.48.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Aug 2024 17:49:01 -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 , Hangbin Liu Subject: [PATCHv3 net-next 2/3] bonding: Add ESN support to IPSec HW offload Date: Tue, 20 Aug 2024 08:48:39 +0800 Message-ID: <20240820004840.510412-3-liuhangbin@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240820004840.510412-1-liuhangbin@gmail.com> References: <20240820004840.510412-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 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 560e3416f6f5..24747fceef66 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -651,10 +651,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; + } + + 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 Tue Aug 20 00:48:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hangbin Liu X-Patchwork-Id: 13769238 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (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 C57F319478 for ; Tue, 20 Aug 2024 00:49:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724114948; cv=none; b=sjWKD4q7xr529cPzVNi/1h7waSU2mOoJCd6aj00wN11VbdbrbnkQPpiXhfUMHiZCkgR7ESx/0TKrjPKq81PbSs+9blvj/Au1lxcojJBddY3gQrPKnXoZRianwcWH6VXHSLkwdhzyNcXNoL55+XO6f7HYoJHmXbu1d2+N97/D6KA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724114948; c=relaxed/simple; bh=0s+SKheHmDsntXrpZ41L4KTwsIhFZvohAAJrkM5ibx8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HyrvcYImlRYOdXlbrDidmRf/GEp1PxLkAXbOIy4I7DEWmvmYZT3pmMPcIfmq/cfv0rQ5RB47jTvAq88jrOyqdvo4daXM514ki9hUAFjKCiJ3vE6zFhju0xdQCGQOaA1K7B6hrPWhK6PWLNKkQuK08tp4CakEcZRVfpuHpFAKwok= 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=ObXYXMuC; arc=none smtp.client-ip=209.85.214.175 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="ObXYXMuC" Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-20219a0fe4dso21899695ad.2 for ; Mon, 19 Aug 2024 17:49:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724114946; x=1724719746; 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=fvEsBVaU9vacqW8jEWHgaimLveKbFN8Ava8ep4RfZhc=; b=ObXYXMuCFdN9EjNB7GnMmQWbPk3KRcvIJIIE0mXV8yUfT7OWNQKEIb9CWg4/aFZ0BI 46FwuYJXRLN32fzyEIr8QZc3FD9tFIyKxjmOhaS2JU3fz34BQdc48a07LON813i7Plru uXYdAKef8giwvbeg1l9F/L41g9adtAzv6i3nS2TT9ncaNKa/H0ya/eit7VCKHiVxGPXD 3zM2mIevKORSQztGEiMU7OZxrvoYEDvP+qQF98tTAW+ihEMVALnk7GeoShqDVwU2dgdi 7SjK1ScKfPVAfW/9wNP9lSrFie0utuZR4FOdAUuX0asDOvZBJ2g7kio8MxFFe/FnTTYL bEbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724114946; x=1724719746; 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=fvEsBVaU9vacqW8jEWHgaimLveKbFN8Ava8ep4RfZhc=; b=QTGCAsD5iEV6jec0VSdh7+QZK5OAoAs2R2ZdFEokOQUHBtVOwU4VvzC3ijTrdkfBn6 CS5DCUz+RjuG5pYaZLtx0pmB4DrUQCdah0oK1qQSYvNKfKVwM92M0IX7pyQJGOK3oPMS zKxOAg4d/Si7XvxvqcArDokfmHwF3R1UiOQm/by5J2kAAIr1hUZNgCvCpLpwc7Hd6FAn CrNkffJjZxwEb2MVFFxL1mljyt6Mak+iokn43Boqx+GY1TNtPGQxeODRNe8mle4SuoRW DQfngtVwHtosnyr4NjGeCJOwbC8NyzaWVj6BVybbmT/RuJK7a1AQOlwzu/4G9Kg+1QjM O39w== X-Gm-Message-State: AOJu0Yycpks/TGtAD+DJGD9+IHkHJbtTYwZVHJrMPE9J8UdCVuPZTPtz IonkC/tFTGiKL4puGlC66UfrSisGZ8nk10ThGJmk4WVXPPXWzzsaMMILmq4DDTQ= X-Google-Smtp-Source: AGHT+IGzNdO4WMK/r4TPpAJt3zg9m23EtXpUlrHfuS/iNZYLdK2Zq2FBWPgH/BSlYzSVB/QlAjwgtQ== X-Received: by 2002:a17:902:d50d:b0:202:3469:2c8c with SMTP id d9443c01a7336-2031517c8e6mr11562545ad.40.1724114945752; Mon, 19 Aug 2024 17:49:05 -0700 (PDT) Received: from localhost.localdomain ([43.228.180.230]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-201f0300522sm67861455ad.6.2024.08.19.17.49.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Aug 2024 17:49:05 -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 , Hangbin Liu Subject: [PATCHv3 net-next 3/3] bonding: support xfrm state update Date: Tue, 20 Aug 2024 08:48:40 +0800 Message-ID: <20240820004840.510412-4-liuhangbin@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240820004840.510412-1-liuhangbin@gmail.com> References: <20240820004840.510412-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 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 24747fceef66..4a4a1d9c8cca 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -675,11 +675,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 */