From patchwork Fri Apr 14 21:12:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ihar Hrachyshka X-Patchwork-Id: 1769182 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::133; helo=smtp2.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=ReL5mpL5; dkim-atps=neutral Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Pyq0z0kCBz1yZr for ; Sat, 15 Apr 2023 07:13:06 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 8A81E42C46; Fri, 14 Apr 2023 21:13:04 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 8A81E42C46 Authentication-Results: smtp2.osuosl.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=ReL5mpL5 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id D-uFg0Vo9nEE; Fri, 14 Apr 2023 21:13:03 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp2.osuosl.org (Postfix) with ESMTPS id B9F2E40481; Fri, 14 Apr 2023 21:13:02 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org B9F2E40481 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 7D215C0037; Fri, 14 Apr 2023 21:13:02 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 41E65C002A for ; Fri, 14 Apr 2023 21:13:01 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 09EA0844A9 for ; Fri, 14 Apr 2023 21:13:01 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 09EA0844A9 Authentication-Results: smtp1.osuosl.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=ReL5mpL5 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Qs5gPlF7sx0F for ; Fri, 14 Apr 2023 21:12:59 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 9937684465 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by smtp1.osuosl.org (Postfix) with ESMTPS id 9937684465 for ; Fri, 14 Apr 2023 21:12:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681506778; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=PMZQLT6twYGutSxoSpJ0W5Vpbg5qJLGGbs7itkvci3k=; b=ReL5mpL5o3jQPVliD0slq0q3EHuds9Wos4LMphK8NipEYX+291QcZ/KKxoCcNU6n+FBVaM Dl6ZK0ZqTicNsNRwL3g9qv1yE7sqJQ3l9u8NvIj6bHoNzxuybYpMqiojEQzYdluVF5D6nt eMAD6lr2jsUAW1fLrF97nnR2YBmTTmk= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-363-V3KW7xetNQqbpI8r43Neqw-1; Fri, 14 Apr 2023 17:12:57 -0400 X-MC-Unique: V3KW7xetNQqbpI8r43Neqw-1 Received: by mail-qt1-f198.google.com with SMTP id bp42-20020a05622a1baa00b003e6748b05edso20524594qtb.2 for ; Fri, 14 Apr 2023 14:12:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681506776; x=1684098776; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=PMZQLT6twYGutSxoSpJ0W5Vpbg5qJLGGbs7itkvci3k=; b=JWDfVKX4puSnQjNO1kA9SOVYzbiUirp57K0Khopzzl+AI0odYg6uCQmHVciCqDLpe6 UlVTdO0nyfs0fhG4y+mabFDoAWfxs+xszq1AFfKlqdATFEQE+V/Vj2PdkcMr0+GFzd2/ HNosKXyfbf4CJHaiJ5k2Wb4ccaw+z0p4QgMxulGQMt4jDGn3qjmrDrX7/p+UBmzLqdZM djAyVDJT9YhgNxW4qL2YhJrRjR+UXC10XgqqTm4a+fGj3PxhF5BNQ62C/OemnLwYsqo/ ijiyOqqq1ELyhkQcuhr/YUot6xhNkVyK4wNp73Hdnrco5waNvDbvq7GQ+lIYvyghKk1F eUTA== X-Gm-Message-State: AAQBX9dD1KUojw12umB/9v0RdtI4qVLlHD+NENbQqegwmZjcPkisfTcm cedCMMRofsKKtR3xA0xrpV3jLYb9YivqwrAShlVsEDAsAwbQDcrQIJ9YtNRjl88Tvx/6Sw+zl1G RAiZ7OdqJrbOLBlyIo6WVGYoJn6xy6sltbp8EXQAOQ0+/szvp07RYDPLNJrhEDfVT76nYhmH/ X-Received: by 2002:ac8:5ad0:0:b0:3e6:9429:1e01 with SMTP id d16-20020ac85ad0000000b003e694291e01mr17779957qtd.11.1681506776590; Fri, 14 Apr 2023 14:12:56 -0700 (PDT) X-Google-Smtp-Source: AKy350asU6fNFRawq7hhO3/lA1S+A8/RRz31H7HcGbbUZeTxBLFrzDA2G93NkhIdESHbz9XrGXIp8g== X-Received: by 2002:ac8:5ad0:0:b0:3e6:9429:1e01 with SMTP id d16-20020ac85ad0000000b003e694291e01mr17779921qtd.11.1681506776262; Fri, 14 Apr 2023 14:12:56 -0700 (PDT) Received: from fedora34.localdomain.com (cpe-172-73-180-250.carolina.res.rr.com. [172.73.180.250]) by smtp.gmail.com with ESMTPSA id bk35-20020a05620a1a2300b007460093cccdsm1496549qkb.25.2023.04.14.14.12.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Apr 2023 14:12:55 -0700 (PDT) From: Ihar Hrachyshka To: dev@openvswitch.org Date: Fri, 14 Apr 2023 21:12:52 +0000 Message-Id: <20230414211253.1992599-1-ihrachys@redhat.com> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Cc: Dumitru Ceara Subject: [ovs-dev] [PATCH ovn v5 1/2] tests: define fmt_pkt function to construct packets with scapy X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" Scapy allows to define packets in descriptive form that is easier to digest and debug. Signed-off-by: Ihar Hrachyshka Acked-by: Ales Musil Acked-by: Dumitru Ceara --- v1: initial version. v2: use .decode() instead of sed to truncate b'...'. v2: remove unnecessary backspaces in example of use. v2: use $PYTHON3. v3: . v4: added missing acks from previous reviews. v5: . --- tests/ovn-macros.at | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/ovn-macros.at b/tests/ovn-macros.at index ee942e8a6..6f2d085ae 100644 --- a/tests/ovn-macros.at +++ b/tests/ovn-macros.at @@ -817,6 +817,29 @@ ovn_trace_client() { ovs-appctl -t $target trace "$@" | tee trace | sed '/^# /d' } +# Receives a string with scapy python code that represents a packet. +# Returns a hex-string that contains bytes that reflect the packet symbolic +# description. +# +# Scapy docs: https://scapy.readthedocs.io/en/latest/usage.html +# +# Example of usage: +# +# packet=$(fmt_pkt " +# Ether(dst='ff:ff:ff:ff:ff:ff', src='50:64:00:00:00:01') / +# IPv6(src='abed::1', dst='ff02::1:ff00:2') / +# ICMPv6ND_NS(tgt='abed::2') +# ") +# +# ovs-appctl netdev-dummy/receive $vif $packet +# +fmt_pkt() { + echo "from scapy.all import *; \ + import binascii; \ + out = binascii.hexlify(raw($1)); \ + print(out.decode())" | $PYTHON3 +} + OVS_END_SHELL_HELPERS m4_define([OVN_POPULATE_ARP], [AT_CHECK(ovn_populate_arp__, [0], [ignore])])