From nobody Thu Oct 2 20:45:50 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 038B32DC784; Thu, 11 Sep 2025 20:05:30 +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=1757621132; cv=none; b=gclZt+G520TMf9LLH42zZDVAmg5ADcUqIoCZi8VxsNSakSAeuU71F+lHfgTryXxBTlE+RINguB53LYJRgWygOvaTz2avd3KkImCVEVhKRwNXxZhoM6MHBehPMXHWNukItpA936+Jz+PvDv0dlqnQrlsASFBTmzSJyyTYsgM/+u0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757621132; c=relaxed/simple; bh=cBJ8N3+usDyC0kts12vANVIdZbJUEHQHgUg3Ehv0XcY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=t03y6KSiSQ3pqXV3WjOHsk5S6m4yPJWHO9IX4++mzIs2Ty3/bQfS8G2DgCnxRRuNV+gNGnL0fL3fBkPAOLDb6615w/SdnpZRdj2Tnhq0nSCi8Wqj9hRaPWSjadzXNerpYK/ZZw9Ybc9FLk1vQ1h4vO7NSMh3WObmmb4XLV+MAlA= 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=p954Zw0D; 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="p954Zw0D" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fiberby.net; s=202008; t=1757621127; bh=cBJ8N3+usDyC0kts12vANVIdZbJUEHQHgUg3Ehv0XcY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p954Zw0DXV1nCLEnrXMHUbaYWpXk6FPwoHeSN8IJ2aGGThLLjS0F79TIjgvs+v2Af siMe/sDs+zpTlU9xPE2sPnC+CflXGs3Tdg6YZ1Ae3rdEVIa1vc9/9WbDEjKW3bjNe5 WSPsVDnzMWtOlI1Ed5zDZQ8daypp79UcicpFhfqBod3m9KsrJm5xrE51/4uQ9+WOVu 5OCLFQwMx9kRh8COcEkVqdV3HvLWjdumVIdpqI6AtSyB6ML5KDZf0B8cgoCMCb8XKF lP77tJgd8+3iZcLyym/Z5wHSSGhwaceWgtmh2efqqRPxLEAB7kj3f0t0HnNYf6iDJF QJSAo9v+lD+gw== Received: from x201s (193-104-135-243.ip4.fiberby.net [193.104.135.243]) by mail1.fiberby.net (Postfix) with ESMTPSA id 8DFED600C4; Thu, 11 Sep 2025 20:05:26 +0000 (UTC) Received: by x201s (Postfix, from userid 1000) id 46FA62054AD; Thu, 11 Sep 2025 20:05:21 +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 v3 11/13] tools: ynl: encode indexed-arrays Date: Thu, 11 Sep 2025 20:05:04 +0000 Message-ID: <20250911200508.79341-12-ast@fiberby.net> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250911200508.79341-1-ast@fiberby.net> References: <20250911200508.79341-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