Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp332453lqs; Thu, 13 Jun 2024 11:15:13 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWAP+F5LgHeICdQ7VWh+lZR9WR1s/bHpmYByeUxa5XX84laEx3pBlkGYXfsTs6LYEO8x5BWeDVa0+yPq7P9+jskXSjm+kf3N9l5sKgpLA== X-Google-Smtp-Source: AGHT+IF6kP97kfJRRRw7gSuVde7RbZ7GVovsGBRJ44BJDVC3P/PKaGjFCU4cFX8FbBFQ6ISQs4Rb X-Received: by 2002:a17:906:aeda:b0:a6e:facf:f982 with SMTP id a640c23a62f3a-a6f60d2c79amr40192866b.23.1718302513799; Thu, 13 Jun 2024 11:15:13 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718302513; cv=pass; d=google.com; s=arc-20160816; b=HoGmsf6IPKRoWDKSdgk0L6+qyz+RhZCsdvur6+WEwIIcYCEZSZqeIgGgCFnH+aYam1 530HJIPQ8pJKpVzmQNpHyi/IeQXsQ/yTzoLxEnQZQZ6a3N3zM9S6zIE9OtmI6CPPTYlA yIaS1U+V0tpFUQH4BlKEswpAdu+VE1zIBbC/rbRt8BRPw9Zs8yDj8u0NdDlSvjPW9/TN fL6GFC2L5TQdfywScKlID/bdqMvll3CVTmEc071auN19MQMmi9M5REcYKzZYPiwWKIqh BOsA8T87gHoZghW5upNA7nevz9BKuhFjE8j3E/Ii+N6p1HO1/ficWFLylIa6eO1pCOIB e1jw== 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:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=iLGJvpvd4CEYNzpdVDTbnwnMoftXigk8Jqf38C6TROA=; fh=HLI0XJ/48QKNENdGc+eTHiBFCXj3cne18WbXVwR06EE=; b=e/wtQaGgTWT5MXUiLy5ZfP7eLm/kGvrs4/jjNcjCUVSWnVNanI8wu+aNqgJYQL5774 scIKp5dd2k1vcqPGihm0gdc0T0CT6DCryy2dtIxv9Ti1AbfQMr6fO9gg8pqwPH6WtU6/ AGw4YffJRODjEmSlJgS0+qRYWIGhw7p6I06F9IQqJbZA31i77YLVmZ7vTjcj/uMxR3bc KzI2X1gySfsWY+ij/cCK2PEq280L2gqyF5G4lLVvFVzKhuy6u1ATnyXqSyaWAdtyrzMH ZJ+BB+lbqHH026VofdCaP9SRbP1tU12uyg8TILovN7mKca+pQki0Bgxb0pU3bffUmoYV ayRw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=S97nzmW0; 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-213800-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-213800-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a6f56e887ffsi93100066b.1054.2024.06.13.11.15.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jun 2024 11:15:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-213800-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=S97nzmW0; 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-213800-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-213800-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 7E4991F22D84 for ; Thu, 13 Jun 2024 18:15:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D1C0014EC7E; Thu, 13 Jun 2024 18:13:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="S97nzmW0" 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 7BCB114B07F for ; Thu, 13 Jun 2024 18:13:50 +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=1718302435; cv=none; b=D8G7wZmutERBlbMDsSPmRxazmKxTK+B3P0Pv9BsFEgiIf/Qx/35rG8odV6A5H3SfhqVSReD/4yYX7oU75C7FTHpWr8uCfGFKLNCPKNYZk2n8MTMlENFuyiPRx2GW6nnnOdf+g/GJocR2FAo8CyI3LmNFxd+i7NyxdjLYfRdl/14= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718302435; c=relaxed/simple; bh=PIMrBNZ+QcTFTWCK6HJzPESDq0Olq4pAwKK/9jAnwRM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PidSotzGZOVgrLHLL1m+8UTX6vflG5VOxecXU3E8moqs/6UTucIxI3n0hEWrQFYH5qdi3TitrNpcA5WNJ5/BYN2hsj5C0avafOseUBx0DZLncFct/Gj6mi0dJ+psbxwKPBCHliZf4WxKMzRK2vUwQzMJ4eTHTktq67ND/OIvOr8= 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=S97nzmW0; 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=1718302429; 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: in-reply-to:in-reply-to:references:references; bh=iLGJvpvd4CEYNzpdVDTbnwnMoftXigk8Jqf38C6TROA=; b=S97nzmW0EHDSC93A4zjdqQ9SVAD7dxc5F9UaoJx7mofShX7Y7+L1Tenyqj1p5Jdb6mdS3j wKob7Wc7ndE80H4chAQZAiHWWyqMZp894CJsUkA8kT71VlmtrotivUu5l2zoC4FMwjm6AU lSdeLAo62q6QZcLovomNsvLW0r5z8QI= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-330-N1OsEcEROEenTGiR3NVz4Q-1; Thu, 13 Jun 2024 14:13:46 -0400 X-MC-Unique: N1OsEcEROEenTGiR3NVz4Q-1 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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 mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7164419560B4; Thu, 13 Jun 2024 18:13:44 +0000 (UTC) Received: from RHTRH0061144.redhat.com (unknown [10.22.16.41]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 9E3A019560BF; Thu, 13 Jun 2024 18:13:41 +0000 (UTC) From: Aaron Conole To: netdev@vger.kernel.org Cc: dev@openvswitch.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Pravin B Shelar , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan , Adrian Moreno , Stefano Brivio , Ilya Maximets Subject: [RFC net-next 2/7] selftests: openvswitch: Refactor actions parsing. Date: Thu, 13 Jun 2024 14:13:28 -0400 Message-ID: <20240613181333.984810-3-aconole@redhat.com> In-Reply-To: <20240613181333.984810-1-aconole@redhat.com> References: <20240613181333.984810-1-aconole@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.0 on 10.30.177.12 Until recently, the ovs-dpctl utility was used with a limited actions set and didn't need to have support for multiple similar actions. However, when adding support for tunnels, it will be important to support multiple set() actions in a single flow. When printing these actions, the existing code will be unable to print all of the sets - it will only print the first. Refactor this code to be easier to read and support multiple actions of the same type in an action list. Signed-off-by: Aaron Conole --- .../selftests/net/openvswitch/ovs-dpctl.py | 45 ++++++++++--------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/tools/testing/selftests/net/openvswitch/ovs-dpctl.py b/tools/testing/selftests/net/openvswitch/ovs-dpctl.py index 56f6bd162d3e..73768f3af6e5 100644 --- a/tools/testing/selftests/net/openvswitch/ovs-dpctl.py +++ b/tools/testing/selftests/net/openvswitch/ovs-dpctl.py @@ -439,32 +439,30 @@ class ovsactions(nla): def dpstr(self, more=False): print_str = "" - for field in self.nla_map: + for field in self["attrs"]: if field[1] == "none" or self.get_attr(field[0]) is 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": - print_str += "ct_clear" - elif field[0] == "OVS_ACTION_ATTR_POP_VLAN": - print_str += "pop_vlan" - elif field[0] == "OVS_ACTION_ATTR_POP_ETH": - print_str += "pop_eth" - elif field[0] == "OVS_ACTION_ATTR_POP_NSH": - print_str += "pop_nsh" - elif field[0] == "OVS_ACTION_ATTR_POP_MPLS": - print_str += "pop_mpls" + 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[0] == "OVS_ACTION_ATTR_CT_CLEAR": + print_str += "ct_clear" + elif field[0] == "OVS_ACTION_ATTR_POP_VLAN": + print_str += "pop_vlan" + elif field[0] == "OVS_ACTION_ATTR_POP_ETH": + print_str += "pop_eth" + elif field[0] == "OVS_ACTION_ATTR_POP_NSH": + print_str += "pop_nsh" + elif field[0] == "OVS_ACTION_ATTR_POP_MPLS": + print_str += "pop_mpls" else: datum = self.get_attr(field[0]) if field[0] == "OVS_ACTION_ATTR_CLONE": @@ -472,7 +470,10 @@ class ovsactions(nla): print_str += datum.dpstr(more) print_str += ")" else: - print_str += datum.dpstr(more) + try: + print_str += datum.dpstr(more) + except: + print_str += "{ATTR: %s not decoded}" % field[0] return print_str -- 2.45.1