From patchwork Tue Apr 11 18:01:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13208002 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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 41F3CC76196 for ; Tue, 11 Apr 2023 18:03:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230150AbjDKSDC (ORCPT ); Tue, 11 Apr 2023 14:03:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230034AbjDKSCn (ORCPT ); Tue, 11 Apr 2023 14:02:43 -0400 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2045.outbound.protection.outlook.com [40.107.8.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1AD361B5; Tue, 11 Apr 2023 11:02:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=frBUxP1RaKbwP1DmJHW3W0n7b4yxtHHXr/D+hUXYNZCtpmKpWzIHvMSmV44+XBbdrvDrvfEV1J+uXVGf7SmcfYxSVsBeojSPt8flj6GlxcoGHXpRVDgeke7payZVdJX1pOxXqS7gli3nYMQI2fTQR6ZjPGipEvQvy5AELFkppSWMAJtafiQi4zAabd6rtPBLs4gjsgpB1w5Bm2xn8IzGpfXxE6DFLzyC+MPHIKEvmUBHlSGvDs/p8KVRzQu7sytzHYXzQwaTqUPipypzXQ+c5xGzBeLlG2whWHetGOqqzeXP96asVa1jsbEw0VIYhiTyqG2XXXKgeWjdjkGSTlRr7A== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=VP9EEfl5mIhmjubsT9Ff9sFexFj057nS6x8TfZsyEj8=; b=TI4G+iQfnvNtYhAZKBXslop0d38QEgzuN25ud+TXG0OwWxnMPNUxWWMUVlBd5reb6bUvvMDGWSn1vWBI6J+1F0MRYi4aO8wNFq2ZA1IDcjkBVg4qplO8SrCBQGO2woQztjtcQGvC8YTYXj1Z5KGL5VHClc51cj/QFN0ovETTipJdRMmwiayevUub4kFa5MdRYM29uFk9tWNJl1fQoEjOMbhWg+/zGnabeSDkNpCUlVgLG2NoKzfI/TFGccMFuSkOfeYpR1zgv/UP4Tj/cF8T4oUoTmoCxjib1Xa2Rf/XwjvXBrIDEY2KsSKsY3TtzPZjDkUHHUJa+OX9OoSvnC7goA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=VP9EEfl5mIhmjubsT9Ff9sFexFj057nS6x8TfZsyEj8=; b=Q8hWAEyyqzSlD1vqtsnD8nZCtvKdSxfUGOpSvSwnB/IGgkgrWPQNopdjri1f8VA6mHqQOgwlttiJCjeL3uypx6UQoqBnQtrCq3bYq79/eB6mEfXnh1YELaPAqkzr6t9u4NSgKKicfR2eDNSM1/+s1WImY4Upa4XeFinMYmHF+iw= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) by AS8PR04MB7829.eurprd04.prod.outlook.com (2603:10a6:20b:2a7::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.38; Tue, 11 Apr 2023 18:02:28 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::55b1:d2dd:4327:912b]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::55b1:d2dd:4327:912b%5]) with mapi id 15.20.6298.028; Tue, 11 Apr 2023 18:02:28 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jamal Hadi Salim , Cong Wang , Jiri Pirko , Vinicius Costa Gomes , Kurt Kanzenbach , Gerhard Engleder , Amritha Nambiar , Ferenc Fejes , Xiaoliang Yang , Roger Quadros , Pranavi Somisetty , Harini Katakam , Giuseppe Cavallaro , Alexandre Torgue , Michael Sit Wei Hong , Mohammad Athari Bin Ismail , Oleksij Rempel , Jacob Keller , linux-kernel@vger.kernel.org, Simon Horman Subject: [PATCH v5 net-next 5/9] net/sched: pass netlink extack to mqprio and taprio offload Date: Tue, 11 Apr 2023 21:01:53 +0300 Message-Id: <20230411180157.1850527-6-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230411180157.1850527-1-vladimir.oltean@nxp.com> References: <20230411180157.1850527-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: FR2P281CA0186.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:9f::20) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|AS8PR04MB7829:EE_ X-MS-Office365-Filtering-Correlation-Id: 073a089d-5caf-41c9-8658-08db3ab6e9dc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GCZ7OpPBEuvtIHFX6hvvMt8oX382EW8zsGPFk8gNo3oXx3cHDEDgssIwd260haUnErqXrlV8yGtca8hYmvPTi9SppwKuyi9QEG5J5JMsKzbKteMpf89yRbUaFBk47BkrkCZT9f3zUp0/rdV9b8DECV7DXgndy2lDmIKqRAw3Hp2z0+ZaAKE4ikLSPx4nFGp1KSQVHXq/fyd9rT3+h0Rt0fxgnB7Vn9LnivirroVFXXPScEotHpITG8xPiyxHW1LAEMqegD1nXahNqnQqLoKv0m0aJlyan6bE7BArekboNKEnX5KakX3a33eujIjevt/u5Fxu/pIUrGOi7smO1cNGR5kuf9Wk7BvzUKKazctCFFKAo9lmnr2ZHtxQXXWd1PkY9vNblKM6q6KzQb+pSUmioNPPcSPVaGLg3raow9Y2YGNNz7AOuyc4H2YncWfIVOPeVDFboyGElB1Pz1b2+mD/rjkn7X5Kw5AU8HJQSv+lZIS5UMks2IZJ135OdxRuoivh20nfbVXl4Ot+SP9idHSg3ZXy54r/at1lDKJlpnnb/0b2fJdQ7YBlbRZRqlGeF+ZXso/oiBWtjwoA4KjLya7B1blBowDmp/ciavof/Lm06zgQxQ4Nh3J5GaJiHCW0NFAL X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR04MB6452.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(396003)(366004)(136003)(346002)(39860400002)(376002)(451199021)(41300700001)(478600001)(86362001)(316002)(54906003)(8676002)(52116002)(6916009)(66946007)(66556008)(4326008)(66476007)(8936002)(6486002)(5660300002)(7416002)(44832011)(2616005)(186003)(36756003)(38100700002)(38350700002)(26005)(6506007)(6512007)(1076003)(83380400001)(2906002)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: qSsmE8y/XbnDXgJMZSt14+5MPCGIjKOZpAGxQPB4T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M461Twt5I98NiKkHl//Shd6Zu4VZktdhqKYx8mqLo4LsvWokpfqs0mqSuV8eP0O4CllfcnywQxIoXwCtSuGeAuZ84WyyYNbudblakTV1RH6dZ7CwYEqisfNeLz7x5gZFDPMaUZ4/Fp89KjK8dKwcPGydoY6qINLHuLwEmAkpQaPB/MQcmsU2PT11bdsg1uK0SD91cDVg8TOyIPbrvYZ3QqrimmbjNGnb0qm9g35qrAaY+O8gn+LTWYC1CK2v96BTPbB9DKgXB3ORWrGyZbkRFMnH390GuTaiK/7Lxs73MHYV6FKOMAe3zfRkCy3nHf8GmH1CuHZUbCya8QNYNxUtJ8u/RPOlJSos00NIgLjAi/76JPiDlg7ohYdzFg3Z9BwsMtw7eaQJJmbeycSypTVAZonZ++60wrP+wnrAAYv4PLojNWG0DI20S1f+a/4raF6mu44lj2kRfye4WhyxIFmen3ezVYApB37jfNYv9w370bAReLaRzgBg5DqsBCeUQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 073a089d-5caf-41c9-8658-08db3ab6e9dc X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Apr 2023 18:02:28.7140 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 2J2MdSccaAMq9yYyXLvdIY3g2u47oKtmBdxxSUYdxuho/+WLsIggcW5BHhbpmy6VzNARf1aVSU9u0D7wpfv1Qg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7829 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org With the multiplexed ndo_setup_tc() model which lacks a first-class struct netlink_ext_ack * argument, the only way to pass the netlink extended ACK message down to the device driver is to embed it within the offload structure. Do this for struct tc_mqprio_qopt_offload and struct tc_taprio_qopt_offload. Since struct tc_taprio_qopt_offload also contains a tc_mqprio_qopt_offload structure, and since device drivers might effectively reuse their mqprio implementation for the mqprio portion of taprio, we make taprio set the extack in both offload structures to point at the same netlink extack message. In fact, the taprio handling is a bit more tricky, for 2 reasons. First is because the offload structure has a longer lifetime than the extack structure. The driver is supposed to populate the extack synchronously from ndo_setup_tc() and leave it alone afterwards. To not have any use-after-free surprises, we zero out the extack pointer when we leave taprio_enable_offload(). The second reason is because taprio does overwrite the extack message on ndo_setup_tc() error. We need to switch to the weak form of setting an extack message, which preserves a potential message set by the driver. Signed-off-by: Vladimir Oltean Reviewed-by: Simon Horman Acked-by: Jamal Hadi Salim --- v3->v5: none v2->v3: patch is new include/net/pkt_sched.h | 2 ++ net/sched/sch_mqprio.c | 5 ++++- net/sched/sch_taprio.c | 12 ++++++++++-- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/include/net/pkt_sched.h b/include/net/pkt_sched.h index bb0bd69fb655..b43ed4733455 100644 --- a/include/net/pkt_sched.h +++ b/include/net/pkt_sched.h @@ -166,6 +166,7 @@ struct tc_mqprio_caps { struct tc_mqprio_qopt_offload { /* struct tc_mqprio_qopt must always be the first element */ struct tc_mqprio_qopt qopt; + struct netlink_ext_ack *extack; u16 mode; u16 shaper; u32 flags; @@ -193,6 +194,7 @@ struct tc_taprio_sched_entry { struct tc_taprio_qopt_offload { struct tc_mqprio_qopt_offload mqprio; + struct netlink_ext_ack *extack; u8 enable; ktime_t base_time; u64 cycle_time; diff --git a/net/sched/sch_mqprio.c b/net/sched/sch_mqprio.c index aae4d64dbf3f..67d77495c8fd 100644 --- a/net/sched/sch_mqprio.c +++ b/net/sched/sch_mqprio.c @@ -33,9 +33,12 @@ static int mqprio_enable_offload(struct Qdisc *sch, const struct tc_mqprio_qopt *qopt, struct netlink_ext_ack *extack) { - struct tc_mqprio_qopt_offload mqprio = {.qopt = *qopt}; struct mqprio_sched *priv = qdisc_priv(sch); struct net_device *dev = qdisc_dev(sch); + struct tc_mqprio_qopt_offload mqprio = { + .qopt = *qopt, + .extack = extack, + }; int err, i; switch (priv->mode) { diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c index 1f469861eae3..cbad43019172 100644 --- a/net/sched/sch_taprio.c +++ b/net/sched/sch_taprio.c @@ -1520,7 +1520,9 @@ static int taprio_enable_offload(struct net_device *dev, return -ENOMEM; } offload->enable = 1; + offload->extack = extack; mqprio_qopt_reconstruct(dev, &offload->mqprio.qopt); + offload->mqprio.extack = extack; taprio_sched_to_offload(dev, sched, offload, &caps); for (tc = 0; tc < TC_MAX_QUEUE; tc++) @@ -1528,14 +1530,20 @@ static int taprio_enable_offload(struct net_device *dev, err = ops->ndo_setup_tc(dev, TC_SETUP_QDISC_TAPRIO, offload); if (err < 0) { - NL_SET_ERR_MSG(extack, - "Device failed to setup taprio offload"); + NL_SET_ERR_MSG_WEAK(extack, + "Device failed to setup taprio offload"); goto done; } q->offloaded = true; done: + /* The offload structure may linger around via a reference taken by the + * device driver, so clear up the netlink extack pointer so that the + * driver isn't tempted to dereference data which stopped being valid + */ + offload->extack = NULL; + offload->mqprio.extack = NULL; taprio_offload_free(offload); return err;