From patchwork Mon Aug 7 22:09:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13345251 X-Patchwork-Delegate: stephen@networkplumber.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0D30217736 for ; Mon, 7 Aug 2023 22:11:26 +0000 (UTC) Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2045.outbound.protection.outlook.com [40.107.7.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71575E1 for ; Mon, 7 Aug 2023 15:10:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=f4qaWym8CYj7sreyBPeMXQBUAs+i9pptYkUH13BhIx7g3OMMK4465aivBnipaqgPuRUXEf0k7E/Z7RH+d323IPiq60//rXxAkTCYo9AqlqsTOszO5WNT84jvSfSluSTHk+HZBxg99/h/14KzqMtLradF4lNvu4yFGcjETEe9m1TFA/lev3KDm999VMbNduGD8203yFffvgsWJ+J2OsV4xhA0KouFAAH2p6v6LWBAT0akJ3RCeAvz6HyGOvLR6ZqNrsbTMRke29xiJoCetZeDeIro1MHIlzFt2lemDv115ubFydJlBzGixk7VCZHoqpxkJOiecCgIGqw80RpwLqhw0w== 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=MGvmgjKqjRa5k+atW6Wf1sHxDAtT/axLJz5O0Zgd1Cc=; b=MijkQUbMtM0CNHOq4KdsIJxMzzgW9CJ9ZeI1kjXXY5scF/qVDpBJ9sfaN6bWFlCTkGObtPZzPDy/HjkLKWYY7s5+Bxj5jZ3OwhqZ1RFbgBC+N/HYc8DbXR7kSbT+6sAH2AdoHN3naskX1QTQSMyXuqkxgOeKL1I+6LYzU05zrHi/8dbT2u6jvN5hmfxKQKyGO6z8cGV+/ukQq3B0J6l+1OG9by08pLqItDC0QdQ62DpROaPGyZ/7yRef9w/2fQpkf4ofONptT1F2ZHwcGD6C/ODe+1iyOh74pBvk7lX+qpjPtZdcVA1xlIUiZoQyNDEPrKrOWkAhrbHm314BGWM5Tg== 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=MGvmgjKqjRa5k+atW6Wf1sHxDAtT/axLJz5O0Zgd1Cc=; b=CCKZH4E25SJSSkfDqvEgyldJYPiX1HNXxytFQ3EhJaVG61srTJur9YCZLpJGicyk6SZxIM64+z2zvPgHD6iNp5IydBVMkdiRVeNIjUPTYRvbE5g8mhhfS8IObzDR8bzIN+pKkGGgz049v2ozHrjh00Xu/YBpNrq4FmyVY3kg0FQ= 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 AM0PR04MB6963.eurprd04.prod.outlook.com (2603:10a6:208:18b::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.27; Mon, 7 Aug 2023 22:09:47 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::d4ed:20a0:8c0a:d9cf]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::d4ed:20a0:8c0a:d9cf%6]) with mapi id 15.20.6652.026; Mon, 7 Aug 2023 22:09:47 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: David Ahern , Stephen Hemminger , Vinicius Costa Gomes Subject: [PATCH v2 iproute2 1/2] tc/taprio: don't print netlink attributes which weren't reported by the kernel Date: Tue, 8 Aug 2023 01:09:35 +0300 Message-Id: <20230807220936.4164355-1-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: FR0P281CA0062.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:49::23) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|AM0PR04MB6963:EE_ X-MS-Office365-Filtering-Correlation-Id: 7ba896e5-2361-4bd2-efcc-08db97930320 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gVHKRL+BAXKW7AAwZDwV25LksEjaC81iln5pS72jOF4t/DUTraZDbwnuiV+D/0k0AyyStWKzGyKwsyiLEpc2+k6T1UBJ/xihSHv4VM0NfeG0s/reaipxQmNA+Tsww2xoIH3XCGJbHJKWiI6aWzvQebYI2tc14dW+l3ICKnJcntQtia5RJuXnNfFJndtvebsUvNFWeMNgpHsvMdAjEncpHPNsIYOrWhQKcfjVfD/IjAqhM5WGSeYnbuBIHjIvB7W0mPbrL/xQAM3/KbDzb0R0LPeMbm05YhxU59xjrYLczkmCfVzlzLXOihjvFhIwOpdk5gl+0TYXIObfE/24fwU6UJzLxfaozjCYYXumpMFPuJ5HTGTzEW9Og0X0xl8YK1p+yZQzpkKUgiRJoed+DZMaZcz5Ug1dWzJ0Q4Qmk6xNPVBsISMaI+KaFJ9TKnjfu/02vEvSw9lcWbb3J9BIUfBAVr703ppJpvbqBMzzpYaUiEixRtreIIko6VbsaiXvC5SZbB59jkY7XZkrrVTPN5oES07skBtAl+2T5cIXWQeNP7RvdoKGETDA92WGmoSe77tKUzCBFG7wE3vWTjpFmqIH3OEEEruSq/+eoqRKt3MUM6M= 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)(346002)(376002)(39860400002)(366004)(396003)(136003)(186006)(1800799003)(451199021)(1076003)(41300700001)(26005)(2906002)(44832011)(83380400001)(5660300002)(8936002)(8676002)(2616005)(478600001)(6916009)(86362001)(6506007)(316002)(38350700002)(38100700002)(54906003)(6486002)(66476007)(66556008)(52116002)(66946007)(6666004)(966005)(6512007)(4326008)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: VAF7oKQsE9jAFpETzxSLcX1424NfWEHPRKM2DiuKxS7UcTe6OaOvyrJBvrV4ZtYhzHqDOK06JSOc8JPbArARNlyJR+jOawQCitVa4eXVHJGXleRhzolig0NXdtL7uE8BN/xzqucBLjVs6FXLk3lWPmg5YU7XV1D4GyG/EKbhgfQUROZwKmtr6bjVjXRyTCaFm1g9yNHwBNUJ69flsHkrde7hqowLnQw5Edh/WSskYUodlzy8yfxdqcZje24vbZL6IimIuACildabDjNEXIFYm1aQFotfERWpG1EqBu9bnQfnHZS2mBXlmb3ceNMJgt5q1nII5DhRBTBrzGsG8zYpKdDmGoTr6r9uGmkJEa2i1NJSI7naxAED2QDqd6xSctTtfIGEebrWPbiCTBN+ocJ/umzN8x+BLro7qgci3WYvnuIzijdkDgJEXbHMPBMqx9GfniQtG1gX7+mbWC5WKyIlhWaXfYyzKq2yl/XW2rCZ3JYZx8WZbVixTKxq6Z3WhHw0Z0J+upUEna0YQL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HArjt+8g5URCg7srgakk7y/2EWER8BG5H3uYMaVg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7ba896e5-2361-4bd2-efcc-08db97930320 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Aug 2023 22:09:47.2935 (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: SgGX8/q+bRMaWaAj1fggqlPiiakfF9w8McUyKlV5kkTXHR0YuaK1HAVTxz6TMwhQDbXk4/LSUbhzC50+TQSKww== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB6963 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: dsahern@gmail.com When an admin schedule is pending and hasn't yet become operational, the kernel will report only the parameters of the admin schedule in a nested TCA_TAPRIO_ATTR_ADMIN_SCHED attribute. However, we default to printing zeroes even for the parameters of the operational base time, when that doesn't exist. Link: https://lore.kernel.org/netdev/87il9w0xx7.fsf@intel.com/ Fixes: 0dd16449356f ("tc: Add support for configuring the taprio scheduler") Signed-off-by: Vladimir Oltean Acked-by: Vinicius Costa Gomes --- v1->v2: - move variable declarations to their respective "if" blocks - use "nla" instead of "tb[TCA_TAPRIO_ATTR_SCHED_CYCLE_TIME]" tc/q_taprio.c | 89 +++++++++++++++++++++++++++++++-------------------- 1 file changed, 54 insertions(+), 35 deletions(-) diff --git a/tc/q_taprio.c b/tc/q_taprio.c index 913197f68caa..6250871fb5f2 100644 --- a/tc/q_taprio.c +++ b/tc/q_taprio.c @@ -416,14 +416,11 @@ static int taprio_parse_opt(struct qdisc_util *qu, int argc, return 0; } -static int print_sched_list(FILE *f, struct rtattr *list) +static void print_sched_list(FILE *f, struct rtattr *list) { - struct rtattr *item; + struct rtattr *item, *nla; int rem; - if (list == NULL) - return 0; - rem = RTA_PAYLOAD(list); open_json_array(PRINT_JSON, "schedule"); @@ -432,60 +429,82 @@ static int print_sched_list(FILE *f, struct rtattr *list) for (item = RTA_DATA(list); RTA_OK(item, rem); item = RTA_NEXT(item, rem)) { struct rtattr *tb[TCA_TAPRIO_SCHED_ENTRY_MAX + 1]; - __u32 index = 0, gatemask = 0, interval = 0; - __u8 command = 0; parse_rtattr_nested(tb, TCA_TAPRIO_SCHED_ENTRY_MAX, item); - if (tb[TCA_TAPRIO_SCHED_ENTRY_INDEX]) - index = rta_getattr_u32(tb[TCA_TAPRIO_SCHED_ENTRY_INDEX]); + open_json_object(NULL); - if (tb[TCA_TAPRIO_SCHED_ENTRY_CMD]) - command = rta_getattr_u8(tb[TCA_TAPRIO_SCHED_ENTRY_CMD]); + nla = tb[TCA_TAPRIO_SCHED_ENTRY_INDEX]; + if (nla) { + __u32 index = rta_getattr_u32(nla); - if (tb[TCA_TAPRIO_SCHED_ENTRY_GATE_MASK]) - gatemask = rta_getattr_u32(tb[TCA_TAPRIO_SCHED_ENTRY_GATE_MASK]); + print_uint(PRINT_ANY, "index", "\tindex %u", index); + } - if (tb[TCA_TAPRIO_SCHED_ENTRY_INTERVAL]) - interval = rta_getattr_u32(tb[TCA_TAPRIO_SCHED_ENTRY_INTERVAL]); + nla = tb[TCA_TAPRIO_SCHED_ENTRY_CMD]; + if (nla) { + __u8 command = rta_getattr_u8(nla); + + print_string(PRINT_ANY, "cmd", " cmd %s", + entry_cmd_to_str(command)); + } + + nla = tb[TCA_TAPRIO_SCHED_ENTRY_GATE_MASK]; + if (nla) { + __u32 gatemask = rta_getattr_u32(nla); + + print_0xhex(PRINT_ANY, "gatemask", " gatemask %#llx", + gatemask); + } + + nla = tb[TCA_TAPRIO_SCHED_ENTRY_INTERVAL]; + if (nla) { + __u32 interval = rta_getattr_u32(nla); + + print_uint(PRINT_ANY, "interval", " interval %u", + interval); + } - open_json_object(NULL); - print_uint(PRINT_ANY, "index", "\tindex %u", index); - print_string(PRINT_ANY, "cmd", " cmd %s", entry_cmd_to_str(command)); - print_0xhex(PRINT_ANY, "gatemask", " gatemask %#llx", gatemask); - print_uint(PRINT_ANY, "interval", " interval %u", interval); close_json_object(); print_nl(); } close_json_array(PRINT_ANY, ""); - - return 0; } static int print_schedule(FILE *f, struct rtattr **tb) { - int64_t base_time = 0, cycle_time = 0, cycle_time_extension = 0; + struct rtattr *nla; - if (tb[TCA_TAPRIO_ATTR_SCHED_BASE_TIME]) - base_time = rta_getattr_s64(tb[TCA_TAPRIO_ATTR_SCHED_BASE_TIME]); + nla = tb[TCA_TAPRIO_ATTR_SCHED_BASE_TIME]; + if (nla) { + int64_t base_time = rta_getattr_s64(nla); - if (tb[TCA_TAPRIO_ATTR_SCHED_CYCLE_TIME]) - cycle_time = rta_getattr_s64(tb[TCA_TAPRIO_ATTR_SCHED_CYCLE_TIME]); + print_lluint(PRINT_ANY, "base_time", "\tbase-time %lld", + base_time); + } - if (tb[TCA_TAPRIO_ATTR_SCHED_CYCLE_TIME_EXTENSION]) - cycle_time_extension = rta_getattr_s64( - tb[TCA_TAPRIO_ATTR_SCHED_CYCLE_TIME_EXTENSION]); + nla = tb[TCA_TAPRIO_ATTR_SCHED_CYCLE_TIME]; + if (nla) { + int64_t cycle_time = rta_getattr_s64(nla); - print_lluint(PRINT_ANY, "base_time", "\tbase-time %lld", base_time); + print_lluint(PRINT_ANY, "cycle_time", " cycle-time %lld", + cycle_time); + } - print_lluint(PRINT_ANY, "cycle_time", " cycle-time %lld", cycle_time); + nla = tb[TCA_TAPRIO_ATTR_SCHED_CYCLE_TIME_EXTENSION]; + if (nla) { + int64_t cycle_time_extension = rta_getattr_s64(nla); - print_lluint(PRINT_ANY, "cycle_time_extension", - " cycle-time-extension %lld", cycle_time_extension); + print_lluint(PRINT_ANY, "cycle_time_extension", + " cycle-time-extension %lld", + cycle_time_extension); + } - print_sched_list(f, tb[TCA_TAPRIO_ATTR_SCHED_ENTRY_LIST]); + nla = tb[TCA_TAPRIO_ATTR_SCHED_ENTRY_LIST]; + if (nla) + print_sched_list(f, nla); return 0; } From patchwork Mon Aug 7 22:09:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13345252 X-Patchwork-Delegate: stephen@networkplumber.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 541B313AE6 for ; Mon, 7 Aug 2023 22:15:19 +0000 (UTC) Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2057.outbound.protection.outlook.com [40.107.8.57]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F14771B1 for ; Mon, 7 Aug 2023 15:14:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ctbgL/adJAS/1OolwKFEVceTnnsuJoc6/YaOZ5T2LVxhNFGi3HXwot6JavzSoxhlJygwZTB1KbNlnJDZ5tElwubA+YdnIw53oR64Zny12UZzD2GuFZRmksQpQ+9ClioJU0rqHU0qKvN/DGtwv+rxAnjR12pHDDEHCj+UG3I1Dc4B/QgTvYCXUiH2uRlrMrlqXWshtNpgUL2L8P3pcCh/f1Cu2ro+b7kcSFoQ1h2yj4h3fwfrnUg0Ayd1quK1s2EExPpPRci4fRrydVzwiS2Bws53hGUOrkawxinzoh8U5NqCxSQ73OSvH+XJLToXo9jLPGaWw/sc/7bS21PFx6EDeA== 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=Ez7iTS9zJLdBrhJvk76pKbB56xg6+2bJRYU04SJyYak=; b=DKNWjnK34cp/zUFMEjMNn06CMMqBMXYkErReRmpv8KBGfQA2Iz/ks0UWkVDlcVLxI8NwF/mpNmFD/2cIvZ7iXq7Tp/9E6FLdMeDaTleLNWxcYrt+5B/320iwYudIbDrn5uxhtMac1bUacUXzhZ7YJH6ZehKeA8jnSP7uX13ZIDYEJ0ksmCTpQP3LqVlltvQ0aPgXSJ/brJImejNnwy01wI2l6NY10buzslTmXL1pfO7/E4HPShh99St7WaTYfkwjy65nnRopgnKo+BfG121p1Rl6TJON3SbdDTE8LtCB/8UX4se+jCTohIBL7XbTr+WNA6R4SrTzzNFjx5pM4k6qnA== 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=Ez7iTS9zJLdBrhJvk76pKbB56xg6+2bJRYU04SJyYak=; b=X7Fgk5yhGKB9ZvlnaNQ+V7634SGcs9I4Jqsi/2wXT8rQCGgVE8CNAfnV0L+YaNZZ2MeKTDg2XHCwYYFrtyI0FHWylzci5ysIItaqejYJ3002Eg0/4eU1GiwQGWOHHp12yPwC+yoiqvsHx3PbYwv8K1xZcmuivyy2fszh0GRTH+M= 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 AM0PR04MB6963.eurprd04.prod.outlook.com (2603:10a6:208:18b::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.27; Mon, 7 Aug 2023 22:09:48 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::d4ed:20a0:8c0a:d9cf]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::d4ed:20a0:8c0a:d9cf%6]) with mapi id 15.20.6652.026; Mon, 7 Aug 2023 22:09:47 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: David Ahern , Stephen Hemminger , Vinicius Costa Gomes Subject: [PATCH v2 iproute2 2/2] tc/taprio: fix JSON output when TCA_TAPRIO_ATTR_ADMIN_SCHED is present Date: Tue, 8 Aug 2023 01:09:36 +0300 Message-Id: <20230807220936.4164355-2-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230807220936.4164355-1-vladimir.oltean@nxp.com> References: <20230807220936.4164355-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: FR0P281CA0062.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:49::23) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|AM0PR04MB6963:EE_ X-MS-Office365-Filtering-Correlation-Id: 2c6b32b9-29d8-415f-ea5d-08db9793037d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tvT1BG0BikA98GkUSE9d9K9KYpFaNqHyWo0EnbkaXs29/UcjZfvZZW/tk5lYI2HsCUREc2NVzAx8DSWcu+bC44bNtb2mgYfzY9qi103dNv4Z8ZjFU8f2O5vcfv5fYIQQ+uiqVojYmp+UkbFkno0IrU3S/WXCbMmeyMDAVNoyI3l1eQg75z5qUuT9oRSpnd22HAsyV6lFsIMAhp5TrNwDERh+i4Wl5qi01qIT7Kx3DqwesPGfsKpVLaRadOx/M61KfSaAtlnNXh+GkLSUb6YLU4BMywRDN7eSdkMNkWZ1OhuaPLWijL4QCMacVTvajJmtULJthW7iaSMafaNy+utA4Cb7KqNWIB7RZBXXttB/emaYFkCw7UgaUA3RsGESsS1cYQZI2NsFRglnvKit3yFuNB0jD3/WgtpAhiowJzqdC3FvI3OTZYvoDeU/Pkk+M/g1dmKfZu7Vq+BreMf/+s67Ns6ajTT3lrloISrxUal3ZmSfbPMdPeKgjhfv3JMCy39tC0xr5amTSw/A90NENccGQjFBRzKFyyVJxsticbPWtGtVMzw56d3n/DcMIWUaEX3LXHpVAENsaj8T9VbuturhE4hI/hMPWs8NYoMyp1pu0bJsO29jKkC0VGtKCWMJ70zz 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)(346002)(376002)(39860400002)(366004)(396003)(136003)(186006)(1800799003)(451199021)(1076003)(41300700001)(26005)(2906002)(44832011)(83380400001)(5660300002)(8936002)(8676002)(2616005)(478600001)(6916009)(86362001)(6506007)(316002)(38350700002)(38100700002)(54906003)(6486002)(66476007)(66556008)(52116002)(66946007)(6666004)(6512007)(4326008)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: HLioN+5qQYzLfcMPxAV0w6NKy3IgVjuVAIU/wfGV4u6Ftl5QVDTQkP1SpVbh20VCSWi0HklhuK1qGuNDbNPTZxCX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Bc9hYxKpgCaNk4vZ5tPo5ShvEHvGcrgn527Vaut6htvp2868kANlFmeohtw+LJeaweR8FL4u3vNZ6dJhbC0rQFvs2K3sfxMn5LeEGuVPfqWLuAQLEMD1xE85xrczTaNjh3+GwsG0r5rdzYHHHXVSiwcT0TATVXtiLxHqtq50oPw9AoatT3XcADDm3GHWxxxseeeAe+vXteaiD7aLK3RoKxgu2ADBd7z4ho7BomYWVAMyS9gzglC5M9R6UQRM27PuJP2QY7BXI1QI4fAgMix9Eg1zzE63W7/5ne0J/rh6tA7NIklEqQlfouvRnKi+aUPbEyRWceHtD25vG89xXspnLG6/EQC+SXwPuBHsLbAIBshL1UT5xbn67mw4y/xZm8NDNtvC3339gSWSg6v00qH6C595hHB7OCbVWc1H5DngY3oBaWGoQrU9zlnh0KWbccd0ydWopRS0afA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2c6b32b9-29d8-415f-ea5d-08db9793037d X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Aug 2023 22:09:47.9063 (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: 67EtI1RqYUiNzjwK8TOOMHI9PzvywE96BjWyUUm7nUSES4T2mV4EHufRe3vKd8tftrWje3FmqopXSQQvgVZQ2w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB6963 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: dsahern@gmail.com When the kernel reports that a configuration change is pending (and that the schedule is still in the administrative state and not yet operational), we (tc -j -p qdisc show) produce the following output: [ { "kind": "taprio", "handle": "8001:", "root": true, "refcnt": 9, "options": { "tc": 8, "map": [ 0,1,2,3,4,5,6,7,0,0,0,0,0,0,0,0 ], "queues": [ { "offset": 0, "count": 1 },{ "offset": 1, "count": 1 },{ "offset": 2, "count": 1 },{ "offset": 3, "count": 1 },{ "offset": 4, "count": 1 },{ "offset": 5, "count": 1 },{ "offset": 6, "count": 1 },{ "offset": 7, "count": 1 } ], "clockid": "TAI", "base_time": 0, "cycle_time": 20000000, "cycle_time_extension": 0, "schedule": [ { "index": 0, "cmd": "S", "gatemask": "0xff", "interval": 20000000 } ],{ "base_time": 1691160103110424418, "cycle_time": 20000000, "cycle_time_extension": 0, "schedule": [ { "index": 0, "cmd": "S", "gatemask": "0xff", "interval": 20000000 } ] }, "max-sdu": [ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ], "fp": [ "E","E","E","E","E","E","E","E","E","E","E","E","E","E","E","E" ] } } ] which is invalid json, because the second group of "base_time", "cycle_time", etc etc is placed in an unlabeled sub-object. If we pipe it into jq, it complains: parse error: Objects must consist of key:value pairs at line 53, column 14 Since it represents the administrative schedule, give this unnamed JSON object the "admin" name. We now print valid JSON which looks like this: [ { "kind": "taprio", "handle": "8001:", "root": true, "refcnt": 9, "options": { "tc": 8, "map": [ 0,1,2,3,4,5,6,7,0,0,0,0,0,0,0,0 ], "queues": [ { "offset": 0, "count": 1 },{ "offset": 1, "count": 1 },{ "offset": 2, "count": 1 },{ "offset": 3, "count": 1 },{ "offset": 4, "count": 1 },{ "offset": 5, "count": 1 },{ "offset": 6, "count": 1 },{ "offset": 7, "count": 1 } ], "clockid": "TAI", "base_time": 0, "cycle_time": 20000000, "cycle_time_extension": 0, "schedule": [ { "index": 0, "cmd": "S", "gatemask": "0xff", "interval": 20000000 } ], "admin": { "base_time": 1691160511783528178, "cycle_time": 20000000, "cycle_time_extension": 0, "schedule": [ { "index": 0, "cmd": "S", "gatemask": "0xff", "interval": 20000000 } ] }, "max-sdu": [ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ], "fp": [ "E","E","E","E","E","E","E","E","E","E","E","E","E","E","E","E" ] } } ] Fixes: 602fae856d80 ("taprio: Add support for changing schedules") Signed-off-by: Vladimir Oltean Acked-by: Vinicius Costa Gomes --- v1->v2: none tc/q_taprio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tc/q_taprio.c b/tc/q_taprio.c index 6250871fb5f2..ef8fc7a05fc2 100644 --- a/tc/q_taprio.c +++ b/tc/q_taprio.c @@ -654,7 +654,7 @@ static int taprio_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt) parse_rtattr_nested(t, TCA_TAPRIO_ATTR_MAX, tb[TCA_TAPRIO_ATTR_ADMIN_SCHED]); - open_json_object(NULL); + open_json_object("admin"); print_schedule(f, t);