From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 585E53B2AB for ; Thu, 26 Oct 2023 19:31:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="dd8cu/aU" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 913CDC433C8; Thu, 26 Oct 2023 19:30:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1698348659; bh=YGvTcDodB0sRAjcNb1b1GrCpOY2psaPKQ0iCqLIPzxA=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=dd8cu/aUDOlAWrvhfXjMP1d3r3W4EQe/Be0iZEF2TunImVpx64rnP/tcKAKV4Kad0 iM8BZsWlKtdqUsvegnbpMfgcwgrpDCb1XUVXYlSu8xeSpg875zPWM5+KtzK/urpPNf opTHG5sS/2k4NRJ/XoFtsd6OHhAM1iTHJoSW2kCYRvJNCwuGuVuMhrl+Tt42lqwxZR q8w7JWDxP7CH+vrTUcaQaNzNRVd0QgnHsyJtsv5QdL6PZDfngr2CGhqCidc31r8mXZ aKJic+moVk3tn+cLJvg7P+/JXZnqZCREXJBMpmFWrb16WT2i4+A1IaYhaGdTzSowWK gXN1oxHbomzqw== Date: Thu, 26 Oct 2023 12:30:58 -0700 From: Jakub Kicinski To: Jiri Pirko Cc: netdev@vger.kernel.org, pabeni@redhat.com, davem@davemloft.net, edumazet@google.com Subject: Re: [patch net-next v3] tools: ynl: introduce option to process unknown attributes or types Message-ID: <20231026123058.140072c7@kernel.org> In-Reply-To: References: <20231025095736.801231-1-jiri@resnulli.us> <20231025175636.2a7858a6@kernel.org> <20231026074120.6c1b9fb5@kernel.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Thu, 26 Oct 2023 18:25:14 +0200 Jiri Pirko wrote: > Thu, Oct 26, 2023 at 04:41:20PM CEST, kuba@kernel.org wrote: > >On Thu, 26 Oct 2023 07:42:33 +0200 Jiri Pirko wrote: > >> {'129': {'0': [type:0 len:12] b'\x00\x00\x00\x00\x00\x00\x00\x00', > >> '1': [type:1 len:12] b'\x00\x00\x00\x00\x00\x00\x00\x00', > >> '2': [type:2 len:12] b'(\x00\x00\x00\x00\x00\x00\x00'}, > >> Looks like unnecessary redundant info, I would rather stick with > >> "as_bin()". __repr__() is printable representation of the whole object, > >> we just need value here, already have that in a structured object. > >> > >> > >> What is "type" and "len" good for here? > > > >I already gave you a longer explanation, if you don't like the > >duplication, how about you stop keying them on a (stringified?!) id. > > I don't care that much, it just looks weird :) As I said my key requirement is that the NlAttr object must still be there in the result. Maybe a good compromise is to stick it into the key, instead of the value. Replacing the stringified type id. Then you can keep the value as binary. We'd need to wrap it into another class but whatever, compromises. IDK how this works in Python exactly but to give you a rough idea here's pseudo code typed in the email client: class UnknownNlAttrKey: def __init__(self, nlattr): self.nla = nlattr def __hash__(self): return self.nla.type def __eq__(self, other): if isintance(other, Unknown...): return other.nla.type == self.nla.type return False def __repr__(): return f"UnknownAttr({self.nla.type})"