From nobody Thu Oct 2 21:55:27 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 78B0730FF39; Wed, 10 Sep 2025 23:08:59 +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=1757545742; cv=none; b=ZsjCJXS9+ZBKXpvnl/2CLMm8EZq4jXI70m4EufVnk+bOYnerJYO5mS1AX4ec2iWNPpTaen4LwG4wX6L5FVQhRoYF3Q8v7dndMBsSFkUBIWv/tEeodpqG96i1j1le6gyXSNnxgoxNQLAxhneYTNXBbI7IuJsUzkSSRQ1GkvLiFNE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757545742; c=relaxed/simple; bh=Ns7Cgk5ZDdtF+Q6dyaF9mQHUhLgGBUAAJadXXI0Ry6M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=VE5CF+UyLCADfhSzNOqTaZDotKvX751HNhyWbR7A5a0m4eVWJKR1fBKSZX/yAajTyWqzZ+Ui7ZInhkzfrnHlkTBnwjQLsWBNumezk0PMcHXa4/u2jxSi7Rfl5fjh4M7jaEMSxdULXGWnzY1n57RTGqp+yK12lysF9HLwxLqOn9I= 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=umbYFG1d; 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="umbYFG1d" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fiberby.net; s=202008; t=1757545730; bh=Ns7Cgk5ZDdtF+Q6dyaF9mQHUhLgGBUAAJadXXI0Ry6M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=umbYFG1d5Yak61rLgZzoGxrWRIqKSxbBUaFIbuDdfZU1mTzy6jhP0VGirnCNImw5z MySboBdfMvv+xHfYnjq2OiKHmbaodKvF6CCyAAdBlSIOtlTeIHxrAZoVDIDYZ/AAQU f8hPGt6GK7+xz0sf9jKTI67/B8H3ry8VlDJpxzB47LEhd0+sFqoTtR88EB6bMrz3Xr tNkqDER4VnB7JpFKB8un/pEp2TsXF8Nj6ZGSknA20gpJ0biBm2cOxrslEhgpfxDqr6 3kuga41VpSqcsIe6zGZn5RF6MB7rskNQ0+FbYqM3LFwUozTzKpR1SGeJJHlAjcuqZJ nFet1GbCbDnSQ== Received: from x201s (193-104-135-243.ip4.fiberby.net [193.104.135.243]) by mail1.fiberby.net (Postfix) with ESMTPSA id CFABB6013B; Wed, 10 Sep 2025 23:08:50 +0000 (UTC) Received: by x201s (Postfix, from userid 1000) id 27688204E9E; Wed, 10 Sep 2025 23:08:43 +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 , Andrew Lunn , Sabrina Dubroca , wireguard@lists.zx2c4.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v2 09/12] tools: ynl: move nest packing to a helper function Date: Wed, 10 Sep 2025 23:08:31 +0000 Message-ID: <20250910230841.384545-10-ast@fiberby.net> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250910230841.384545-1-ast@fiberby.net> References: <20250910230841.384545-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 moves nest packing into a helper function, that can also be used for packing indexed arrays. No behavioural changes intended. Signed-off-by: Asbj=C3=B8rn Sloth T=C3=B8nnesen Reviewed-by: Donald Hunter --- tools/net/ynl/pyynl/lib/ynl.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tools/net/ynl/pyynl/lib/ynl.py b/tools/net/ynl/pyynl/lib/ynl.py index 8244a5f440b2..4928b41c636a 100644 --- a/tools/net/ynl/pyynl/lib/ynl.py +++ b/tools/net/ynl/pyynl/lib/ynl.py @@ -562,11 +562,8 @@ class YnlFamily(SpecFamily): =20 if attr["type"] =3D=3D 'nest': nl_type |=3D Netlink.NLA_F_NESTED - attr_payload =3D b'' sub_space =3D attr['nested-attributes'] - sub_attrs =3D SpaceAttrs(self.attr_sets[sub_space], value, sea= rch_attrs) - for subname, subvalue in value.items(): - attr_payload +=3D self._add_attr(sub_space, subname, subva= lue, sub_attrs) + attr_payload =3D self._add_nest_attrs(value, sub_space, search= _attrs) elif attr["type"] =3D=3D 'flag': if not value: # If value is absent or false then skip attribute creation. @@ -623,6 +620,14 @@ class YnlFamily(SpecFamily): 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 + def _add_nest_attrs(self, value, sub_space, search_attrs): + sub_attrs =3D SpaceAttrs(self.attr_sets[sub_space], value, search_= attrs) + attr_payload =3D b'' + for subname, subvalue in value.items(): + attr_payload +=3D self._add_attr(sub_space, subname, subvalue, + sub_attrs) + return attr_payload + def _get_enum_or_unknown(self, enum, raw): try: name =3D enum.entries_by_val[raw].name --=20 2.51.0