Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp332910lqs; Thu, 13 Jun 2024 11:15:55 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVbqfQVylczV4dGBPci5mIM4/1/RGgGzXzBwCXGg5OAFto8WFbnyz8AJ6lk+9z8OAgvGF9OqrFNIlq66+gNdoL/GaVlQ1RjHTrjEw4ljA== X-Google-Smtp-Source: AGHT+IFFahdDoj+Lfepg6Tmyk6h9T1M+R923hGVp+1WgiVjRJPw3ruFQatSdmepJwHzTTEd8N5ha X-Received: by 2002:a05:6358:5317:b0:19f:2f51:d6db with SMTP id e5c5f4694b2df-19fa9dece76mr70220355d.6.1718302555154; Thu, 13 Jun 2024 11:15:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718302555; cv=pass; d=google.com; s=arc-20160816; b=WB0gfTlstzn5m1Osg5XQG4FBeKXFZnwuBKSsdfq0KNGfSxJ1exKlwxQ8Gg2ofFL9Il 2L+zb0XA4DdGooOm+KoNtydlcxOnYO4aYbQu0/dsAImcvTVeIosMpS32iBzelIj9hgMW RCpx8tubgYHThGbKlmfh0MmMVVM32+t1ikDGFOgEpS8uloRWtC9sUV/IhOS87XOGq8XR mZz4NKZrYNwM+NRG0vWp8laf7W/Qw/7pDwMHFJI4i2/IBjQoupEGqn9HKZYioFy7bXxA KT0hjSphsFk/Eu30ieGxHM5YcqgcCE19XB05/Nx8hAubaTv7UJ3KROfyz5yuSdbUODEf HB+w== 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=SBn7Y/AGY6HbNkoDSXw9yPDY45ccM5JWbhy8cP5+0Oo=; fh=HLI0XJ/48QKNENdGc+eTHiBFCXj3cne18WbXVwR06EE=; b=nBGNa/9fSetAODgQ0ff/qlVYIlgxoUVQNn8zbYtdLDqUO8oDYoPPm0f1iKyWEKb7/n sG95EL7bzQ5FRGvV85XOhJlTAYnJTUav2iChYvkHkmJ5hTh8xFp2wM1NpWE20SLVhpUr A4OHUxVGr/QvdAwqP4NWV/vWYVN2gKyolvVN1zAptX7tXbLuiNRVEkEGZmL9PA1g8aXa kr1gb2du8xgRgnaaPvE0K3X9E/T1Fwnq6Ii5JgxZYbnu8O0eLR9BmLPh2LXdATuB9d7m +N6k09uVJ7Xc2IutGNzZuFxEdCF/KjZxQlWysFli9DC1QRxp0dH7Tz4JCU/VwdI3cARn epWw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=MxsZxIxm; 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-213802-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-213802-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id 6a1803df08f44-6b2a5a1723asi20518366d6.115.2024.06.13.11.15.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jun 2024 11:15:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-213802-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=MxsZxIxm; 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-213802-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-213802-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id CC5A51C21D1A for ; Thu, 13 Jun 2024 18:15:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B22C3156243; Thu, 13 Jun 2024 18:14:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="MxsZxIxm" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 4F0F6155A55 for ; Thu, 13 Jun 2024 18:14:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718302442; cv=none; b=sCOm8v4UIG5klDjQUnCjbqXsTI264s3RkVxUSH1Eo0awR3MjXcMY/tb2hAlPUtUk98bs2R/JcBtE8s5Ec8RCsw+4A6H6jxLiEzsQxlQHAz2MhS/v0KX/XnCWrAX7m/rgMlq4kwHMMGrgAENcnvOB9FQunZCAZ1bXgK7bxPc4QDI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718302442; c=relaxed/simple; bh=SUqg3Y2+jucLHiR9s5BdxzfEh5ARUVVH65pJoLq+00M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=erwdA0aw6iln18u+Owq73E1A/epxrsIkrsM8IQgbl3LEAGwi6gfAj26sZNU9OtkF243gmlPMiNIXTa+/pmR+OQ9N8ZzJeppAqLhU9uvqXw+0Xq5K3cfZV0NHAbS70dfh7SONqmiE6rWiYJ0aj59C11DltBdzA2gYaVJYhkIZOeg= 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=MxsZxIxm; arc=none smtp.client-ip=170.10.129.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=1718302440; 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=SBn7Y/AGY6HbNkoDSXw9yPDY45ccM5JWbhy8cP5+0Oo=; b=MxsZxIxmLSc/LE0C+/VsaD3m91IYZr/jDlVk5o2IeUDyXpEf6OszU478MvST0aWLNiM1zp 0e6D8UCYyzni+EPlXiHGYe9GFmYw3YqRFUGJoMCcdMpQLi1tD0PYu7NxsWzQCgjUoEvsOL RDAzLVAFL/Ib3LlslEYO3uWyyz0nCUQ= Received: from mx-prod-mc-01.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-379-A0OPjjXJOxu_TJBsGYm5fQ-1; Thu, 13 Jun 2024 14:13:55 -0400 X-MC-Unique: A0OPjjXJOxu_TJBsGYm5fQ-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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4A5601956094; Thu, 13 Jun 2024 18:13:54 +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 2864619560BF; Thu, 13 Jun 2024 18:13:50 +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 5/7] selftests: openvswitch: Support implicit ipv6 arguments. Date: Thu, 13 Jun 2024 14:13:31 -0400 Message-ID: <20240613181333.984810-6-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 The current iteration of IPv6 support requires explicit fields to be set in addition to not properly support the actual IPv6 addresses properly. With this change, make it so that the ipv6() bare option is usable to create wildcarded flows to match broad swaths of ipv6 traffic. Signed-off-by: Aaron Conole --- .../selftests/net/openvswitch/ovs-dpctl.py | 43 ++++++++++++------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/tools/testing/selftests/net/openvswitch/ovs-dpctl.py b/tools/testing/selftests/net/openvswitch/ovs-dpctl.py index 5545e5cab1d6..2577a06c58cf 100644 --- a/tools/testing/selftests/net/openvswitch/ovs-dpctl.py +++ b/tools/testing/selftests/net/openvswitch/ovs-dpctl.py @@ -200,6 +200,19 @@ def convert_ipv4(data): return int(ipaddress.IPv4Address(ip)), int(ipaddress.IPv4Address(mask)) +def convert_ipv6(data): + ip, _, mask = data.partition('/') + + if not ip: + ip = mask = 0 + elif not mask: + mask = 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff' + elif mask.isdigit(): + mask = ipaddress.IPv6Network("::/" + mask).hostmask + + return ipaddress.IPv6Address(ip).packed, ipaddress.IPv6Address(mask).packed + + def convert_int(size): def convert_int_sized(data): value, _, mask = data.partition('/') @@ -937,21 +950,21 @@ class ovskey(nla): "src", "src", lambda x: str(ipaddress.IPv6Address(x)), - lambda x: int.from_bytes(x, "big"), - lambda x: ipaddress.IPv6Address(x), + lambda x: ipaddress.IPv6Address(x).packed if x else 0, + convert_ipv6, ), ( "dst", "dst", lambda x: str(ipaddress.IPv6Address(x)), - lambda x: int.from_bytes(x, "big"), - lambda x: ipaddress.IPv6Address(x), + lambda x: ipaddress.IPv6Address(x).packed if x else 0, + convert_ipv6, ), - ("label", "label", "%d", int), - ("proto", "proto", "%d", int), - ("tclass", "tclass", "%d", int), - ("hlimit", "hlimit", "%d", int), - ("frag", "frag", "%d", int), + ("label", "label", "%d", lambda x: int(x) if x else 0), + ("proto", "proto", "%d", lambda x: int(x) if x else 0), + ("tclass", "tclass", "%d", lambda x: int(x) if x else 0), + ("hlimit", "hlimit", "%d", lambda x: int(x) if x else 0), + ("frag", "frag", "%d", lambda x: int(x) if x else 0), ) def __init__( @@ -1148,8 +1161,8 @@ class ovskey(nla): ( "target", "target", - lambda x: str(ipaddress.IPv6Address(x)), - lambda x: int.from_bytes(x, "big"), + lambda x: ipaddress.IPv6Address(x).packed, + convert_ipv6, ), ("sll", "sll", macstr, lambda x: int.from_bytes(x, "big")), ("tll", "tll", macstr, lambda x: int.from_bytes(x, "big")), @@ -1233,14 +1246,14 @@ class ovskey(nla): ( "src", "src", - lambda x: str(ipaddress.IPv6Address(x)), - lambda x: int.from_bytes(x, "big", convertmac), + lambda x: ipaddress.IPv6Address(x).packed, + convert_ipv6, ), ( "dst", "dst", - lambda x: str(ipaddress.IPv6Address(x)), - lambda x: int.from_bytes(x, "big"), + lambda x: ipaddress.IPv6Address(x).packed, + convert_ipv6, ), ("tp_src", "tp_src", "%d", int), ("tp_dst", "tp_dst", "%d", int), -- 2.45.1