From patchwork Fri Jul 2 14:26:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taehee Yoo X-Patchwork-Id: 12356261 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6AE9EC11F68 for ; Fri, 2 Jul 2021 14:27:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4EB78613CB for ; Fri, 2 Jul 2021 14:27:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233132AbhGBOaL (ORCPT ); Fri, 2 Jul 2021 10:30:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233117AbhGBOaL (ORCPT ); Fri, 2 Jul 2021 10:30:11 -0400 Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61C1EC061762 for ; Fri, 2 Jul 2021 07:27:38 -0700 (PDT) Received: by mail-pg1-x52d.google.com with SMTP id f5so386994pgv.3 for ; Fri, 02 Jul 2021 07:27:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=oovjBCYEfKr8UlBHknq0vS0WePZ568uyDVDCFtyxl6U=; b=dYOpwlETabkwpkQuXeY23if5nwRocWRv3gHoI07rqZf+uF/LTHmsVT79YAnnF6x7YJ nX81jiaJT0Jg0+AB5L7bfpNT/EvcvScJbeLbc985rjOi9wleAQPQWqAopq9t2yxBxVWC JfDM0itO6IVFpj2kPorYxxsZGojxgVlpkaKzJMyvkFxvMKzR4+xpK+S8elG928TKXu8e WwTzcR890M5gzO7dNE/BmH8yXkWuZdl5qE5qrvf886oyzoj6oC4Ugo1JI4UTd/Jbmcp2 5NygZl954z6c9nuFhMXyhOKxJndPADDFIugLXhJP9bSZ4d1VCGFNTn7Ww9bzTgRaWYUP 9FVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=oovjBCYEfKr8UlBHknq0vS0WePZ568uyDVDCFtyxl6U=; b=iNdCTXa0TWywNHLk7jh90tiSt8ZItq+8G7dPhcykZsQXioPaWJ/P3lBV+l4eDOovVI GYQQRFeZuMQFe/y4dQOE0zYkQxMJBrI6G3MK7p14hUlufJMd/L1ed9MTlm+0GvFiGlKg reibFs0sQnk8TeKV9mJ+BqDvo0hKpertGTDYngxEpTqEOET/kBPzTX0tdVWJRlEqj0FW BMPr2jKv9ceHM9+21Tg/NPD5K+IflV3UhRCbiuokYev0uMP1fshqWl33aKmzfnq2+0Nz UmCICI2u/H9XKtM4i5Svn64ijPcTaDLt7krwe/37MIGgfh/7QP3dys1VjOhW2VDq/79I Hw/w== X-Gm-Message-State: AOAM5321gA5t7izhP7fWvN5gvywqLIePUqAffd2J0EKzk/TSaPYvlh4d SQBoIdZIUVraEe0CB/Y0jP1aywMvyvaFFQ== X-Google-Smtp-Source: ABdhPJz8TRzk5u4A6yenNi/OyzI8ih0TzlGMMdtJUrwP6B0rSgLvy1Z2Thmm0W/bolGKQdkou3kZiw== X-Received: by 2002:a63:170e:: with SMTP id x14mr300599pgl.452.1625236057950; Fri, 02 Jul 2021 07:27:37 -0700 (PDT) Received: from localhost.localdomain ([49.173.165.50]) by smtp.gmail.com with ESMTPSA id nr12sm12683747pjb.1.2021.07.02.07.27.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Jul 2021 07:27:37 -0700 (PDT) From: Taehee Yoo To: davem@davemloft.net, kuba@kernel.org, j.vosburgh@gmail.com, vfalico@gmail.com, andy@greyhouse.net, jesse.brandeburg@intel.com, anthony.l.nguyen@intel.com, jarod@redhat.com, netdev@vger.kernel.org, intel-wired-lan@lists.osuosl.org Cc: ap420073@gmail.com Subject: [PATCH net 6/8] bonding: disallow setting nested bonding + ipsec offload Date: Fri, 2 Jul 2021 14:26:46 +0000 Message-Id: <20210702142648.7677-7-ap420073@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210702142648.7677-1-ap420073@gmail.com> References: <20210702142648.7677-1-ap420073@gmail.com> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org bonding interface can be nested and it supports ipsec offload. So, it allows setting the nested bonding + ipsec scenario. But code does not support this scenario. So, it should be disallowed. interface graph: bond2 | bond1 | eth0 The nested bonding + ipsec offload may not a real usecase. So, disallowing this is fine. Fixes: 18cb261afd7b ("bonding: support hardware encryption offload to slaves") Signed-off-by: Taehee Yoo --- drivers/net/bonding/bond_main.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 7659e1fab19e..f268e67cb2f0 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -419,8 +419,9 @@ static int bond_ipsec_add_sa(struct xfrm_state *xs) xs->xso.real_dev = slave->dev; bond->xs = xs; - if (!(slave->dev->xfrmdev_ops - && slave->dev->xfrmdev_ops->xdo_dev_state_add)) { + if (!slave->dev->xfrmdev_ops || + !slave->dev->xfrmdev_ops->xdo_dev_state_add || + netif_is_bond_master(slave->dev)) { slave_warn(bond_dev, slave->dev, "Slave does not support ipsec offload\n"); rcu_read_unlock(); return -EINVAL; @@ -453,8 +454,9 @@ static void bond_ipsec_del_sa(struct xfrm_state *xs) xs->xso.real_dev = slave->dev; - if (!(slave->dev->xfrmdev_ops - && slave->dev->xfrmdev_ops->xdo_dev_state_delete)) { + if (!slave->dev->xfrmdev_ops || + !slave->dev->xfrmdev_ops->xdo_dev_state_delete || + netif_is_bond_master(slave->dev)) { slave_warn(bond_dev, slave->dev, "%s: no slave xdo_dev_state_delete\n", __func__); goto out; } @@ -479,8 +481,9 @@ static bool bond_ipsec_offload_ok(struct sk_buff *skb, struct xfrm_state *xs) if (BOND_MODE(bond) != BOND_MODE_ACTIVEBACKUP) return true; - if (!(slave_dev->xfrmdev_ops - && slave_dev->xfrmdev_ops->xdo_dev_offload_ok)) { + if (!slave_dev->xfrmdev_ops || + !slave_dev->xfrmdev_ops->xdo_dev_offload_ok || + netif_is_bond_master(slave_dev)) { slave_warn(bond_dev, slave_dev, "%s: no slave xdo_dev_offload_ok\n", __func__); return false; }