From patchwork Wed Aug 21 10:50:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hangbin Liu X-Patchwork-Id: 13771220 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 AD2A815FA92 for ; Wed, 21 Aug 2024 10:50:17 +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=1724237419; cv=none; b=qYc8/U4GwFGOMACTClVWca2iipyfbUZY9fGHdRid8hh1Px1f40GR5xtzZ+YZrgYuG8xhwjLpI1CBWVoFE12RTMW9GJPLpVB7AkbX+E6QggUD0j69d5K7Sa4/BI69vTKf7dK4t25z/F/bJHmPD8k2MlYLAJNgPMts6rfqrJfRTD8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724237419; c=relaxed/simple; bh=Zq+0/3Gr2e57AJZa0AMF5OcxcxRIYB7VnkX/NnfF42c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gpPefo6wWTp2zIPbr8mwcp7rV4o7IDxVr2g8fynjTWAjuOS/GSmDCDLUn5tqEh6ow9b6FADqmPeItag5Lm3bs/eC+iFoz2ohwevr8NNPZoh8brUwTMwbtqMDPz0BozR9cyDE6datCT3yLvJavPNsGgFrTMI+WhhgljaeBnQgFCk= 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=BHUROTqt; 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="BHUROTqt" Received: by mail-ot1-f42.google.com with SMTP id 46e09a7af769-7093d565310so4876850a34.2 for ; Wed, 21 Aug 2024 03:50:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724237416; x=1724842216; 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=5gCfqc2cR0PpKpPsbaJjvf5TzqEN3O3X8g14GOIR6FQ=; b=BHUROTqt0CSFzvBQkV6V0m1k+F2ZlRJU5+cNlZ7ASg9ED5TyQjWUupTyzQK1MlcHJ+ EnVN8eBdRePOQjVfoEVcdsJlKVovDWAzSq3yq+v0yrTPUAQjTcXf9dA1mrq9G7OBKdZa bDCVd8qiXpvQDWuSdd9yQXMm+N1pELvq+BmbyPnZO+oXLbfyirdW1QpG7ywy+4+Q57ip 4FWofW8IixXdK4BklIoFxnIM8Q1WLszmrcSokKXIXY6UdYAl1lVfUqn1pZheFRol9tTN GWbc6hgB+PjNtKvYzCpLeDOg6V26oerGR+O2ErV3/SaoLcYD/z/M2AG80kC+G6w+zrRJ MLVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724237416; x=1724842216; 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=5gCfqc2cR0PpKpPsbaJjvf5TzqEN3O3X8g14GOIR6FQ=; b=NCUT830MikaFCXXN1o6XuBf09xG+X6AGodJg3rhIdz/TQJA7JOozFsaheXWi53URQf u357VeJON+xqF2/QlUQ/P0ZD+3Cv322bO4N9YZcJRaN6ddYiDoI2kK9IqY9Ln54qRltP /ARXKg3LqlcUxtsPUBoIplMegsia1AHrcYniyHn++Wx2hdwcx0g+HEIsPcayRWknJeaB fulJ4PEWGC3CEd7o1ylnzo5mBPo3iFG0k9hZb/uSkCfzZHnMYRiUqN76uGO1vMcdEx2B cDwkLCDcw+Iqk1kKuLG1CwtXprjKgPabceVaMu4VmY/Xa0ErJFyEFKso/RDxkYpNQYxB tW8g== X-Gm-Message-State: AOJu0YwVzklDxcsAIOitn5ElYUFQIEDljU4Fmw7WBgB6DcvsR3j8UIQj 6hQhDvDMLjYNCCdBKzjF5lK8da/gXdXgHBE1/GICkAqIVnHEWG2UTtrMwG5JeJU= X-Google-Smtp-Source: AGHT+IEHhImaH/xn4Kfl/bEXPeBSR9N8v+DAhgGVwWA+IsdFL4OIoZEiF/AxiKDchr9nV0cEBxJ4EA== X-Received: by 2002:a05:6870:2116:b0:264:9161:82e9 with SMTP id 586e51a60fabf-2738be910acmr1621666fac.41.1724237416188; Wed, 21 Aug 2024 03:50:16 -0700 (PDT) Received: from Laptop-X1.redhat.com ([43.228.180.230]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7127add6db6sm9652521b3a.20.2024.08.21.03.50.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Aug 2024 03:50:15 -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 Subject: [PATCHv4 net-next 1/3] bonding: add common function to check ipsec device Date: Wed, 21 Aug 2024 18:50:01 +0800 Message-ID: <20240821105003.547460-2-liuhangbin@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240821105003.547460-1-liuhangbin@gmail.com> References: <20240821105003.547460-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 Signed-off-by: Hangbin Liu --- drivers/net/bonding/bond_main.c | 47 ++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 13 deletions(-) diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index f9633a6f8571..fe10ac66f26e 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -418,6 +418,38 @@ 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) + 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 @@ -595,23 +627,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 Wed Aug 21 10:50:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hangbin Liu X-Patchwork-Id: 13771221 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-oa1-f44.google.com (mail-oa1-f44.google.com [209.85.160.44]) (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 77BD6192D96 for ; Wed, 21 Aug 2024 10:50:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724237423; cv=none; b=PRkJTs7fJkGdndur6dbGWpZriSTlU2Um+00bRInpuJcwVO4DJ/S1Xs/tS9VFseeMBU07o7VCukJ5MF0HxnjHobtduL6QWxHlmNOhWr70AAja0edTLr5ZPXOvnMhkmknlLvZcbVssIEIFegptrWWXUPxeAZO0CDl7TSIKpdFiZFY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724237423; c=relaxed/simple; bh=l5Htu+4YK0/DnPXh3keN+cEExP+NgFStDvf0ACtHRVU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NRO6snxa1+78ft+hcTvV8dDuuCaSvtBa+I7H8s7jYOr9uhSozfz0nhE2O3+n0T/c8pwHJjPgznbtAT7Pi8d90drZ7JW9GuOq6UQ8GtEKuEQh9YTnI1YDoZ0GIFuEg8EhXkk9OgXQQq1EinxtY2Fv08tl9J5UD/oYxa6MqqBIueM= 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=H2yMafX6; arc=none smtp.client-ip=209.85.160.44 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="H2yMafX6" Received: by mail-oa1-f44.google.com with SMTP id 586e51a60fabf-2702a00aad4so3103771fac.1 for ; Wed, 21 Aug 2024 03:50:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724237421; x=1724842221; 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=VSH8K/D1F3FbpQ53Zg061gb48/Lg7Mg1AaeNfy/4IKA=; b=H2yMafX67duokndCIkPBdBioadndfkNzHTXwv03gqS+8A8QtBAD4gzVB0eftRrwXoB 8qk9ql8nexGxWH4ulmMVOgCEq5yRZ9J3AVU/1sMgz3CaFK7oBr48ithUClEcBAk/yhDh eSnp2A6tBgVi8FMcz4wp5+l0e72wu0+IjmKmYKt5jRe6RURn6qcsnP+k2uNHDH6elwy8 Dx03NwEzT/Vjy8jsKH9JmwYCLfpEeyfu8b3pSj0i+wYMSsfYxf0xrV1nQ2T5rI3Ih1a4 0FGnl77QUgtqF1mYswLvk83gqvHdbwl46KuVG3FnEYH6OQm6v1edc9EJCTBe7dkfJ+Op +2hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724237421; x=1724842221; 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=VSH8K/D1F3FbpQ53Zg061gb48/Lg7Mg1AaeNfy/4IKA=; b=iEixgZOgZLELimw5Rmj1hlN40+i8KwZ/C54YlARvXBdXqBxL0gAZgA4E0++FnVZGvr XuwAVESXfwsmA/h/ZanAeHEEuxMbkSmDH4jfCnuVhk7c/YUv654RyYuFdjQ2gpLBoqT9 gDbJJ2lXETHKevT0XOoztYokD3y3EXA1DzwitUG14u/OnJTP+9NAiEA0pZaZ+V3iiGNh rXVNSEwFrSV27KzT6LHpbM4QhYfZuYY8FdjGq7AW19cp7bdBbDfH4NU2C/qVJsjpAk4I sBKfK+YRQJuHF/MmSX8abxWaj1BmVFf/R29fNyVquEAFbTaKQi7/NxR9hjcfYiKsuQUX dUNQ== X-Gm-Message-State: AOJu0Yz61paMGPuZxbnOKgiSvPee74yioHf9CBS2Bg++k2pza3hDlRGs LdZosCbz5OSACR5etm0MwhLrlfSsm9VHQInzgznpPnqUKzE6KMP4bYjUzjvRsw4= X-Google-Smtp-Source: AGHT+IGcoGZSm0j66xHeh5I/XpHaF9NpKnulDNB/5oRQ2nBor4inlNLWRH7CdMmjFZMybVZVU0Mnmg== X-Received: by 2002:a05:6870:d14f:b0:255:2e14:3d9d with SMTP id 586e51a60fabf-2737eeb59d1mr1947522fac.5.1724237421153; Wed, 21 Aug 2024 03:50:21 -0700 (PDT) Received: from Laptop-X1.redhat.com ([43.228.180.230]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7127add6db6sm9652521b3a.20.2024.08.21.03.50.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Aug 2024 03:50:20 -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 Subject: [PATCHv4 net-next 2/3] bonding: Add ESN support to IPSec HW offload Date: Wed, 21 Aug 2024 18:50:02 +0800 Message-ID: <20240821105003.547460-3-liuhangbin@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240821105003.547460-1-liuhangbin@gmail.com> References: <20240821105003.547460-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 fe10ac66f26e..2fffc5956545 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -650,10 +650,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_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 21 10:50:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hangbin Liu X-Patchwork-Id: 13771222 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-oo1-f50.google.com (mail-oo1-f50.google.com [209.85.161.50]) (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 E9F4B166F04 for ; Wed, 21 Aug 2024 10:50:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724237428; cv=none; b=VAXl5QbBRT3HuW2+s1GjgXiNBDjI++LqmN6+7vobomiVNuyL4xM3D8fJWEFCw31d9WDgCJy0GV657hM3B+McSDXiWTZuZ2o8kPyjy4UFeu5WvIR4enL9YJe/p25h4eU+Wnv8uxrVt293bE2ZB08hunKuF7yRXeWkqJ+kRu5grbE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724237428; c=relaxed/simple; bh=op/n4zpte/oz35ANwLNxWsnhnTE/6WXRxDYlxzLTbaM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sT8LPcV3NPMG9RjjkL/aBQzQLV5CTpM/8T+VcHvgGDgA/TFC0QjjfBWv8h9gM0mq5aivyyaQshMRYQUPTDE04yAF4hBoAKf8q6uSIHAi4wYWuGmyp+swVoGuecU40pS/+8ctddo+SRc9Kp+8A/I9MpSfTChndner7XaXAaMHHFw= 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=Q6Qnkxuo; arc=none smtp.client-ip=209.85.161.50 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="Q6Qnkxuo" Received: by mail-oo1-f50.google.com with SMTP id 006d021491bc7-5d5f24d9df8so3428937eaf.2 for ; Wed, 21 Aug 2024 03:50:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724237426; x=1724842226; 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=DMKxbS9x+mrBqvRfcgMerk1mhSE5hvUdcOBzhbHf9TI=; b=Q6QnkxuoVVye/cq8HpZA4wKNtNxS98pt6CoOmMxDE74By4NzwBRrIB0tnawh6WGUjc m31Iy6iTbf7k+uS67Qk7iZQuU/eNBnMSHOLO1OD1+2a/CYQ6/fxWpDTw/7FFkgJC5fgN iZdmnPpgGmiTwAmQG91r6R/Qhp+LVNomsa7H1NwPobmeTiEMfCAentczJzs3PHk8p1Mv PflJ4Ke+YHP2Zl6AlCBR4p2M5BmO62uRdP9s04o060EZw4i4PBujM68D7klYV1rnoBrO pemygJcEe5jLl8i5dqXMVs7i5dQF1tPnRuAJrfYAo4oNVuhBncNrnor+XWvW93fZchrx TuCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724237426; x=1724842226; 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=DMKxbS9x+mrBqvRfcgMerk1mhSE5hvUdcOBzhbHf9TI=; b=D4wqMg9XHd336W49jeqGRUniB8jtWX3a6UznpyB/MD+Ux6qo2BR+w3f7T9GWb1CufV HmaVIbBD5xDJFKBuVl+Chr4xH/gaY0lXs+rK6LmhyWQoZ7aLNkG4tgsoyHmhvZgoACe5 zeXnByaamcctmzZX1t1HWdmkG6PVrsdF7apwfGO2c5DUWhRfzOsxYRV2UqUQkZSguG6U tV6pCcjuTBnZ3CMVvgtSPtH/9uS4B8fqzQ7RKZKu+8cQvwvL5+wLm6Ix7FsXO/Si6LuI dEJ4IILstCffpwsqCtxE+aWImIAiN+Rwpu/gsOfvsKKz/McXhk9WoBGz1MhK7H2Pmkq0 cD0Q== X-Gm-Message-State: AOJu0YyTI1T51KQom4M1anOU2RSRCH9nF0RVrONcg6ypxaPKENQJr3fF 5Q+WQjqFmFXu0BXaSzRyOxmWMAlB6eOVD8dFhawpb6LlH9EzwQlTQowSoRI1nWk= X-Google-Smtp-Source: AGHT+IFy9RpkzMPUkvpZyqWmjoc2nYZAKk7bXtz1vjTbLJveyZC3OyzBtXRjqkHWL7hOl1K87KO0EQ== X-Received: by 2002:a05:6870:e9aa:b0:259:ae64:9234 with SMTP id 586e51a60fabf-2737eef29ccmr1787465fac.13.1724237425626; Wed, 21 Aug 2024 03:50:25 -0700 (PDT) Received: from Laptop-X1.redhat.com ([43.228.180.230]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7127add6db6sm9652521b3a.20.2024.08.21.03.50.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Aug 2024 03:50:25 -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 Subject: [PATCHv4 net-next 3/3] bonding: support xfrm state update Date: Wed, 21 Aug 2024 18:50:03 +0800 Message-ID: <20240821105003.547460-4-liuhangbin@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240821105003.547460-1-liuhangbin@gmail.com> References: <20240821105003.547460-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 2fffc5956545..e4e73664cd35 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -674,11 +674,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 */