From nobody Sat Feb 7 08:27:15 2026 Received: from mail-ej1-f41.google.com (mail-ej1-f41.google.com [209.85.218.41]) (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 3FA4C225390 for ; Sat, 18 Oct 2025 15:18:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760800685; cv=none; b=O+q3ASPwzEHiGNXOhH6w4InQ32Rx9cm+jBa+P3dkv8vqFGNYkJM+MvMVgnkxQ4uSKE1YBvFeESpZ9QhOZyV63Cocf2+wkgEfFNDBZCQSQ0sELwuWJI/c7LmjJCSJySiJHF3UeWctVMYFb8nPWd0qXbZT2qzn8ENMaaBOZDUZFcE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760800685; c=relaxed/simple; bh=UeRLzxSTtKouZ2KsT3hkb4b+OwXStm7lt7fTIc9MGFE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uETr1nrVXGcuZjnHcPoRljbHQIejF+33ZRtvlhirSzGri+8KJz+34DdLs9f56PlP8U3eF9fhd5uRKtmjbCL6WOa0sU0cEQszuUzIMfS3fulojQhY57kRy1Go80uHV4Lmy7w5XD7uibPen3VnHB3IjIO9ivEzPiGtNXeg6FxCw7E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.com; spf=pass smtp.mailfrom=googlemail.com; dkim=pass (2048-bit key) header.d=googlemail.com header.i=@googlemail.com header.b=QWkqATuf; arc=none smtp.client-ip=209.85.218.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=googlemail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=googlemail.com header.i=@googlemail.com header.b="QWkqATuf" Received: by mail-ej1-f41.google.com with SMTP id a640c23a62f3a-b457d93c155so421749666b.1 for ; Sat, 18 Oct 2025 08:18:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20230601; t=1760800681; x=1761405481; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=KrN3fMwOLPZu29auA7WsZPkfHarxsXcDGhOuMV9Gxus=; b=QWkqATufxIHXa1hbeOx6EwVjxa0ilIhis5E5PNAANAIImKTQ3orQy2RLBKaoqYqPcq mpMEMvrUWlnNNKAmb5wETkGfhZ230Zu8/6Yzl3fmhDZEXW6wAvzXLWOC6kFs6Or2OF53 iDKIhkAbvROwYWBdLRr8rJoxFsz7NiCTzy4x3yHD/TGCieCjmvCh6N84/HGcp2NFFxKT QK9ZcZPH400TjZSNZEkcLRUuQL+ydM2vfQYghummz6EbNO473f1jCl+5PNOS4/xWuGxO 5Uzc1UXJe7AGhUg6oDws3cEoAH6dO80jjS3rsH84gMoqqaNWHaLDpHbrBjw4tZUIi1to ltYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760800681; x=1761405481; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=KrN3fMwOLPZu29auA7WsZPkfHarxsXcDGhOuMV9Gxus=; b=dwu9plTdf4KOeZ35qPdySgxCl4mJRNGkrHKQs01ulo1D2QyIZcUvlYgLdF4BYsLa4C 1TJVzCFMsFkPHTxcjBMDM+slemkpV3yMl9CNsujya7pv4WqvBPoEkKXmdwogXrqb2mUv 9YyyKmAqQsrYhAoXkJKaDL6vXfDMJRhWsIBk10YQ+5x+7MPm8lXFVRGRCE4FN187kG99 tHQT4fKST2qfvo3y49R06Pm+6YpqQxCrQ8DBx/1xxraGtbqHdRjTXEeZXsbGbVMJ1ZGf rA+k3/9s8iYfMg0PEGtxSDpPP/9qT2vc/N08C0S75grsV5t9LxUcfuc4olIyLLjJ42hA lOQQ== X-Forwarded-Encrypted: i=1; AJvYcCXeTLELqq79IKK8lSYS1+gNfvO6KKoWdQc8a6RYlJmzeuwMCkeeQGj1LJ59MS+2FXAAsiqSwF+KTQVqyO4=@vger.kernel.org X-Gm-Message-State: AOJu0YxobRdi6YHYClpeWxIQDw+U1PTM1bVXQIEQvVwnM3QPJcu/2i63 FuHBAzsw2XWxMdFUwJQBYKuFGQYIoOL6iEYil+dusDZRz0bnBPzkbLui X-Gm-Gg: ASbGncsGIfsgD2ZujKbW/IZNNJBWdKKEpZADeOOeg6VG5SVoUE/xPOAzGxjLMRiu8Wm K2UqbDIMB35wJmisWitl0B1sAFROQe6TbsWaVeqcFFWkgeBFNgHZPC9Capd8GTEAXn9dtZ4X7FS /TTMGzJSEGL7czGEOWlQqDUYB/PzJ8KWxodJy9k+6/QOpNmiJNF4ze75vNYqtRHiRReC2sT3E/4 tRAXq4hYJRPPvAPnoVm/+VW/RkPacseGkps4JuGtxseAUbvaHlhHHo8EVoEYRgFsVggv9atn0UK EVMCt3fVwbhmJLhjZgsXYDDxLzwoNjk6olNqkEhBznLNJrIrFWrmOdqYAEFrwYKGKK1VgmH4WpU tfaey9AOuKaiUF5JXI6SU8THF0TdCM/j8s5LFbs6Xl7U8CHgYa3v5qo/J3gtLkEFpC0RLyOEr9+ M0ULi+0sqMich8mnZIgF++xLNHPDhwl+xtKAD66M1ngmERsPN276ATkFBHKgwVRY8NWtfF3k5mD g== X-Google-Smtp-Source: AGHT+IE0GjjqomwD9ou8fGZFtmJFWtZFMZxl/gZzYCOgNQM91Qb7zfcpfiyOckxUCtZmVWiY1V/tyw== X-Received: by 2002:a17:907:1c85:b0:b3e:5f20:888d with SMTP id a640c23a62f3a-b647304516amr947340466b.27.1760800680470; Sat, 18 Oct 2025 08:18:00 -0700 (PDT) Received: from tycho (p200300c1c7311b00ba8584fffebf2b17.dip0.t-ipconnect.de. [2003:c1:c731:1b00:ba85:84ff:febf:2b17]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b65eb036846sm259983366b.54.2025.10.18.08.17.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Oct 2025 08:18:00 -0700 (PDT) Sender: Zahari Doychev From: Zahari Doychev To: donald.hunter@gmail.com, kuba@kernel.org Cc: davem@davemloft.net, edumazet@google.com, pabeni@redhat.com, horms@kernel.org, jacob.e.keller@intel.com, ast@fiberby.net, matttbe@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us, johannes@sipsolutions.net, zahari.doychev@linux.com Subject: [PATCH 1/4] ynl: samples: add tc filter add example Date: Sat, 18 Oct 2025 17:17:34 +0200 Message-ID: <20251018151737.365485-2-zahari.doychev@linux.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251018151737.365485-1-zahari.doychev@linux.com> References: <20251018151737.365485-1-zahari.doychev@linux.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add a simple tool that demonstrates adding a flower filter with two VLAN push actions. This example can be invoked as: # ./tools/samples/tc-filter-add p2 # tc -j -p filter show dev p2 ingress pref 2211 [ { "protocol": "802.1Q", "kind": "flower", "chain": 0 },{ "protocol": "802.1Q", "kind": "flower", "chain": 0, "options": { "handle": 1, "keys": { "num_of_vlans": 3, "vlan_id": 255, "vlan_prio": 5 }, "not_in_hw": true, "actions": [ { "order": 1, "kind": "vlan", "vlan_action": "push", "id": 255, "control_action": { "type": "pass" }, "index": 5, "ref": 1, "bind": 1 },{ "order": 2, "kind": "vlan", "vlan_action": "push", "id": 555, "control_action": { "type": "pass" }, "index": 6, "ref": 1, "bind": 1 } ] } } ] This shows the filter with two VLAN push actions, verifying that tc action attributes are handled correctly. Signed-off-by: Zahari Doychev --- tools/net/ynl/Makefile.deps | 1 + tools/net/ynl/samples/.gitignore | 1 + tools/net/ynl/samples/tc-filter-add.c | 92 +++++++++++++++++++++++++++ 3 files changed, 94 insertions(+) create mode 100644 tools/net/ynl/samples/tc-filter-add.c diff --git a/tools/net/ynl/Makefile.deps b/tools/net/ynl/Makefile.deps index 865fd2e8519e..96c390af060e 100644 --- a/tools/net/ynl/Makefile.deps +++ b/tools/net/ynl/Makefile.deps @@ -47,4 +47,5 @@ CFLAGS_tc:=3D $(call get_hdr_inc,__LINUX_RTNETLINK_H,rtne= tlink.h) \ $(call get_hdr_inc,_TC_MIRRED_H,tc_act/tc_mirred.h) \ $(call get_hdr_inc,_TC_SKBEDIT_H,tc_act/tc_skbedit.h) \ $(call get_hdr_inc,_TC_TUNNEL_KEY_H,tc_act/tc_tunnel_key.h) +CFLAGS_tc-filter-add:=3D$(CFLAGS_tc) CFLAGS_tcp_metrics:=3D$(call get_hdr_inc,_LINUX_TCP_METRICS_H,tcp_metrics.= h) diff --git a/tools/net/ynl/samples/.gitignore b/tools/net/ynl/samples/.giti= gnore index 7f5fca7682d7..05087ee323ba 100644 --- a/tools/net/ynl/samples/.gitignore +++ b/tools/net/ynl/samples/.gitignore @@ -7,3 +7,4 @@ rt-addr rt-link rt-route tc +tc-filter-add diff --git a/tools/net/ynl/samples/tc-filter-add.c b/tools/net/ynl/samples/= tc-filter-add.c new file mode 100644 index 000000000000..b9c6f30f2a30 --- /dev/null +++ b/tools/net/ynl/samples/tc-filter-add.c @@ -0,0 +1,92 @@ +// SPDX-License-Identifier: GPL-2.0 +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "tc-user.h" + +int main(int argc, char **argv) +{ + struct tc_newtfilter_req *req; + struct tc_act_attrs *acts; + struct tc_vlan p =3D { + .v_action =3D TCA_VLAN_ACT_PUSH + }; + __u16 flags =3D NLM_F_EXCL | NLM_F_CREATE; + struct ynl_error yerr; + struct ynl_sock *ys; + int ifi; + + if (argc < 2) { + fprintf(stderr, "Usage: %s \n", argv[0]); + return 1; + } + ifi =3D if_nametoindex(argv[1]); + if (!ifi) { + perror("if_nametoindex"); + return 1; + } + + ys =3D ynl_sock_create(&ynl_tc_family, &yerr); + if (!ys) { + fprintf(stderr, "YNL: %s\n", yerr.msg); + return 1; + } + + req =3D tc_newtfilter_req_alloc(); + if (!req) { + fprintf(stderr, "tc_newtfilter_req_alloc failed\n"); + goto err_destroy; + } + memset(req, 0, sizeof(*req)); + + acts =3D tc_act_attrs_alloc(2); + if (!acts) { + fprintf(stderr, "tc_act_attrs_alloc\n"); + goto err_act; + } + memset(acts, 0, sizeof(*acts)); + + req->_hdr.tcm_ifindex =3D ifi; + req->_hdr.tcm_parent =3D TC_H_MAKE(TC_H_CLSACT, TC_H_MIN_INGRESS); + req->_hdr.tcm_info =3D TC_H_MAKE((2211 << 16), htons(0x8100)); + req->chain =3D 0; + + tc_newtfilter_req_set_nlflags(req, flags); + tc_newtfilter_req_set_kind(req, "flower"); + tc_newtfilter_req_set_options_flower_key_vlan_id(req, 255); + tc_newtfilter_req_set_options_flower_key_vlan_prio(req, 5); + tc_newtfilter_req_set_options_flower_key_num_of_vlans(req, 3); + + __tc_newtfilter_req_set_options_flower_act(req, acts, 2); + + tc_act_attrs_set_kind(&acts[0], "vlan"); + tc_act_attrs_set_options_vlan_parms(&acts[0], &p, sizeof(p)); + tc_act_attrs_set_options_vlan_push_vlan_id(&acts[0], 255); + tc_act_attrs_set_kind(&acts[1], "vlan"); + tc_act_attrs_set_options_vlan_parms(&acts[1], &p, sizeof(p)); + tc_act_attrs_set_options_vlan_push_vlan_id(&acts[1], 555); + + tc_newtfilter_req_set_options_flower_flags(req, 0); + tc_newtfilter_req_set_options_flower_key_eth_type(req, htons(0x8100)); + + if (tc_newtfilter(ys, req)) + fprintf(stderr, "YNL: %s\n", ys->err.msg); + + tc_newtfilter_req_free(req); + ynl_sock_destroy(ys); + return 0; + +err_act: + tc_newtfilter_req_free(req); +err_destroy: + ynl_sock_destroy(ys); + return 2; +} --=20 2.51.0 From nobody Sat Feb 7 08:27:15 2026 Received: from mail-ej1-f49.google.com (mail-ej1-f49.google.com [209.85.218.49]) (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 313A019D07A for ; Sat, 18 Oct 2025 15:18:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760800686; cv=none; b=lrmC+hx+g+KEG98pN7Zdw3nYzFh9IhQoJGflPlLubf5BapkZu/6VJ8Fc8/PZ/sPSf1FoE+3NTcFpgGtpBp3rBjnB2aDiR3GHmv2LpcP7bAjaeek4aN0OgV/w0AZG9fF7kfPGYCXQTWYRYepJ8RbW3zHPPFB7Ige0cGXrUVp39h4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760800686; c=relaxed/simple; bh=JhyO9XvNDW+35nBiw4rGks4IugYKd7xQ0UiDyIaZ/c8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mmA9jqZAn03bNcPuqLE/1zEAKxj5xjvAFLCPlNFRN+8kYLpG7t2beZv0BTXjrpPSMEs1Z7HS+IDLWxzjpgQLdsSZ0wLfDsh1EGgT3vj7DXjx/3zNSEBLKJLbq9LAf3jPguKRo0xNfNcqcKi6Lpd1M3jtvmHstttJs+nQLNAkRvs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.com; spf=pass smtp.mailfrom=googlemail.com; dkim=pass (2048-bit key) header.d=googlemail.com header.i=@googlemail.com header.b=BXU+rz6r; arc=none smtp.client-ip=209.85.218.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=googlemail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=googlemail.com header.i=@googlemail.com header.b="BXU+rz6r" Received: by mail-ej1-f49.google.com with SMTP id a640c23a62f3a-b456d2dc440so458456266b.0 for ; Sat, 18 Oct 2025 08:18:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20230601; t=1760800682; x=1761405482; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=7tBEUnZekJ5PrNAba7jx8QPCcLmqbNQY6xjID2I+xCI=; b=BXU+rz6rN9cmkwHCf4jx6DBYv9HsLnOkhu5zOrzYYO13Vhs1K3lulsmIxUpkyaEeE8 FXaFo9BEPOZxmjcDcQcWrKEwCOXrQPR2Idl1xnaFW/RWp52oEeX6/RkRZ1EhBlwmFIx4 MkjLz8KEO4mGSs4Hdy1GyTmL15l9ubSYjvz4mj3u/bP2XuPCBj5iNtI0HUZf5mmzaL6o k1PSuBqK9TnIA4A5xFUm6XeaCAeUly5L0Fml4fTLWWJ02ZwO3bs06pe6WdblVJaCI4ek cQM2B4Of+Aatyszz8zSDKnU2SnmjEbae5jSqQepxpKqmGbuoZ2chWmQU/rZ9UpkSvy2U MyOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760800682; x=1761405482; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=7tBEUnZekJ5PrNAba7jx8QPCcLmqbNQY6xjID2I+xCI=; b=H8JXh/zlzBOoC8Qaevl2hLeKoa8Tdgtb9sDVwiWsm9CiqkU23BG5M2sJc3qYr9iGV7 FLcR4X3TfaJ9ROH4iIe1RbevnVy2cmCYoM2e7wsIix0Av3kN/wx+SP0sHiiJOhKQjo+Z T34phvKrXqIQq49xXV9vvUbtrW36jyVD1Az97AGiltr33Ni7Ux04chgODhDYR0XbudOR hOjsQDWR2Ry7OyH4rOO4FVbSucb2lz5UIUcJC0FunqHyaq3IsKRov6PauQQgKw5WItPr DsydzHUsuaazGzVTt+/dVcdMm7djZ/iz94nYHsNvnUPUq+b4GeTgFP3DjhXXKEEUpVI4 1ntQ== X-Forwarded-Encrypted: i=1; AJvYcCX2iQ15Ph4Eahmo/GSFJOZLjBzCmkbvNgfOrRNBTwWAqD5vB7AjE7Qo4TB/DHlD9HTVCT3ZqJiH6cG1J8U=@vger.kernel.org X-Gm-Message-State: AOJu0YzHPM2eZyXspXHe0xuq4O/ER1kx9oxBWNDvsBffIjsGzMzqucSd C7wpTJW4Z4t8ioIMznkdBwKIf0yvrpJLv0VslhtndcT4bMtx8JGbsSgx X-Gm-Gg: ASbGncto+NrcfhwUmMiJvQrdUwAs6czeE94svtGW2IbkL9ORbDg/KXhC1kTPfBt1dk+ ggNjnv7kjWTGJTH1iWudzVknA+9Xk9Og7gYFI8HZuyuhuY6+CLe5mO+WDU7Z9AGfz52RX5B88aZ aOfHMeOjL98kNvwMYxmJ+24BKdEEPoKgml4Wnh3+6PyysaVQO+yRuYnz5i4Igp17yAqwleb3FHR 8dy80FR96eRvt5Pt7mKbIgRQEEOSf5xWCSUMRX72Iv3L3H6dz1y8h1Wi7KiPW1FT0TjCXCeQB0P SujMnqNWflf+0EGeRVzcJJM2RuWeXUcrT4JGXje2t5HiSk2qzgL42vWAki5AVDB2AHIU6fwSe5f ClQBqaNPu3JHqC/Spo0lHSNJXXcBOppwKb0YRRL8sK9riZOE/Rh++xNewX+h7KPE1/dxOEvP4ZT WIQ9zWXs9BSTDKt4fSDYn9QdPWGentaqov/MSSX6KnygDJXft+KpVhaby5zXJFNpXjZd5i9lrEN Q== X-Google-Smtp-Source: AGHT+IFubBcvDe/p5FEnyUxV3Cks6QoQioHs5yaIMVYObE6b3U3QQzbJ5CaDHU8R8IMyAEZnxXnS+g== X-Received: by 2002:a17:907:86a2:b0:b41:2209:d35d with SMTP id a640c23a62f3a-b6472b5f887mr740065766b.1.1760800682144; Sat, 18 Oct 2025 08:18:02 -0700 (PDT) Received: from tycho (p200300c1c7311b00ba8584fffebf2b17.dip0.t-ipconnect.de. [2003:c1:c731:1b00:ba85:84ff:febf:2b17]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b65eb036846sm259983366b.54.2025.10.18.08.18.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Oct 2025 08:18:01 -0700 (PDT) Sender: Zahari Doychev From: Zahari Doychev To: donald.hunter@gmail.com, kuba@kernel.org Cc: davem@davemloft.net, edumazet@google.com, pabeni@redhat.com, horms@kernel.org, jacob.e.keller@intel.com, ast@fiberby.net, matttbe@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us, johannes@sipsolutions.net, zahari.doychev@linux.com Subject: [PATCH 2/4] tools: ynl: zero-initialize struct ynl_sock memory Date: Sat, 18 Oct 2025 17:17:35 +0200 Message-ID: <20251018151737.365485-3-zahari.doychev@linux.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251018151737.365485-1-zahari.doychev@linux.com> References: <20251018151737.365485-1-zahari.doychev@linux.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The memory belonging to tx_buf and rx_buf in ynl_sock is not initialized after allocation. This commit ensures the entire allocated memory is set to zero. When asan is enabled, uninitialized bytes may contain poison values. This can cause failures e.g. when doing ynl_attr_put_str then poisoned bytes appear after the null terminator. As a result, tc filter addition may fail. Signed-off-by: Zahari Doychev --- tools/net/ynl/lib/ynl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/net/ynl/lib/ynl.c b/tools/net/ynl/lib/ynl.c index 2bcd781111d7..16a4815d6a49 100644 --- a/tools/net/ynl/lib/ynl.c +++ b/tools/net/ynl/lib/ynl.c @@ -744,7 +744,7 @@ ynl_sock_create(const struct ynl_family *yf, struct ynl= _error *yse) ys =3D malloc(sizeof(*ys) + 2 * YNL_SOCKET_BUFFER_SIZE); if (!ys) return NULL; - memset(ys, 0, sizeof(*ys)); + memset(ys, 0, sizeof(*ys) + 2 * YNL_SOCKET_BUFFER_SIZE); =20 ys->family =3D yf; ys->tx_buf =3D &ys->raw_buf[0]; --=20 2.51.0 From nobody Sat Feb 7 08:27:15 2026 Received: from mail-ej1-f46.google.com (mail-ej1-f46.google.com [209.85.218.46]) (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 E514122836C for ; Sat, 18 Oct 2025 15:18:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760800691; cv=none; b=Q5yM5ZXjyMOjJwmwhdqOy1BYdElRw7SZmCxySy3gnanWq9JC0pm3bGqkMBGW36m/y/eZT6dBrlhjRxmR0/8kS7eBB8T/wD0pY0LJSxBKHXXUpQTqM7fFgKkT778eeg508+0BdTOpJpB0foa6hTgy+mPSf0YT6bL/D73IWwWh8oM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760800691; c=relaxed/simple; bh=uPnH5ewj9MAoqq1yVrco8LvFEZu5ocqvEtDb1ZRbnWw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GznQzhzo8iBSXRmd83lYz5ZAmNyC+AyJhNxH0uryExAah+O1Uln+3otm4I5NrGbJUAT70XShk38Ioc7U4vRaenOK6auDI9djgScQS41ntz6kN7jo0Us/dl5147yts9/rHlK4LirOV5Hul7lA9Z8o7kZi/QSrttz1LgREKez+woc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.com; spf=pass smtp.mailfrom=googlemail.com; dkim=pass (2048-bit key) header.d=googlemail.com header.i=@googlemail.com header.b=NbOvrSpT; arc=none smtp.client-ip=209.85.218.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=googlemail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=googlemail.com header.i=@googlemail.com header.b="NbOvrSpT" Received: by mail-ej1-f46.google.com with SMTP id a640c23a62f3a-b50206773adso731922266b.0 for ; Sat, 18 Oct 2025 08:18:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20230601; t=1760800684; x=1761405484; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=0ziuauqYm5nAIFZTrsIsUXlvSa4YCy2hrgmDn3UImNQ=; b=NbOvrSpT5b6SMtAxSgF/eT61MVylZoRTA9IQdmsIu8/HWXUKDu9UGhMSq87BN5feG5 PSBVs7dCEOkh3vybsvPXniZmlklB8EHlcxjaO+v3MoHDlwVYI/s00Rogg/ln/qDAv068 iqRMOszYKYYFpYGBjN3xtjT08mSMxQXTWjLbWFGA8YJejxXn9a5iY6KHy9HTMugG3Vhp wdxeR7SjALhGPmRzck4morX9LkUEVOe/nPqjEvS1ZmF7Hkpe6KxDWds3EnuZdqN349I0 jF0oYIWwF3jzaZThgqrhXICzPXP0aVXTgzTGgteYJZjl7AnNsBiKnPQPZECa6/Qau3Wz 0Mtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760800684; x=1761405484; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=0ziuauqYm5nAIFZTrsIsUXlvSa4YCy2hrgmDn3UImNQ=; b=qdccz7vj7EVEPgRd6xD4crZAaZfXSTEO1p52iFFw4txICybhhKlC3LQtXzLqhJKtlN 3nZtStV1R59K+F6JfnuL0rZg9fAFrXdpVW0goLnfIgxMfRrFnwAVh0yCII1EZ1jC5xZ5 tbjUOXh1HhNNrq4pTUswmvcp0yEDerIOPfWK/sxnLcxXY6A1LW3l+OeV2ieCmZF1vrpG YTrfDeFkxdWhOyy9C5u02/pLkVPhGEVIreEdc1cH+MnotzH2aTQkkfabr1ySdJjpVIR0 LK1MVm6IcxEHDPwTxL9wjiCCLKV7n6Qs0dCuXj4kWFMzYZ4ymfrWs4Kw2rWkyc3u3dpw e8TA== X-Forwarded-Encrypted: i=1; AJvYcCVwyb3ajyQosphQ57Hm3705SPLDjTJwrwwmWbdZxS3edoYNj/YhehesRNVEEZsYv88rjGnoaViwjTTx5eA=@vger.kernel.org X-Gm-Message-State: AOJu0YwYmbkKkxX1GeEviB0XzMkBP5QjwtNbsFogCsSEMuKx5czq7LRS +LGf6a0V0CGFzeNmjXfFcrOi19fJHwkx/6ixAGQT8AA1iD+xJjLqaW72aIoOLr7QEW8= X-Gm-Gg: ASbGnctUT0XsORbdglnlCl9FycBMxZCiTzGAePmK4kxMLOpX+ZnXb8FWcdOSK6E8npa Du/gVCp8NhtZXSqXeX+5433VcVfUjtJ6SwEu81PtCVmXx47uDx6gr0CmSoDlVMSNgAX+l0+Gl3a 3Ie0HWTciA9RLIDPGlfrMIxxMW4ZmmuRNOopkHi0GdAbrPixsdTLVmUxTl2Vyi/2Zzf/Pb0H8D9 C/EWHy3Dv0sNJVSm9Oww3PTetnXPKWD8xAipUQQvtXHQOD8p0eP8bJ6lTRuGCgGBeXqaECq4yCK MS7izOs1TpfFHIBZDlRKTtMUyqyEuZSABTBHAhZdy9/WbkfYF7H0P/BictJ0o7OXq68O1q68vwU UwdkphKckR+ve03PoFZLhG1pId7rzwn0KUgxUfGcwngLfh3DD0CB2cBHfrXZ58rT/Gg5jyxui6Z n1dvaYQZFk7U9nZqwSCFRrFE64/sczJzQKpSVUW59Wm8DaZ8xu/6H/g/FYAibz5QvIQ0FiNBC8v g== X-Google-Smtp-Source: AGHT+IG9vq0qMlQ90uZLTJ+7i+vyez08khY42hQiH9++p1pjab0KxXKoIzUX4plMAY7ETu5kWV6yhg== X-Received: by 2002:a17:907:894f:b0:b33:821f:156e with SMTP id a640c23a62f3a-b605249e3b3mr1287934366b.12.1760800683677; Sat, 18 Oct 2025 08:18:03 -0700 (PDT) Received: from tycho (p200300c1c7311b00ba8584fffebf2b17.dip0.t-ipconnect.de. [2003:c1:c731:1b00:ba85:84ff:febf:2b17]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b65eb036846sm259983366b.54.2025.10.18.08.18.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Oct 2025 08:18:03 -0700 (PDT) Sender: Zahari Doychev From: Zahari Doychev To: donald.hunter@gmail.com, kuba@kernel.org Cc: davem@davemloft.net, edumazet@google.com, pabeni@redhat.com, horms@kernel.org, jacob.e.keller@intel.com, ast@fiberby.net, matttbe@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us, johannes@sipsolutions.net, zahari.doychev@linux.com Subject: [PATCH 3/4] tools: ynl: call nested attribute free function for indexed arrays Date: Sat, 18 Oct 2025 17:17:36 +0200 Message-ID: <20251018151737.365485-4-zahari.doychev@linux.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251018151737.365485-1-zahari.doychev@linux.com> References: <20251018151737.365485-1-zahari.doychev@linux.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When freeing indexed arrays, the corresponding free function should be called for each entry of the indexed array. For example, for for 'struct tc_act_attrs' 'tc_act_attrs_free(...)' needs to be called for each entry. Previously, memory leaks were reported when enabling the ASAN analyzer. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D874=3D=3DERROR: LeakSanitizer: detected memory leaks Direct leak of 24 byte(s) in 1 object(s) allocated from: #0 0x7f221fd20cb5 in malloc ./debug/gcc/gcc/libsanitizer/asan/asan_mall= oc_linux.cpp:67 #1 0x55c98db048af in tc_act_attrs_set_options_vlan_parms ../generated/t= c-user.h:2813 #2 0x55c98db048af in main ./linux/tools/net/ynl/samples/tc-filter-add.= c:71 Direct leak of 24 byte(s) in 1 object(s) allocated from: #0 0x7f221fd20cb5 in malloc ./debug/gcc/gcc/libsanitizer/asan/asan_mall= oc_linux.cpp:67 #1 0x55c98db04a93 in tc_act_attrs_set_options_vlan_parms ../generated/t= c-user.h:2813 #2 0x55c98db04a93 in main ./linux/tools/net/ynl/samples/tc-filter-add.c= :74 Direct leak of 10 byte(s) in 2 object(s) allocated from: #0 0x7f221fd20cb5 in malloc ./debug/gcc/gcc/libsanitizer/asan/asan_mall= oc_linux.cpp:67 #1 0x55c98db0527d in tc_act_attrs_set_kind ../generated/tc-user.h:1622 SUMMARY: AddressSanitizer: 58 byte(s) leaked in 4 allocation(s). The following diff illustrates the changes introduced compared to the previous version of the code. void tc_flower_attrs_free(struct tc_flower_attrs *obj) { + unsigned int i; + free(obj->indev); + for (i =3D 0; i < obj->_count.act; i++) + tc_act_attrs_free(&obj->act[i]); free(obj->act); free(obj->key_eth_dst); free(obj->key_eth_dst_mask); Signed-off-by: Zahari Doychev Reviewed-by: Jakub Kicinski --- tools/net/ynl/pyynl/ynl_gen_c.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tools/net/ynl/pyynl/ynl_gen_c.py b/tools/net/ynl/pyynl/ynl_gen= _c.py index 58086b101057..aadeb3abcad8 100755 --- a/tools/net/ynl/pyynl/ynl_gen_c.py +++ b/tools/net/ynl/pyynl/ynl_gen_c.py @@ -861,6 +861,18 @@ class TypeIndexedArray(Type): return [f"{member} =3D {self.c_name};", f"{presence} =3D n_{self.c_name};"] =20 + def free_needs_iter(self): + return self.sub_type =3D=3D 'nest' + + def _free_lines(self, ri, var, ref): + lines =3D [] + if self.sub_type =3D=3D 'nest': + lines +=3D [ + f"for (i =3D 0; i < {var}->{ref}_count.{self.c_name}; i++)= ", + f'{self.nested_render_name}_free(&{var}->{ref}{self.c_name= }[i]);', + ] + lines +=3D f"free({var}->{ref}{self.c_name});", + return lines =20 class TypeNestTypeValue(Type): def _complex_member_type(self, ri): --=20 2.51.0 From nobody Sat Feb 7 08:27:15 2026 Received: from mail-ej1-f51.google.com (mail-ej1-f51.google.com [209.85.218.51]) (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 1DB5821FF5B for ; Sat, 18 Oct 2025 15:18:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760800692; cv=none; b=BGlGZt44cH1okHecVRxg35LYOEOqIC10UgYBxtmB5b4N7ZImc1wRQSOLTq6Bi4JFHBlbkqR2uETFPngSkqcRPH90D6VcxT76jW1Y5YQbHgY/ZEXwkfelEmlDBMH8E7jH6nB4ExuzLLARKr0yv8Bmxs4MrjDiVchzSenrfN+ZnJQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760800692; c=relaxed/simple; bh=qzqeSszSGyaiszISR/czBnXkGhO6/26SHNNlkpAcUt8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dyoL3yqpfqdbJ5ZeZX6E882/HZXnm/OPEuP9Y3jAncpeHuJcHNnZiHX/UNCqskGujCVxdTzFrkKq26q20tq/v0uZmuYZgw1YqROKBohgs9dJGLF/CXSmoyYEZP9+Yy92mvTQLVN94txfvFXcRol7IAasw0loyECXnLz8zn1XDqA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.com; spf=pass smtp.mailfrom=googlemail.com; dkim=pass (2048-bit key) header.d=googlemail.com header.i=@googlemail.com header.b=c/U2VCaE; arc=none smtp.client-ip=209.85.218.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=googlemail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=googlemail.com header.i=@googlemail.com header.b="c/U2VCaE" Received: by mail-ej1-f51.google.com with SMTP id a640c23a62f3a-b5c18993b73so503340266b.0 for ; Sat, 18 Oct 2025 08:18:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20230601; t=1760800685; x=1761405485; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=f6ph45DuTn4gKNCYi+keao8MWtW71hOag0yh3hz/4co=; b=c/U2VCaEB6ndaedTInB0zdhVqGa3dEKg60chIXK/eWHosMuxErYuaa0fPrJFXXnWLE Tz/Cz1Q8agXVzVlofRPE+6Ol/Srxg2Rn8kiQ4/ioOqrx5ric3VHna99uxQEDTk9kRzJ6 wO+bSw9/PlU6mOYVeWO+ZD1XMwSToD4Q9KJKhtbhxWtCN1+fG7oVvK3IQswfW9kbayeT 7aWIq256mwCoyE+HZcy5ieD/IPZ9Iqbh5t/eAX3rBthSq1WOyKRX/WVoeMk5mba4EoSC WbZn7hEx13MsWpnWmxVfx+ls5rEKmt82qOjjA67KNgehoSOsjTfFQwt0F1qUqP1tsC0F PmNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760800685; x=1761405485; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=f6ph45DuTn4gKNCYi+keao8MWtW71hOag0yh3hz/4co=; b=sl/++JfJt8ZRCmLdxztjSVAoc9o6a08pcP4lPQRFEVKgwOBYX2RXoNwLK/51/nzWzW a7eWQnyVazAU7taL/TQOwqSTKud1AzRPukqeDLyj2gbAuJjnWEzeVa3clmLrmjCc7QGV +dF2/HB0nrvGCJbmbjiZ+oBpFG7FP0BjqxuJoh8lRx/NjSY1PcDoJbjxzq8lw+f68IrR ltZ8YL19tVWOR+GbdW0lFdhEvmRl4Zx7479Ghili99cYH2/Lj83HitNv7YO2U9SX8pVn OsgffZkkpeXFoD/T1tvGHGyg6dnoS+KmfiXnT1j/R7ON+V+jH/0MZpsQwiFC5ycCPB2t 3w/g== X-Forwarded-Encrypted: i=1; AJvYcCWO8It/xut2Ws5R6KwIIayRJvgazHob9EYT9So9rOlPES5IoQjWOtfr0iGrs1oxTZfkb4ThLdPTU+/TUck=@vger.kernel.org X-Gm-Message-State: AOJu0YyVKDqo230BbFOgbYCA2Ii96LJAzJBXWQesudG7w9v0z0fsDFU8 u1bMKR7KzA4jMkdqhoGmr6h6NIjHjRB2+rt8gohW0Q+FyeaXk5UZIZPW X-Gm-Gg: ASbGncuN8DxBFmVcp/w7qG69xfOW1wqkWTp5XuWwpK5OdqhlNtvj7zcqC3hnWcoohNQ TYh2VjzHIv9gFXbJqm5rfxRi/hF/nbjB4LdXO+kvnmtbs2exRINeX6YveO28SYJh/k+FS4fHtMf iNLtmowwg9dLoKD2Ef0ZhKrDqrW3WXujr2KUcmq248TgWhW6S9A3YvrQyIliKAyiwAMPJ38eS00 ZsjblZERmsY2yJokYM0o6epusRLOPilO/Vn5T2SQrux69p1Yq4Lt2iXrcRI1GURJTtD7I6zlCkO rBmEaLjIEzZjHl1txGVUjmD9bf3tz9HdSg5Y9cpMVORwT13xn9R46dJ9lfptduLPOjp/hjQm3JZ Ap29rKwmmDjind7TIlJAYynD+EI+KZS+qVtEvwbPN8IsbRoRx/kwSm87jz7I2xPvKChQu/UggLV kUpTu6AYjuU2abgs/2HopDfioAQNC8n/KkQ/F9KC3oPIytqhVnpJPr9wEmMA56lNp7Ug2cl1rRl Q+RtK6F+QJB X-Google-Smtp-Source: AGHT+IEaxfddzIsW7EfJsH4hq5Kgg3RQ2/rfz47KNABoXSBEYYMg0uwV1ertYdf1YmLz+K9fDfpnSQ== X-Received: by 2002:a17:907:7ea5:b0:b54:185f:359c with SMTP id a640c23a62f3a-b6473149643mr898256366b.16.1760800685477; Sat, 18 Oct 2025 08:18:05 -0700 (PDT) Received: from tycho (p200300c1c7311b00ba8584fffebf2b17.dip0.t-ipconnect.de. [2003:c1:c731:1b00:ba85:84ff:febf:2b17]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b65eb036846sm259983366b.54.2025.10.18.08.18.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Oct 2025 08:18:05 -0700 (PDT) Sender: Zahari Doychev From: Zahari Doychev To: donald.hunter@gmail.com, kuba@kernel.org Cc: davem@davemloft.net, edumazet@google.com, pabeni@redhat.com, horms@kernel.org, jacob.e.keller@intel.com, ast@fiberby.net, matttbe@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us, johannes@sipsolutions.net, zahari.doychev@linux.com Subject: [PATCH 4/4] tools: ynl: add start-index property for indexed arrays Date: Sat, 18 Oct 2025 17:17:37 +0200 Message-ID: <20251018151737.365485-5-zahari.doychev@linux.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251018151737.365485-1-zahari.doychev@linux.com> References: <20251018151737.365485-1-zahari.doychev@linux.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The Linux tc actions expect that the action order starts from index one. To accommodate this, add a start-index property to the ynl spec for indexed arrays. This property allows the starting index to be specified, ensuring compatibility with consumers that require a non-zero-based index. For example if we have "start_index =3D 1" then we get the following diff. ynl_attr_put_str(nlh, TCA_FLOWER_INDEV, obj->indev); array =3D ynl_attr_nest_start(nlh, TCA_FLOWER_ACT); for (i =3D 0; i < obj->_count.act; i++) - tc_act_attrs_put(nlh, i, &obj->act[i]); + tc_act_attrs_put(nlh, i + 1, &obj->act[i]); ynl_attr_nest_end(nlh, array); Signed-off-by: Zahari Doychev --- Documentation/netlink/netlink-raw.yaml | 13 +++++++++++++ Documentation/netlink/specs/tc.yaml | 7 +++++++ tools/net/ynl/pyynl/lib/nlspec.py | 1 + tools/net/ynl/pyynl/ynl_gen_c.py | 6 +++++- 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/Documentation/netlink/netlink-raw.yaml b/Documentation/netlink= /netlink-raw.yaml index 246fa07bccf6..aafb7cb16beb 100644 --- a/Documentation/netlink/netlink-raw.yaml +++ b/Documentation/netlink/netlink-raw.yaml @@ -260,6 +260,9 @@ properties: Sometimes, however, both forms are necessary, in which c= ase header contains the enum form while specific attributes may request to convert th= e values into a bitfield. type: boolean + start-index: + description: For indexed arrays the first index value. + type: integer checks: description: Kernel input validation. type: object @@ -308,6 +311,16 @@ properties: type: string # End netlink-raw =20 + # allow start index only for indexed arrays + if: + properties: + type: + const: indexed-array + then: {} + else: + not: + required: [ start-index ] + # Make sure name-prefix does not appear in subsets (subsets inherit = naming) dependencies: name-prefix: diff --git a/Documentation/netlink/specs/tc.yaml b/Documentation/netlink/sp= ecs/tc.yaml index b398f7a46dae..459aa51059ec 100644 --- a/Documentation/netlink/specs/tc.yaml +++ b/Documentation/netlink/specs/tc.yaml @@ -2044,6 +2044,7 @@ attribute-sets: type: indexed-array sub-type: nest nested-attributes: act-attrs + start-index: 1 - name: police type: nest @@ -2303,6 +2304,7 @@ attribute-sets: type: indexed-array sub-type: nest nested-attributes: act-attrs + start-index: 1 - name: police type: nest @@ -2493,6 +2495,7 @@ attribute-sets: type: indexed-array sub-type: nest nested-attributes: act-attrs + start-index: 1 - name: key-eth-dst type: binary @@ -3020,6 +3023,7 @@ attribute-sets: type: indexed-array sub-type: nest nested-attributes: act-attrs + start-index: 1 - name: mask type: u32 @@ -3180,6 +3184,7 @@ attribute-sets: type: indexed-array sub-type: nest nested-attributes: act-attrs + start-index: 1 - name: flags type: u32 @@ -3566,6 +3571,7 @@ attribute-sets: type: indexed-array sub-type: nest nested-attributes: act-attrs + start-index: 1 - name: taprio-attrs name-prefix: tca-taprio-attr- @@ -3798,6 +3804,7 @@ attribute-sets: type: indexed-array sub-type: nest nested-attributes: act-attrs + start-index: 1 - name: indev type: string diff --git a/tools/net/ynl/pyynl/lib/nlspec.py b/tools/net/ynl/pyynl/lib/nl= spec.py index 85c17fe01e35..08660602da9d 100644 --- a/tools/net/ynl/pyynl/lib/nlspec.py +++ b/tools/net/ynl/pyynl/lib/nlspec.py @@ -181,6 +181,7 @@ class SpecAttr(SpecElement): self.display_hint =3D yaml.get('display-hint') self.sub_message =3D yaml.get('sub-message') self.selector =3D yaml.get('selector') + self.start_index =3D yaml.get('start-index', 0) =20 self.is_auto_scalar =3D self.type =3D=3D "sint" or self.type =3D= =3D "uint" =20 diff --git a/tools/net/ynl/pyynl/ynl_gen_c.py b/tools/net/ynl/pyynl/ynl_gen= _c.py index aadeb3abcad8..698d6089a856 100755 --- a/tools/net/ynl/pyynl/ynl_gen_c.py +++ b/tools/net/ynl/pyynl/ynl_gen_c.py @@ -852,7 +852,11 @@ class TypeIndexedArray(Type): ri.cw.p(f"ynl_attr_put(nlh, i, {var}->{self.c_name}[i], {self.= checks['exact-len']});") elif self.sub_type =3D=3D 'nest': ri.cw.p(f'for (i =3D 0; i < {var}->_count.{self.c_name}; i++)') - ri.cw.p(f"{self.nested_render_name}_put(nlh, i, &{var}->{self.= c_name}[i]);") + ri.cw.p( + f"{self.nested_render_name}_put(nlh, " + f"i{f' + {self.start_index}' if self.start_index > 0 else = ''}, " + f"&{var}->{self.c_name}[i]);" + ) else: raise Exception(f"Put for IndexedArray sub-type {self.attr['su= b-type']} not supported, yet") ri.cw.p('ynl_attr_nest_end(nlh, array);') --=20 2.51.0