Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp36590268rwd; Tue, 11 Jul 2023 03:06:30 -0700 (PDT) X-Google-Smtp-Source: APBJJlGvROnD6TDG3rC29V0RwFcilb5wGngRUs1Oe/Ch1cAuSKlSJmMnaWfZTZ6Hk2D+TDa+4zSx X-Received: by 2002:a17:906:ca17:b0:96f:d780:5734 with SMTP id jt23-20020a170906ca1700b0096fd7805734mr13782576ejb.65.1689069990568; Tue, 11 Jul 2023 03:06:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689069990; cv=none; d=google.com; s=arc-20160816; b=NkjaUuH/GT7HzcAx1DoPKQ1gEQmnX/cT+MpZ2jLgG4y5D86iUi57ejbZ/faCjNPEco 9bKUsEPshqWhbsbl+2BLsAzq5km4e9H6RyhuHqnGirw7rEYXHFOo1c0VAvuDMBMmX0bn UQDAMKZOQ3lok2YQJ+QK+5oD3tmFAalHgdRyemK+M39fPAQL9y+x0zerIIztEDjoH+5Q WBNnIBilX6Wgh6aXyFt4iqjTl/YyCNONIa+IX9+5RHpgl0J9Aiesij2eeIRO8VdA4ESD 5lyOQEecOzWoPeo1d8JhZlx/KSvBzLi/W1TfBvSU9TksYlV+fDE3B5ladIpyZlcP8EWx EzQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=s23FGh0F9FFG13NIT0fd3P9KNe0H4codp8QmmoHqaTk=; fh=CUDXLPWUx+nghYiuFQsnZJzV60qd200jMWXauBw/Z04=; b=KldNllm9yVmRJrvYySUy+7PcAKGjCyJECcby0qpE7naqVD6t70ggYy6E1GQ7vLqpD6 AfLs4CSEBsA1qr1k24/4uKJH9vpGjmdY+7HgoLXygcPEdk6OkDhYmfReuG0Aw+IFIjcY QJoIrYBzaCJ7ERasYLRwRYq5DzRgo0y72vpp5rDjB0zdEsz+UzpFWcfgH4QGkW6L/dCf XMu84x8VZQb+iiC8Uql5aYwYOZ6e/4mS9i4QpN7Io9BRsCqOQEqHxM/jApf6lVyntEoF J2E5IJAYkCHa2nWcQOxY6puNRDfXYNKjZW5HIQiKnVpRJyo750FSwEO5DivpuInUaJOz j/3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=azkGVysX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qq17-20020a17090720d100b009938899a768si1563458ejb.530.2023.07.11.03.06.06; Tue, 11 Jul 2023 03:06:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=azkGVysX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231516AbjGKJz7 (ORCPT + 99 others); Tue, 11 Jul 2023 05:55:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230252AbjGKJz6 (ORCPT ); Tue, 11 Jul 2023 05:55:58 -0400 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85612A8; Tue, 11 Jul 2023 02:55:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1689069357; x=1720605357; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=Eu5iZ0jjghh5xc/XHtgk1oWVm52GiK/SZSOg8TCA4+s=; b=azkGVysXlg4gN1eMvJK3KYT/shC4DYFoEGMAjdBTD8D606Ity/0axVFw By/aQRvqMq9vA4NScvufyM4lg0BUnWk8w1AddaIWNH88t+p1t70WLfM6N 4ODj9YO4Wr2gYamxh7JG4sdddCYwlMpWwev4dphw7+rsJkqEJXM2IV79B lHtEN7ZzLBRcS2eo5kG2C+befgLGh+kJCjFA5X6W59dA9eSLYHw6EnFP2 n9bdjW/pjfEs+jC34TCgmwuZiWv9Dx/HzZyDKBc1mrsEx7GyrSe9ebr00 +Dy4wB1IwBP0LG/I3IEZHSzdfanKM50GbeteDfaIDdguOqhgOrHQ8Obei w==; X-IronPort-AV: E=McAfee;i="6600,9927,10767"; a="349385344" X-IronPort-AV: E=Sophos;i="6.01,196,1684825200"; d="scan'208";a="349385344" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jul 2023 02:55:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10767"; a="1051723761" X-IronPort-AV: E=Sophos;i="6.01,196,1684825200"; d="scan'208";a="1051723761" Received: from amlin-018-114.igk.intel.com ([10.102.18.114]) by fmsmga005.fm.intel.com with ESMTP; 11 Jul 2023 02:55:31 -0700 From: Arkadiusz Kubalewski To: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kuba@kernel.org, davem@davemloft.net, pabeni@redhat.com, edumazet@google.com, chuck.lever@oracle.com Cc: Arkadiusz Kubalewski Subject: [PATCH net-next] tools: ynl-gen: fix parse multi-attr enum attribute Date: Tue, 11 Jul 2023 11:53:23 +0200 Message-Id: <20230711095323.121131-1-arkadiusz.kubalewski@intel.com> X-Mailer: git-send-email 2.37.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When attribute is enum type and marked as multi-attr, the netlink respond is not parsed, fails with stack trace: File "/root/arek/linux-dpll/tools/net/ynl/lib/ynl.py", line 600, in dump return self._op(method, vals, dump=True) File "/root/arek/linux-dpll/tools/net/ynl/lib/ynl.py", line 586, in _op rsp_msg = self._decode(gm.raw_attrs, op.attr_set.name) File "/root/arek/linux-dpll/tools/net/ynl/lib/ynl.py", line 453, in _decode self._decode_enum(rsp, attr_spec) File "/root/arek/linux-dpll/tools/net/ynl/lib/ynl.py", line 410, in _decode_enum value = enum.entries_by_val[raw - i].name TypeError: unsupported operand type(s) for -: 'list' and 'int' error: 1 Allow succesfull parse of multi-attr enums by decoding and assigning their names into response in the _decode_enum(..) function. Signed-off-by: Arkadiusz Kubalewski --- tools/net/ynl/lib/ynl.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/net/ynl/lib/ynl.py b/tools/net/ynl/lib/ynl.py index 3b343d6cbbc0..553d82dd6382 100644 --- a/tools/net/ynl/lib/ynl.py +++ b/tools/net/ynl/lib/ynl.py @@ -407,7 +407,14 @@ class YnlFamily(SpecFamily): raw >>= 1 i += 1 else: - value = enum.entries_by_val[raw - i].name + if attr_spec.is_multi: + for index in range(len(raw)): + if (type(raw[index]) == int): + enum_name = enum.entries_by_val[raw[index] - i].name + rsp[attr_spec['name']][index] = enum_name + return + else: + value = enum.entries_by_val[raw - i].name rsp[attr_spec['name']] = value def _decode_binary(self, attr, attr_spec): -- 2.37.3