From patchwork Wed Dec 23 14:45:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 352261 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable 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 0BA09C433E0 for ; Wed, 23 Dec 2020 14:47:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C710022482 for ; Wed, 23 Dec 2020 14:47:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728068AbgLWOq4 (ORCPT ); Wed, 23 Dec 2020 09:46:56 -0500 Received: from mail-eopbgr00126.outbound.protection.outlook.com ([40.107.0.126]:61785 "EHLO EUR02-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727207AbgLWOqz (ORCPT ); Wed, 23 Dec 2020 09:46:55 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JKy/+dUC3+YTvLS5UTybgC0Ly0qcAtHgoHh49hNa1ndEyd6zOY4MfD+mTh/fpa9WFI8WerNdDYro4D7GtyNyVSI5OtPuutGa/AEEZ0JKhCcXTiGXTn1TB02qZmDcP5Bx7RgkL0i9BWLORUP8/8Dc57U83tMczC9bEidNvT55d4HX5sirASHBHrstik42C9XnMryY2gwccReQ735JYS2P2qWePasP2+JjBW/YIM+6EhDGYhmW8qKmyAZYZdxDV/Q0YVBjcGxp2jaXzv0Lvx46zUkeGLEd/tDfcqKS2+9E3dn33TlaoCwmdGDyT1TEuwsBzGHw9rHftBlV7JrFOXsnzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Bsz2QdlwY8mvIdkvF48A+vw7nVfJnuGotMo6dZ2v9CQ=; b=WtHdHZe6XtfLbZdSEKREw5bZZhFhejiKhBZZIu81TZfYxK0y4ShZTLKAewnU0Nrvtw2OCVTAHZrwmnDivmqFO5h7rOwl3HKSErbCCTt0FZZPxqJ0BERAZJaC3JPjWYwEKSjl/SNbQ+4wlxf1Bjpt3d4QPoNMW4lWryBuU9Ei50lVR1eXBWpLJ9P6O29ykVxI17ke5tIkgleAB+otG6Qn8hng7K3ZhJCJSTygKls4zJLcLBaroy8EzgJ9GSnG2hXTajWhSvYUsGdrSwfbmgXBEogS5eD7mAQNPRp4za9gwyCg9rU2S89iH5GYIzp1QcQX5kofbEG3bUAjtiBNaqSkww== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=prevas.dk; dmarc=pass action=none header.from=prevas.dk; dkim=pass header.d=prevas.dk; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=prevas.dk; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Bsz2QdlwY8mvIdkvF48A+vw7nVfJnuGotMo6dZ2v9CQ=; b=kQC/kuvDLB3Jq1/eaAdPj19q1U6Vm9+OOfyXYhq2UeP06WyZODHyI99/Be5Og9LO0fn77NWOUZT1gCLs2ZRNtGMEmnAj4IrheWuBlrO+aa1u/SCWsrvqnpK6gxjPpsSv6PAvoQOlJ5E8T37SWMgYzOehLn5018MoeeA9OyEtnkQ= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=none action=none header.from=prevas.dk; Received: from AM0PR10MB1874.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:3f::10) by AM0PR10MB3057.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:162::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3676.33; Wed, 23 Dec 2020 14:45:45 +0000 Received: from AM0PR10MB1874.EURPRD10.PROD.OUTLOOK.COM ([fe80::9068:c899:48f:a8e3]) by AM0PR10MB1874.EURPRD10.PROD.OUTLOOK.COM ([fe80::9068:c899:48f:a8e3%6]) with mapi id 15.20.3676.033; Wed, 23 Dec 2020 14:45:45 +0000 From: Rasmus Villemoes To: netdev@vger.kernel.org, Horatiu Vultur Cc: linux-kernel@vger.kernel.org, Jakub Kicinski , "David S. Miller" , Rasmus Villemoes Subject: [PATCH net 2/2] net: switchdev: don't set port_obj_info->handled true when -EOPNOTSUPP Date: Wed, 23 Dec 2020 15:45:33 +0100 Message-Id: <20201223144533.4145-3-rasmus.villemoes@prevas.dk> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20201223144533.4145-1-rasmus.villemoes@prevas.dk> References: <20201223144533.4145-1-rasmus.villemoes@prevas.dk> X-Originating-IP: [5.186.115.188] X-ClientProxiedBy: AS8PR04CA0142.eurprd04.prod.outlook.com (2603:10a6:20b:127::27) To AM0PR10MB1874.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:3f::10) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from prevas-ravi.prevas.se (5.186.115.188) by AS8PR04CA0142.eurprd04.prod.outlook.com (2603:10a6:20b:127::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3700.27 via Frontend Transport; Wed, 23 Dec 2020 14:45:44 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3c23f2c2-eb75-4082-e676-08d8a7516dea X-MS-TrafficTypeDiagnostic: AM0PR10MB3057: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EnuZOFsbU/AwBRACNeZITmeGh/6PWotF9gN9iEzwGJ704zqrYSmBJo+tJP4wkdWO8vDNvGfdTHjbwlEcM5YBAoU9AohirVeg8QAOIW16EHdCFHeBWUc5Vpc7YIg2QNGWopa0GwbTA5M+Ya8lUXYspVB5EMTNE1qwIzGxAbahX4+Exis+wGJMDI2zQoM6zpT/GPmNu9yfErkz6ZkrtynjvA6gYiD6EGeCSzyPUvGOI1AlTGwv2NVIWDlViKL85uXd9s4RjhByk30tpjE5/YTuNDU28qjQXKp6C02y4Ji2iufMfg0QuKvC38SNFUj56e6EM+8H8IlOrgJhTW2SZDKSq1Uqkwc/Dn39bI6V5DhC80lPfSIAPczA5PLkHxGLiovTWtFRBpbqhWyEcKAg4hBQfg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR10MB1874.EURPRD10.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(366004)(396003)(136003)(39840400004)(376002)(346002)(54906003)(4326008)(6512007)(6486002)(107886003)(316002)(16526019)(5660300002)(26005)(66476007)(8676002)(66556008)(6506007)(83380400001)(66946007)(186003)(52116002)(2616005)(6916009)(6666004)(44832011)(1076003)(86362001)(8976002)(36756003)(2906002)(8936002)(956004)(478600001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: /qcgJVilanVLVsp0fObxz6qXkeSsKkizvhRctMAJFiP/GclyB9d9I9zHxTS8apO+4MqczuoShg2SY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Tenant-OriginalArrivalTime: 23 Dec 2020 14:45:45.0476 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: d350cf71-778d-4780-88f5-071a4cb1ed61 X-MS-Exchange-CrossTenant-Network-Message-Id: 3c23f2c2-eb75-4082-e676-08d8a7516dea X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: sWcwvSGisxj2xt0P48t9NDjpn2P9Fig6N2XheE2Vy4B05LyFEQ+/9fM6mq+K9Vh6biUzTVrlxJ4WhkwkGcLCe3/1eu56qc7g0EKg8rSkPB0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR10MB3057 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org It's not true that switchdev_port_obj_notify() only inspects the ->handled field of "struct switchdev_notifier_port_obj_info" if call_switchdev_blocking_notifiers() returns 0 - there's a WARN_ON() triggering for a non-zero return combined with ->handled not being true. But the real problem here is that -EOPNOTSUPP is not being properly handled. The wrapper functions switchdev_handle_port_obj_add() et al change a return value of -EOPNOTSUPP to 0, and the treatment of ->handled in switchdev_port_obj_notify() seems to be designed to change that back to -EOPNOTSUPP in case nobody actually acted on the notifier (i.e., everybody returned -EOPNOTSUPP). Currently, as soon as some device down the stack passes the check_cb() check, ->handled gets set to true, which means that switchdev_port_obj_notify() cannot actually ever return -EOPNOTSUPP. This, for example, means that the detection of hardware offload support in the MRP code is broken - br_mrp_set_ring_role() always ends up setting mrp->ring_role_offloaded to 1, despite not a single mainline driver implementing any of the SWITCHDEV_OBJ_ID*_MRP. So since the MRP code thinks the generation of MRP test frames has been offloaded, no such frames are actually put on the wire. So, continue to set ->handled true if any callback returns success or any error distinct from -EOPNOTSUPP. But if all the callbacks return -EOPNOTSUPP, make sure that ->handled stays false, so the logic in switchdev_port_obj_notify() can propagate that information. Signed-off-by: Rasmus Villemoes --- net/switchdev/switchdev.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/net/switchdev/switchdev.c b/net/switchdev/switchdev.c index 23d868545362..2c1ffc9ba2eb 100644 --- a/net/switchdev/switchdev.c +++ b/net/switchdev/switchdev.c @@ -460,10 +460,11 @@ static int __switchdev_handle_port_obj_add(struct net_device *dev, extack = switchdev_notifier_info_to_extack(&port_obj_info->info); if (check_cb(dev)) { - /* This flag is only checked if the return value is success. */ - port_obj_info->handled = true; - return add_cb(dev, port_obj_info->obj, port_obj_info->trans, - extack); + err = add_cb(dev, port_obj_info->obj, port_obj_info->trans, + extack); + if (err != -EOPNOTSUPP) + port_obj_info->handled = true; + return err; } /* Switch ports might be stacked under e.g. a LAG. Ignore the @@ -515,9 +516,10 @@ static int __switchdev_handle_port_obj_del(struct net_device *dev, int err = -EOPNOTSUPP; if (check_cb(dev)) { - /* This flag is only checked if the return value is success. */ - port_obj_info->handled = true; - return del_cb(dev, port_obj_info->obj); + err = del_cb(dev, port_obj_info->obj); + if (err != -EOPNOTSUPP) + port_obj_info->handled = true; + return err; } /* Switch ports might be stacked under e.g. a LAG. Ignore the @@ -568,9 +570,10 @@ static int __switchdev_handle_port_attr_set(struct net_device *dev, int err = -EOPNOTSUPP; if (check_cb(dev)) { - port_attr_info->handled = true; - return set_cb(dev, port_attr_info->attr, - port_attr_info->trans); + err = set_cb(dev, port_attr_info->attr, port_attr_info->trans); + if (err != -EOPNOTSUPP) + port_attr_info->handled = true; + return err; } /* Switch ports might be stacked under e.g. a LAG. Ignore the