From patchwork Wed May 31 17:27:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 127806 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 150C942BF6; Wed, 31 May 2023 19:28:02 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BD34D40A89; Wed, 31 May 2023 19:28:01 +0200 (CEST) Received: from mail-oa1-f43.google.com (mail-oa1-f43.google.com [209.85.160.43]) by mails.dpdk.org (Postfix) with ESMTP id 7F1F040A82 for ; Wed, 31 May 2023 19:28:00 +0200 (CEST) Received: by mail-oa1-f43.google.com with SMTP id 586e51a60fabf-19f6f8c840bso2271253fac.3 for ; Wed, 31 May 2023 10:28:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20221208.gappssmtp.com; s=20221208; t=1685554079; x=1688146079; 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=4/D9WgEG9I9PlNDjnMhJCzbKLC/RXkT1XfnaIrkGuao=; b=ljHoLkAKohTtsv7RazSgjM+JJePtF3XehnVFBymW5VFuSUeUjP2DsykDs67IAmEwlC Mtr/XnlO37HbXiSQEZ93mf5D0nMMtka45DY5/gN+czdAfFKK6j6/byziCV49e9UazQFW rOg7ZbqwuPyHtKUdpz/oIIX15oImN356Gl0YmZdAsFnjdTawumHU/ZqBNFs7tUlJl6tJ NmpvjkhY1W+IzKIPwqkFqigHJ9Uz64OroAhzYDsAVw3nbANeB0Ef5ZtGYspzUMt0JtWK RwxNF4JlEbYuiCNXsM6XdsBGCOcAzAjTO9ULMjsjQbOS5iOP/YNsIWG4WidqJVEjNU01 6bNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685554079; x=1688146079; 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=4/D9WgEG9I9PlNDjnMhJCzbKLC/RXkT1XfnaIrkGuao=; b=gaGxTlb6rU70ARKW7kNjyCn9dJzKzP5IuqxXDVUENU9AGrqIkeOZu5l4yNhJ+MXFqA VegfjLoZeFYVgkO81GmZdFPPQ0F5K4r9W88uetkfo9mG5af0A5y5/k6Yf3HsjSlTFxeR pOGdC/hdnIsnYfO+c9gfFRzs9cfycUl6vMfqdQR2Fpop8wmsD3UU/swhdQ7VeeY5uprb /77NXipmwOq25kmeraegwQrjbCbS7g+kFO6WLPfSWryleRlN5QLA5rW828ctepYMEM1x UG/rTVa61OQFD6AM+GpcfLi5CZZPx5nQtxf85k5HqMmoS24FY9+lNejMyZ+A3M4jommB aBew== X-Gm-Message-State: AC+VfDxDurATsQpQUVCdcdhvmi1zVVPyvZBAKopne4bCyw4cbS1P84lf bPQle5f5t4yaHXkciTZpc0We1O+jRHARJQhts8OEAA== X-Google-Smtp-Source: ACHHUZ48Kr+Yb8l4eqI7gw8sCOl25ZKIs4cuyTinhYZkHbFZ7dq2d/fXnjAlMF9EfUd8g/g5/Jq0Nw== X-Received: by 2002:a05:6870:b145:b0:187:e563:77b9 with SMTP id a5-20020a056870b14500b00187e56377b9mr4821016oal.45.1685554079422; Wed, 31 May 2023 10:27:59 -0700 (PDT) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id x64-20020a636343000000b00530914c3bc1sm1571408pgb.21.2023.05.31.10.27.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 May 2023 10:27:58 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Jerin Jacob , Kiran Kumar K , Nithin Dabilpuram Subject: [PATCH v2] graph: fix pcapng file support Date: Wed, 31 May 2023 10:27:53 -0700 Message-Id: <20230531172753.65074-1-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230530190834.142932-1-stephen@networkplumber.org> References: <20230530190834.142932-1-stephen@networkplumber.org> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The interface to rte_pcapng changed in last release so that the interfaces used need to be added to the pcapng file via the API. If this step is missing the pcapng file will not be valid and can't be read by wireshark etc. Fixes: d1da6d0d04c7 ("pcapng: require per-interface information") Signed-off-by: Stephen Hemminger Acked-by: Amit Prakash Shukla --- lib/graph/graph_pcap.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/lib/graph/graph_pcap.c b/lib/graph/graph_pcap.c index 6c433300290b..db722c375fa7 100644 --- a/lib/graph/graph_pcap.c +++ b/lib/graph/graph_pcap.c @@ -7,6 +7,7 @@ #include #include +#include #include #include @@ -80,7 +81,8 @@ graph_pcap_default_path_get(char **dir_path) int graph_pcap_file_open(const char *filename) { - int fd; + int fd, ret; + uint16_t portid; char file_name[RTE_GRAPH_PCAP_FILE_SZ]; char *pcap_dir; @@ -110,12 +112,29 @@ graph_pcap_file_open(const char *filename) NULL); if (pcapng_fd == NULL) { graph_err("Graph rte_pcapng_fdopen failed."); - close(fd); - return -1; + goto error; + } + + /* Add the configured interfaces as possible capture ports */ + RTE_ETH_FOREACH_DEV(portid) { + ret = rte_pcapng_add_interface(pcapng_fd, portid, + NULL, NULL, NULL); + if (ret < 0) { + graph_err("Graph rte_pcapng_add_interface port %u failed: %d", + portid, ret); + goto error; + } } done: return 0; +error: + if (pcapng_fd != NULL) { + rte_pcapng_close(pcapng_fd); + pcapng_fd = NULL; + } + close(fd); + return -1; } int