Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp1148715lqj; Mon, 3 Jun 2024 11:34:04 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUHzLkvQjGVsa733nxQY+6nZEzXkn24rKxWObQWDMw9mv6WBKZ/ZporMWujT8JWniraMQ+u4k2KJpNAAX4AD2Q0l+I8tpiVh36YS8vdUw== X-Google-Smtp-Source: AGHT+IGMN9XeesG2cd5hnA4MsVP/Hoamb4+NNriQmqqHLPvrI7xsJfj9puGgZRud0+6iuW2mkWx7 X-Received: by 2002:a05:6a20:7352:b0:1b2:63d6:33f9 with SMTP id adf61e73a8af0-1b2a2bca8c0mr676533637.9.1717439643986; Mon, 03 Jun 2024 11:34:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717439643; cv=pass; d=google.com; s=arc-20160816; b=t0GKZFYFdUynHcS8LQ61E2TVpwWGlDpAXGsS3vnA/ZsTtKV9RZ3pxrcN70fSQesunL I+VblsBdrUnSObTnNXbDt2nGvmSvnlinW7SVhA/sjyFgk6l5u28dPqRQUa3G4zfMVAEx MuZIOOqys+ChXz+GpwzrXQuMMybvKEBrlbOJsj+qNSxk9XhX97gCGNwAy/jjBoE/4qwu TIRwchcb8ejFgjOlJyBZVkE37c2CBAYHK2LVY3LmCMsj/Y7qkWOdG11AZtdyqy4qfjjX YeS9K0IDag3iFeMC5g3LYkriHKYtgSQjQcnDSt2opcnAn/0ON5gi0LhwKG7MhFLHZJPr OHUA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=Yl8vr4y8a6U6pmG4DWdxKYXNybm3u7Z5la/ggzjv+O4=; fh=VMyCzG+WExgov7v2Eb8Kb+CQEhPnYDAG9BHQAjg0+gE=; b=hV85EF2juLWB7lMuB6IRAiupeCa/pvZqdV4bx6QbtOUzYRzby6Hve/3U3APPd1oxpG krLkB2YWqJABplQpqZ9aAW9dubPi4anz0VD6dvTMaW+EXQaEMZte3nxr7VRqn2O6M84j DfVcEophUBDIXxBJYYGVweOi75Y/WtjXsCsLgRTdYN5O9GrJkvWkuASX47NpGFudYeQA alIJh2/QmK2jRWeQC0afRMsMrDHtx9gTq4e/YnBdND563WNWlqNMibWImYdHEEGR7SrU 81IiInWfRF+zOv+IRHEa0N9AafjcHv84bcSb9VNHJ80wKkKjoGlzvFcrPLAxnd0NaC0L bY+A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=IGFrvrzt; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-199566-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199566-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id 41be03b00d2f7-6c35b40c5c5si7127601a12.540.2024.06.03.11.34.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jun 2024 11:34:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-199566-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=IGFrvrzt; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-199566-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199566-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 0A65BB20E6F for ; Mon, 3 Jun 2024 18:31:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1023A139587; Mon, 3 Jun 2024 18:31:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="IGFrvrzt" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 9CA491CD38 for ; Mon, 3 Jun 2024 18:31:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717439493; cv=none; b=AU6kma0XckgsXPD7faOmuc3Z48i0FN1DEoaEabrZMR/fI5nlFNlik6j8pDzOOUAIm8gPgZTt+HHLMddla5zO6d6wc5InnbbLhRkcpQcCmyZk76i+wz7MFdoCoNyA1EOIoodxA6brrc2VSwcw/7q0A+tXkOH6fSO2qaphXWIgNOc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717439493; c=relaxed/simple; bh=qsya4nkJf9ItcPXlY7BN+r2obn6IM42sPgazzJIezz0=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=LYJtb+zgTk1VsuqgruM5rGzZAXvHrVQzNftI5xgh496rK8BC1GPOrUUZXle/upNHsXCNQ6NYHMR87SE9oNM4P4QgusbcgOJ3DJVm9maEMG7fjGd9gCG2HIXfXCkFtjvg0VGWGhUS7kptCUecy4gajenelWxtttdyW3G793GzaPw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=IGFrvrzt; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717439490; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=Yl8vr4y8a6U6pmG4DWdxKYXNybm3u7Z5la/ggzjv+O4=; b=IGFrvrzt5ZnvrsYlo1b+jnZs9tFI4iT/w805Sv9O12m+SosSae8CyngbYU6S0t54qnM5Mc Cl4OnHltCvCp1RqsUbzalHeQxmalcVkfFoz2rr2ISxXWhhcWS6cy+qHPZLtS8QbP0teJ+6 AY3IvShubv0+GJRnxDfSTniF5dJ0km0= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-602-ggZ-nkC7PtaeEckWHU-_Fg-1; Mon, 03 Jun 2024 14:31:25 -0400 X-MC-Unique: ggZ-nkC7PtaeEckWHU-_Fg-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 19C038058D7; Mon, 3 Jun 2024 18:31:25 +0000 (UTC) Received: from antares.redhat.com (unknown [10.39.193.112]) by smtp.corp.redhat.com (Postfix) with ESMTP id 93EC2105017A; Mon, 3 Jun 2024 18:31:22 +0000 (UTC) From: Adrian Moreno To: netdev@vger.kernel.org Cc: aconole@redhat.com, Adrian Moreno , Pravin B Shelar , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan , dev@openvswitch.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 1/2] selftests: openvswitch: fix action formatting Date: Mon, 3 Jun 2024 20:31:19 +0200 Message-ID: <20240603183121.2305013-1-amorenoz@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 In the action formatting function ("dpstr"), the iteration is made over the nla_map, so if there are more than one attribute from the same type we only print the first one. Fix this by iterating over the actual attributes. Signed-off-by: Adrian Moreno --- .../selftests/net/openvswitch/ovs-dpctl.py | 48 +++++++++++-------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/tools/testing/selftests/net/openvswitch/ovs-dpctl.py b/tools/testing/selftests/net/openvswitch/ovs-dpctl.py index 1dd057afd3fb..b76907ac0092 100644 --- a/tools/testing/selftests/net/openvswitch/ovs-dpctl.py +++ b/tools/testing/selftests/net/openvswitch/ovs-dpctl.py @@ -437,40 +437,46 @@ class ovsactions(nla): def dpstr(self, more=False): print_str = "" - for field in self.nla_map: - if field[1] == "none" or self.get_attr(field[0]) is None: + for attr_name, value in self["attrs"]: + attr_desc = next(filter(lambda x: x[0] == attr_name, self.nla_map), + None) + if not attr_desc: + raise ValueError("Unknown attribute: %s" % attr) + + attr_type = attr_desc[1] + + if attr_type == "none": continue if print_str != "": print_str += "," - if field[1] == "uint32": - if field[0] == "OVS_ACTION_ATTR_OUTPUT": - print_str += "%d" % int(self.get_attr(field[0])) - elif field[0] == "OVS_ACTION_ATTR_RECIRC": - print_str += "recirc(0x%x)" % int(self.get_attr(field[0])) - elif field[0] == "OVS_ACTION_ATTR_TRUNC": - print_str += "trunc(%d)" % int(self.get_attr(field[0])) - elif field[0] == "OVS_ACTION_ATTR_DROP": - print_str += "drop(%d)" % int(self.get_attr(field[0])) - elif field[1] == "flag": - if field[0] == "OVS_ACTION_ATTR_CT_CLEAR": + if attr_type == "uint32": + if attr_name == "OVS_ACTION_ATTR_OUTPUT": + print_str += "%d" % int(value) + elif attr_name == "OVS_ACTION_ATTR_RECIRC": + print_str += "recirc(0x%x)" % int(value) + elif attr_name == "OVS_ACTION_ATTR_TRUNC": + print_str += "trunc(%d)" % int(value) + elif attr_name == "OVS_ACTION_ATTR_DROP": + print_str += "drop(%d)" % int(value) + elif attr_type == "flag": + if attr_name == "OVS_ACTION_ATTR_CT_CLEAR": print_str += "ct_clear" - elif field[0] == "OVS_ACTION_ATTR_POP_VLAN": + elif attr_name == "OVS_ACTION_ATTR_POP_VLAN": print_str += "pop_vlan" - elif field[0] == "OVS_ACTION_ATTR_POP_ETH": + elif attr_name == "OVS_ACTION_ATTR_POP_ETH": print_str += "pop_eth" - elif field[0] == "OVS_ACTION_ATTR_POP_NSH": + elif attr_name == "OVS_ACTION_ATTR_POP_NSH": print_str += "pop_nsh" - elif field[0] == "OVS_ACTION_ATTR_POP_MPLS": + elif attr_name == "OVS_ACTION_ATTR_POP_MPLS": print_str += "pop_mpls" else: - datum = self.get_attr(field[0]) - if field[0] == "OVS_ACTION_ATTR_CLONE": + if attr_name == "OVS_ACTION_ATTR_CLONE": print_str += "clone(" - print_str += datum.dpstr(more) + print_str += value.dpstr(more) print_str += ")" else: - print_str += datum.dpstr(more) + print_str += value.dpstr(more) return print_str -- 2.45.1