From nobody Thu Oct 2 18:33:48 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 688DB2C11CC; Sat, 13 Sep 2025 23:59:15 +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=1757807958; cv=none; b=etPZK/wbO0xEB+MFbN3CbAFSauJYZN1nao/IkjuiLaYZFEDS0i9cd8LWjdKCpquaBMXeOwHJU72wjDP5a2d1oTH5YhJBcA21FUXzMFZHCAaSja31039HnIBmeYJSnEHbJ5RdEdYalz33GsOwE8PK61F6iHG5b2rRcYdzW8zwOdE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757807958; c=relaxed/simple; bh=HqyIhwC1Ng9W9Rs+TyJnvWCNwSRIXH4apSsRMl21lQA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=FO4easMbd057oqpn1Km4wLoiDryxSMD+Kl5ehOLY5HTG1j/CZrnwm7vCIEFYPtN2MGWvPXRQzT9ei7vaSymbIKwUA1f/l7G7kK9ytzMEfHrfrQ6lRELSA7NlXC8iGO3jde/w0bYkfvZy2uwlZNwcUO+XeLzh7iSiJqSv+hHjr1s= 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=le4JH8fI; 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="le4JH8fI" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fiberby.net; s=202008; t=1757807952; bh=HqyIhwC1Ng9W9Rs+TyJnvWCNwSRIXH4apSsRMl21lQA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=le4JH8fI75erN98H+o4YToCsQY9N/LYcIKUefNNJf85hoyeGBl4urZHbdkoQvJN7D nIDk0FzfygsPBlrMH0toZpnFxJnBsP2nS4lXsh1TSKHalHXC7BjAHJ4nPENP6rfafq isDbhCLIspbDwifBF0NbPADXdrEb3ZORL8iZ0B7r5u1mSME7keRU0cgCACfn8RXY/E PzqgugldhzK42isqyrxuvg3fkDm0GCoflVS1ue60SyVZNjirz9fHjC+WqU9bb/GZib pWypIMyXCqDuxC6jPyrQpGnedCZwwlAaYTIV5QhcFsh8aNNO5ZyNU08K29bgEIPqpz 7IT2XDlhiDqiA== Received: from x201s (193-104-135-243.ip4.fiberby.net [193.104.135.243]) by mail1.fiberby.net (Postfix) with ESMTPSA id 5585A600C4; Sat, 13 Sep 2025 23:59:12 +0000 (UTC) Received: by x201s (Postfix, from userid 1000) id 75069204E9E; Sat, 13 Sep 2025 23:58:57 +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 v4 08/11] tools: ynl: move nest packing to a helper function Date: Sat, 13 Sep 2025 23:58:29 +0000 Message-ID: <20250913235847.358851-9-ast@fiberby.net> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250913235847.358851-1-ast@fiberby.net> References: <20250913235847.358851-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 50805e05020a..92ff26f34f4d 100644 --- a/tools/net/ynl/pyynl/lib/ynl.py +++ b/tools/net/ynl/pyynl/lib/ynl.py @@ -561,11 +561,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. @@ -622,6 +619,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