From nobody Mon Dec 15 01:55:17 2025 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1675224975; cv=none; d=zohomail.com; s=zohoarc; b=bZHQICgjUfGapF6MeaiatyY/hOAmktuhw/7af2M6JuGIRryTWXIuZKrpWm0DVigqyS/llHFW+FR/MT2z5U9DUhusgdBl1PBW3ScKHBHWBQS2Lw0cYF0CrZPXr9ODBvp5WSRdv0fyfJW18tMq/A+LWSHTYiQ+wmqVJFPwhWhi0uE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675224975; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject; bh=/nys2t0G7RD2ftML3eD4g9pOiP5E57MBuxl39+WQCyc=; b=LfizNUSkH7yYlB5Una1pRwj2zWUui+nTGSrUOu3aosUnRl7Mzn5NpSBL5BE57mR0cn1IY9drbF6SFvbxAnT4vQ3dH4XseH407ISnHsvMkzIiplwpWFgd5b/C4KiiIPA57ykbYBUTOybLnfxkxHKecc4vqEpO4UvBGxUuMTHh2bQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1675224975762164.52175552357141; Tue, 31 Jan 2023 20:16:15 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pN4VV-00012g-Iu; Tue, 31 Jan 2023 23:14:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pN4VU-00010c-17 for qemu-devel@nongnu.org; Tue, 31 Jan 2023 23:14:00 -0500 Received: from mail-pj1-x1036.google.com ([2607:f8b0:4864:20::1036]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pN4VR-00017g-QS for qemu-devel@nongnu.org; Tue, 31 Jan 2023 23:13:59 -0500 Received: by mail-pj1-x1036.google.com with SMTP id e8-20020a17090a9a8800b0022c387f0f93so792921pjp.3 for ; Tue, 31 Jan 2023 20:13:57 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id q8-20020a17090a7a8800b0022c01052e92sm231350pjf.56.2023.01.31.20.13.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 20:13:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/nys2t0G7RD2ftML3eD4g9pOiP5E57MBuxl39+WQCyc=; b=ZDiQxp1A73d1JQt56rgoxIetxgUKVaLJSc6gFq3rinXHHEXn5UJNutMV78PWKQMcnn gjXYR1BACyBSlTLqGVhiqTU4DYPFVLZClNbZBqAuTxxjDP7GhrvgTE1ODQlw+YzuOX8q DL4QdWvRtp8828LeGd/FPn4+rUZYdEj44KdTnSvZ97tPYlg9RK4mg8jOVgj5F4zQ+LZK xD6BF/tNMqllmcxq1tkQIP1/fdN3vHDC+ih0F6iri09LwTm3vskPXwsARQ4ObfRk06Ah yIfGEtE5sXXfkGT9nRcGa8U6l91NyI2/6yD8XWDkagJwQ1V6R2Sn0stpo3VU8i/qVVNM UHsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/nys2t0G7RD2ftML3eD4g9pOiP5E57MBuxl39+WQCyc=; b=5s3Hli7UmJ/DsHTWCiJYlOyIpCJCFXBedJwtJfkdk4sueA12MLU/R8xIRr+q4cTkjt 70y/GQVzsxNtWO05aG6ib0/ZRm9IgvxQQy+PRiWiiy+pBDihYni3PPBBl1JIhwXfUq+n O+CPskOWe3gRqMnKcvFKPmNSPgBrwn699FrlLxbYsmfR9fz0svM47oNOBPTCjmAcHgBq zZoMgV8sPfctc7BUfggkPhb6zxIMtDRRAl/FTLV6UVSKc/LbdGCd3+49lyHcvW2QGW/M ilOhoGQlAEXAE3COnxap0BfjiGPjBoUT1XxKivYdnZaJK10Jd+aRKC6eP5dadURg1GgC PxUw== X-Gm-Message-State: AO0yUKV1lNVlcVugPWBRquuZ3nh+hcQ9us2mMorPwvMaZMAkGdgOkWMM AmXpKQhzSl4lX5gK9SVxwBMEHQ== X-Google-Smtp-Source: AK7set+JAxQVVY/q+52DazQOG99hN8EtOPG3n69xhr3Efy6jONr1lixbMTPtKpPYP28PongWRE0xhA== X-Received: by 2002:a05:6a20:9591:b0:b9:7a34:a78d with SMTP id iu17-20020a056a20959100b000b97a34a78dmr939957pzb.9.1675224837164; Tue, 31 Jan 2023 20:13:57 -0800 (PST) From: Akihiko Odaki To: Cc: Jason Wang , Dmitry Fleytman , "Michael S . Tsirkin" , Marcel Apfelbaum , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Thomas Huth , Wainer dos Santos Moschetta , Beraldo Leal , Cleber Rosa , Laurent Vivier , Paolo Bonzini , Alexander Bulekov , Bandan Das , Stefan Hajnoczi , Darren Kenny , Qiuhao Li , qemu-devel@nongnu.org, qemu-ppc@nongnu.org, devel@daynix.com, Yan Vugenfirer , Yuri Benditovich , Sriram Yagnaraman , Gal Hammer , Akihiko Odaki Subject: [PATCH v6 5/9] tests/qtest/e1000e-test: Fabricate ethernet header Date: Wed, 1 Feb 2023 13:13:16 +0900 Message-Id: <20230201041320.32096-6-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230201041320.32096-1-akihiko.odaki@daynix.com> References: <20230201041320.32096-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::1036; envelope-from=akihiko.odaki@daynix.com; helo=mail-pj1-x1036.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1675224976416100001 Content-Type: text/plain; charset="utf-8" e1000e understands ethernet header so fabricate something convincing. Signed-off-by: Akihiko Odaki Reviewed-by: Thomas Huth --- tests/qtest/e1000e-test.c | 25 +++++++++++++++---------- tests/qtest/libqos/e1000e.h | 2 ++ 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/tests/qtest/e1000e-test.c b/tests/qtest/e1000e-test.c index b63a4d3c91..de9738fdb7 100644 --- a/tests/qtest/e1000e-test.c +++ b/tests/qtest/e1000e-test.c @@ -27,6 +27,7 @@ #include "qemu/osdep.h" #include "libqtest-single.h" #include "libqos/pci-pc.h" +#include "net/eth.h" #include "qemu/sockets.h" #include "qemu/iov.h" #include "qemu/module.h" @@ -35,9 +36,13 @@ #include "libqos/e1000e.h" #include "hw/net/e1000_regs.h" =20 +static const struct eth_header packet =3D { + .h_dest =3D E1000E_ADDRESS, + .h_source =3D E1000E_ADDRESS, +}; + static void e1000e_send_verify(QE1000E *d, int *test_sockets, QGuestAlloca= tor *alloc) { - static const char test[] =3D "TEST"; struct e1000_tx_desc descr; char buffer[64]; int ret; @@ -45,7 +50,7 @@ static void e1000e_send_verify(QE1000E *d, int *test_sock= ets, QGuestAllocator *a =20 /* Prepare test data buffer */ uint64_t data =3D guest_alloc(alloc, sizeof(buffer)); - memwrite(data, test, sizeof(test)); + memwrite(data, &packet, sizeof(packet)); =20 /* Prepare TX descriptor */ memset(&descr, 0, sizeof(descr)); @@ -71,7 +76,7 @@ static void e1000e_send_verify(QE1000E *d, int *test_sock= ets, QGuestAllocator *a g_assert_cmpint(ret, =3D=3D , sizeof(recv_len)); ret =3D recv(test_sockets[0], buffer, sizeof(buffer), 0); g_assert_cmpint(ret, =3D=3D, sizeof(buffer)); - g_assert_cmpstr(buffer, =3D=3D , test); + g_assert_false(memcmp(buffer, &packet, sizeof(packet))); =20 /* Free test data buffer */ guest_free(alloc, data); @@ -81,15 +86,15 @@ static void e1000e_receive_verify(QE1000E *d, int *test= _sockets, QGuestAllocator { union e1000_rx_desc_extended descr; =20 - char test[] =3D "TEST"; - int len =3D htonl(sizeof(test)); + struct eth_header test_iov =3D packet; + int len =3D htonl(sizeof(packet)); struct iovec iov[] =3D { { .iov_base =3D &len, .iov_len =3D sizeof(len), },{ - .iov_base =3D test, - .iov_len =3D sizeof(test), + .iov_base =3D &test_iov, + .iov_len =3D sizeof(packet), }, }; =20 @@ -97,8 +102,8 @@ static void e1000e_receive_verify(QE1000E *d, int *test_= sockets, QGuestAllocator int ret; =20 /* Send a dummy packet to device's socket*/ - ret =3D iov_send(test_sockets[0], iov, 2, 0, sizeof(len) + sizeof(test= )); - g_assert_cmpint(ret, =3D=3D , sizeof(test) + sizeof(len)); + ret =3D iov_send(test_sockets[0], iov, 2, 0, sizeof(len) + sizeof(pack= et)); + g_assert_cmpint(ret, =3D=3D , sizeof(packet) + sizeof(len)); =20 /* Prepare test data buffer */ uint64_t data =3D guest_alloc(alloc, sizeof(buffer)); @@ -119,7 +124,7 @@ static void e1000e_receive_verify(QE1000E *d, int *test= _sockets, QGuestAllocator =20 /* Check data sent to the backend */ memread(data, buffer, sizeof(buffer)); - g_assert_cmpstr(buffer, =3D=3D , test); + g_assert_false(memcmp(buffer, &packet, sizeof(packet))); =20 /* Free test data buffer */ guest_free(alloc, data); diff --git a/tests/qtest/libqos/e1000e.h b/tests/qtest/libqos/e1000e.h index 091ce139da..5e2b201aa7 100644 --- a/tests/qtest/libqos/e1000e.h +++ b/tests/qtest/libqos/e1000e.h @@ -25,6 +25,8 @@ #define E1000E_RX0_MSG_ID (0) #define E1000E_TX0_MSG_ID (1) =20 +#define E1000E_ADDRESS { 0x52, 0x54, 0x00, 0x12, 0x34, 0x56 } + typedef struct QE1000E QE1000E; typedef struct QE1000E_PCI QE1000E_PCI; =20 --=20 2.39.1