From nobody Thu Oct 2 15:34:57 2025 Received: from mail1.fiberby.net (mail1.fiberby.net [193.104.135.124]) (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 E1840340DAB; Mon, 15 Sep 2025 14:47:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.104.135.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757947674; cv=none; b=d91ubmHq3BMCKtFOPVXnj10ranPU5/yk0geEgqzERxqG/4YnqdS3QLOseRG96NwBVB18cUB6PSyCpQCrKKUy68BJfGg4MuE+X/vrIZAWZkbp3H5lgOugCdeXQWDsqMyEBEyPkVgPaKqKgsC4n5sxwZ2RKU7ODMUBBTq7Ih/y8r8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757947674; c=relaxed/simple; bh=+xB7OdBH5/hOoPqTnhZSd84UXQV32QC9Igc+BZIJ9TQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=lzvMoooF5NKvtLVK9eyuTIwwiKoLp8T2m6AZ3KFGf3utjyF2P+tB41mm2CyDlSFc66Wt1RS/CU7MKv8iAGK8nO64qLJHIkLm32rv34YgJQ+FPXb7Hz5Ko5MOau0cq0YwUvugThxlnW0FGIICAxT+3XBvHcOr9JzswS9HYzeMjKU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fiberby.net; spf=pass smtp.mailfrom=fiberby.net; dkim=pass (2048-bit key) header.d=fiberby.net header.i=@fiberby.net header.b=R3xdIgxC; arc=none smtp.client-ip=193.104.135.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fiberby.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fiberby.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=fiberby.net header.i=@fiberby.net header.b="R3xdIgxC" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fiberby.net; s=202008; t=1757947661; bh=+xB7OdBH5/hOoPqTnhZSd84UXQV32QC9Igc+BZIJ9TQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R3xdIgxCeA3n4EbMNYcIrRdec2kx3Q55RbVNs+fSZKSnNH5f96l+aN38xj69pVEAt db26hmc7StGFTbOrlTaTgzK1klDBXy7P1S7lqjLT6P/LWOC5cvG6Bj5dRfeskgLJpZ /R2sICGICoqeRWvob38nD55yijrLSrt268BJkwPAJrq0IhSxX1jy2I51aRjxuSUBLl vQ0XTBI1pTD9sALnALoMt25Kb+Kv+7lFY+ArK6S7FbU0eu7TnKpn0psSQ2PQ//7XNP Leyzagw/8nm2vQsAzjv6hvQOIJSlZuk8JrN/8jiNamkdoJqAS4Gso4KCtKEcIudQ3l IFk5MM98qlD5Q== Received: from x201s (193-104-135-243.ip4.fiberby.net [193.104.135.243]) by mail1.fiberby.net (Postfix) with ESMTPSA id 1A8A960140; Mon, 15 Sep 2025 14:47:41 +0000 (UTC) Received: by x201s (Postfix, from userid 1000) id 60EC0204FB3; Mon, 15 Sep 2025 14:43:06 +0000 (UTC) From: =?UTF-8?q?Asbj=C3=B8rn=20Sloth=20T=C3=B8nnesen?= To: "Jason A. Donenfeld" , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: =?UTF-8?q?Asbj=C3=B8rn=20Sloth=20T=C3=B8nnesen?= , Donald Hunter , Simon Horman , Jacob Keller , Sabrina Dubroca , wireguard@lists.zx2c4.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v5 09/11] tools: ynl: encode indexed-arrays Date: Mon, 15 Sep 2025 14:42:54 +0000 Message-ID: <20250915144301.725949-10-ast@fiberby.net> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250915144301.725949-1-ast@fiberby.net> References: <20250915144301.725949-1-ast@fiberby.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable This patch adds support for encoding indexed-array attributes with sub-type nest in pyynl. Signed-off-by: Asbj=C3=B8rn Sloth T=C3=B8nnesen Reviewed-by: Donald Hunter --- tools/net/ynl/pyynl/lib/ynl.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tools/net/ynl/pyynl/lib/ynl.py b/tools/net/ynl/pyynl/lib/ynl.py index 92ff26f34f4d..9fd83f8b091f 100644 --- a/tools/net/ynl/pyynl/lib/ynl.py +++ b/tools/net/ynl/pyynl/lib/ynl.py @@ -563,6 +563,11 @@ class YnlFamily(SpecFamily): nl_type |=3D Netlink.NLA_F_NESTED sub_space =3D attr['nested-attributes'] attr_payload =3D self._add_nest_attrs(value, sub_space, search= _attrs) + elif attr['type'] =3D=3D 'indexed-array' and attr['sub-type'] =3D= =3D 'nest': + nl_type |=3D Netlink.NLA_F_NESTED + sub_space =3D attr['nested-attributes'] + attr_payload =3D self._encode_indexed_array(value, sub_space, + search_attrs) elif attr["type"] =3D=3D 'flag': if not value: # If value is absent or false then skip attribute creation. @@ -616,6 +621,9 @@ class YnlFamily(SpecFamily): else: raise Exception(f'Unknown type at {space} {name} {value} {attr= ["type"]}') =20 + return self._add_attr_raw(nl_type, attr_payload) + + def _add_attr_raw(self, nl_type, attr_payload): pad =3D b'\x00' * ((4 - len(attr_payload) % 4) % 4) return struct.pack('HH', len(attr_payload) + 4, nl_type) + attr_pa= yload + pad =20 @@ -627,6 +635,14 @@ class YnlFamily(SpecFamily): sub_attrs) return attr_payload =20 + def _encode_indexed_array(self, vals, sub_space, search_attrs): + attr_payload =3D b'' + for i, val in enumerate(vals): + idx =3D i | Netlink.NLA_F_NESTED + val_payload =3D self._add_nest_attrs(val, sub_space, search_at= trs) + attr_payload +=3D self._add_attr_raw(idx, val_payload) + return attr_payload + def _get_enum_or_unknown(self, enum, raw): try: name =3D enum.entries_by_val[raw].name --=20 2.51.0