From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4FC33A0093; Mon, 7 Mar 2022 19:33:25 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E274840688; Mon, 7 Mar 2022 19:33:24 +0100 (CET) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mails.dpdk.org (Postfix) with ESMTP id 539C04014E for ; Mon, 7 Mar 2022 19:33:22 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1646678002; x=1678214002; h=message-id:date:to:references:from:subject:in-reply-to: content-transfer-encoding:mime-version; bh=E+TmU7BExoThQ5enxkm8M/Dg7hrdPSBModgQcr8HIvU=; b=hMe+dYt/QKMfcxMzT0XDq37XlHS0qyG/wE7kBuhRwrK2Pq7EnCfeZ/qW GuUlPmQdLj1bXk958mKVpeG+GEcqKpA/drKmQ/jEXjf1mnalLyoJW/sB8 TTEvCBZqL6wwtuIekbD+ingc8xrTqaCkE/tywCltGko02NkfHgpxsLLvU 9r8RchbmDFCK+uVEmpCmGPN9c6PD6oed857cQOGtikQS8NTWLDl0fua4t o0bFRHAatI3oscetoWe2jkz5ki1ZxouFiP0aOTLCtqL7jQzocSvTHxjx+ gokzj6N25O5lsm/NAUX/q59UsE4Kb67ifYfjZ+ROKf/2OGY6CYF2cw4UK Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10279"; a="252042519" X-IronPort-AV: E=Sophos;i="5.90,162,1643702400"; d="scan'208";a="252042519" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Mar 2022 10:33:21 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,162,1643702400"; d="scan'208";a="631939492" Received: from fmsmsx605.amr.corp.intel.com ([10.18.126.85]) by FMSMGA003.fm.intel.com with ESMTP; 07 Mar 2022 10:33:20 -0800 Received: from fmsmsx607.amr.corp.intel.com (10.18.126.87) by fmsmsx605.amr.corp.intel.com (10.18.126.85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Mon, 7 Mar 2022 10:33:20 -0800 Received: from fmsmsx607.amr.corp.intel.com (10.18.126.87) by fmsmsx607.amr.corp.intel.com (10.18.126.87) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Mon, 7 Mar 2022 10:33:20 -0800 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx607.amr.corp.intel.com (10.18.126.87) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21 via Frontend Transport; Mon, 7 Mar 2022 10:33:20 -0800 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (104.47.58.173) by edgegateway.intel.com (192.55.55.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.21; Mon, 7 Mar 2022 10:33:19 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hMMjf0Jbpd6tXuFy6zKgOvob5KnqBgeK8WUD8a6o5pfiyanOPMC9i8Yp5/Sqv2amJgs+ooSg6nwhxjTYe/NzTe8wcPavpX/c0aYs2vvssWBGlt2Vt7td1aqGp0gPDrtv+9pe5FHg29FXEs3OJgrv5R8ncJdeBv0+s0ADB97s47tcjLdzNFLfNbNlN7jfu2CkZUNSweRgKgWD+ijsyTmqVgW38+zAS1GYMdcAKvYgQww7lOUl5LRvVDkBX4Ur8M+gWeQAlfjaz/V/1u+C0lHVRthxZuivcKcF8iLyzZLzlS++aATDla2vQ/X+j5FM93mZZ3aUMj6l/5s8SEZ7g904gw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Md9ePztNWb/LiCEDuybzn8b0riCayal7wfmNpC8Pj2U=; b=jbcGYxZndhxUTXgYI2bCMsVZvpIkACTTKc326enmOpxNpd6+yJ1JfN6CF65Ke9Rb6EYKOvOyBgQvWVackk124z2PmL/GsTwZGgaekYkhY/vSdNUiHN7zcd1l3y4yeL9ueX7vrKo3XJlycm3tJGs//3dCm2ZgDtZC2Hnxk/WovEuu10xwzXNIm1Km5x+TV5RMwWOUBz9iMAxf9hbjDIaBSfSiIEuTsUUR5UJ8jUdHMMOn2rcgH4dFBB7c1YZvCbyIzPQX2iZde4Cno6CYSWzKLSEv8MSrpawFkHVHcSMqY4+umIWCI6jZjHw4jG93+RXrJKp9C4wpbIX2y4MVyv33Kg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from PH0PR11MB5000.namprd11.prod.outlook.com (2603:10b6:510:41::19) by SA2PR11MB5147.namprd11.prod.outlook.com (2603:10b6:806:118::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.15; Mon, 7 Mar 2022 18:33:18 +0000 Received: from PH0PR11MB5000.namprd11.prod.outlook.com ([fe80::bd21:6fbe:8308:2ecf]) by PH0PR11MB5000.namprd11.prod.outlook.com ([fe80::bd21:6fbe:8308:2ecf%7]) with mapi id 15.20.5038.027; Mon, 7 Mar 2022 18:33:17 +0000 Message-ID: <4766cb32-da32-1af3-a0a0-3a9c1efc310d@intel.com> Date: Mon, 7 Mar 2022 18:33:12 +0000 Content-Language: en-US To: Tianli Lai , References: <20220307203012.33691-1-laitianli@tom.com> From: Ferruh Yigit Subject: Re: [PATCH 1/2] net/pcap: add snaplen argument X-User: ferruhy In-Reply-To: <20220307203012.33691-1-laitianli@tom.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: DB6P192CA0024.EURP192.PROD.OUTLOOK.COM (2603:10a6:4:b8::34) To PH0PR11MB5000.namprd11.prod.outlook.com (2603:10b6:510:41::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c7c3a439-1f5d-42d1-dd83-08da0068f2d0 X-MS-TrafficTypeDiagnostic: SA2PR11MB5147:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3Zh1kchx3mx46UQl+FmSgxaRMJ/N/XmQQpxHi9x/CVEATZAck/N722ewKLCjSvjCFJWvvab4gz+ZeTxZQV2VyFZuFa7LhY1+5gXoNu6mkyS1wvfcwhFq0S3d6NajKG7x5r+BAnJuB26uu5FaHI7PzF1AWwDHmt5n1wpqSGLdPaBUg9PnGYyg5RuLCjU1IVDYKYlpJPftRYWOO3QNSJUKRVQPi02E8U5agEQwgfW0oHq+ok5LO9E+JppXZNQKU95zS/WVlqTqvPZZW4aylrLNLMTiqsg0q6KwVGyWGXO574n625AN9a7XN1k9W7X3QFvpmr4M3zBeV2mUCzUo2vL6uPeZlJ50HJHc1wjzKj0JhcalWHdEAGhX9RLZtWtCcXGZdoWHoPiHYDUkAQ0jgpRhM6tsEUgz9srshBUkazOmFLhd67U+gcOepaKQxYso0xe9CROXtlssRcLLba3o04fEZc5ZMuaFV1jxmlA+vI16mFIFT4AEhs03eZqgHWMZBG2HDCwpUjJcMn32C09AnExKgmATEKMI0oHQ7QhfXGC9RUhCgSQND0T17JjmwQZxOEEgtoe7jUvHx3mwacuA/sgj+ThlTwrGbTC+ss+LF5tTPLs89uhqbeEk6PDBGVx//PQtb/rKch78nKKMOAWHnLmFzS4UYdi6Ak2QD2svrJYh2pqjuybEXAo2hgPr0paMmGQvaUB4ZjPOJ6mLIWp7LzyUxQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PH0PR11MB5000.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(86362001)(6486002)(6506007)(53546011)(6666004)(508600001)(66556008)(66476007)(66946007)(8676002)(316002)(83380400001)(31696002)(186003)(26005)(6512007)(38100700002)(82960400001)(2616005)(36756003)(2906002)(8936002)(5660300002)(44832011)(31686004)(45980500001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?T3hUVHg1RGcvayswSEFVZW9XYmxJWE1vKy9GRnlFVzlPZUNKUm5FUEFBdEps?= =?utf-8?B?cGRta3c3cG55ZDY1SVZaUVdsRkdKeWx1T2M0WnlSZ3lSWVZHaDVySGxyblhD?= =?utf-8?B?NDdIZXI3VXdWN1pUUjJyNkU2d0ZOQXB3cmJGNmI3NzJnL0pUaUNueFhaaFJ3?= =?utf-8?B?MEV4Y2dTTHF0Uy9jL1dnQnFicmlVbW1qVVhMZ0xtRVNuMVphRGV5MkZhTTQ2?= =?utf-8?B?L2xsRkd0MXFxV3cxMEFQbExVZXFRNm5QQVg5OGV1eUpnR1pHMVZ2MEdjZGQ2?= =?utf-8?B?MFlPOHBwam42TGtpVXg3cWVsYVM1allackRTTW9nN1FBVGFYTmRXcHpmNXdR?= =?utf-8?B?NTQwMG91SWJuV1NvSkI4dytLSjVXeVZuZHBUU1BQNDVHU3hXeHdhWERFSGYw?= =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A=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: c7c3a439-1f5d-42d1-dd83-08da0068f2d0 X-MS-Exchange-CrossTenant-AuthSource: PH0PR11MB5000.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Mar 2022 18:33:17.9219 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Fj5tGH0YezhMv0nePACzSg4tMG66dV2yhRyaOSfnZHGf3fjg7FTHCtlQ/+eCpBInIVhm+V6mC2ERMRX2DpGKnQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR11MB5147 X-OriginatorOrg: intel.com 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 On 3/7/2022 8:30 PM, Tianli Lai wrote: > snaplen argument would set the length of each packet > that will save to pcap file. > Hi Tianli, Overall +1 to add snaplen argument, but please find below comments. Also we are close to finalize the release and this is a new feature, so this can be considered for next release. > Signed-off-by: Tianli Lai > --- > drivers/net/pcap/pcap_ethdev.c | 63 ++++++++++++++++++++++++++-------- please document new devargs in pmd documentation: doc/guides/nics/pcap_ring.rst > 1 file changed, 48 insertions(+), 15 deletions(-) > > diff --git a/drivers/net/pcap/pcap_ethdev.c b/drivers/net/pcap/pcap_ethdev.c > index ec29fd6bc5..8aea6d66ee 100644 > --- a/drivers/net/pcap/pcap_ethdev.c > +++ b/drivers/net/pcap/pcap_ethdev.c > @@ -33,10 +33,12 @@ > #define ETH_PCAP_IFACE_ARG "iface" > #define ETH_PCAP_PHY_MAC_ARG "phy_mac" > #define ETH_PCAP_INFINITE_RX_ARG "infinite_rx" > +#define ETH_PCAP_SNAPLEN_ARG "snaplen" > > #define ETH_PCAP_ARG_MAXLEN 64 > > #define RTE_PMD_PCAP_MAX_QUEUES 16 > +#define RTE_PCAP_MIN_SNAPLEN 64 > > static char errbuf[PCAP_ERRBUF_SIZE]; > static struct timespec start_time; > @@ -99,6 +101,7 @@ struct pmd_process_private { > pcap_t *rx_pcap[RTE_PMD_PCAP_MAX_QUEUES]; > pcap_t *tx_pcap[RTE_PMD_PCAP_MAX_QUEUES]; > pcap_dumper_t *tx_dumper[RTE_PMD_PCAP_MAX_QUEUES]; > + int snaplen; 'struct pmd_internals' is better place than 'struct pmd_process_private'. 'struct pmd_process_private' is for the values that can differ for primary and secondary processes, 'snaplen' does not. > }; > > struct pmd_devargs { > @@ -110,6 +113,7 @@ struct pmd_devargs { > const char *type; > } queue[RTE_PMD_PCAP_MAX_QUEUES]; > int phy_mac; > + int snaplen; > }; > > struct pmd_devargs_all { > @@ -132,6 +136,7 @@ static const char *valid_arguments[] = { > ETH_PCAP_IFACE_ARG, > ETH_PCAP_PHY_MAC_ARG, > ETH_PCAP_INFINITE_RX_ARG, > + ETH_PCAP_SNAPLEN_ARG, > NULL > }; > > @@ -404,6 +409,12 @@ eth_pcap_tx_dumper(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) > calculate_timestamp(&header.ts); > header.len = len; > header.caplen = caplen; > + if (pp->snaplen >= RTE_PCAP_MIN_SNAPLEN) { why not make 'snaplen' always a valid value, so it saves some checks here This can be done by 'snaplen' default value is 'RTE_ETH_PCAP_SNAPSHOT_LEN' and it can be overwritten with *valid* user input, so the variable can be used here directly. > + if ((typeof(pp->snaplen))header.caplen > pp->snaplen) { > + header.caplen = pp->snaplen; Why not do the check before above 'header.caplen = caplen;' line, so won't need to set here again. > + caplen = pp->snaplen; > + } > + } > /* rte_pktmbuf_read() returns a pointer to the data directly > * in the mbuf (when the mbuf is contiguous) or, otherwise, > * a pointer to temp_data after copying into it. > @@ -512,8 +523,11 @@ eth_pcap_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) > * pcap_open_live wrapper function > */ > static inline int > -open_iface_live(const char *iface, pcap_t **pcap) { > - *pcap = pcap_open_live(iface, RTE_ETH_PCAP_SNAPLEN, > +open_iface_live(const char *iface, pcap_t **pcap, int snaplen) { > + int caplen = RTE_ETH_PCAP_SNAPLEN; > + if (snaplen >= RTE_PCAP_MIN_SNAPLEN) As said above these checks can be eliminated by making 'snaplen' always a valid value at this stage. > + caplen = snaplen; > + *pcap = pcap_open_live(iface, caplen, > RTE_ETH_PCAP_PROMISC, RTE_ETH_PCAP_TIMEOUT, errbuf); > > if (*pcap == NULL) { > @@ -525,9 +539,9 @@ open_iface_live(const char *iface, pcap_t **pcap) { > } > > static int > -open_single_iface(const char *iface, pcap_t **pcap) > +open_single_iface(const char *iface, pcap_t **pcap, int snaplen) > { > - if (open_iface_live(iface, pcap) < 0) { > + if (open_iface_live(iface, pcap, snaplen) < 0) { > PMD_LOG(ERR, "Couldn't open interface %s", iface); > return -1; > } > @@ -536,17 +550,19 @@ open_single_iface(const char *iface, pcap_t **pcap) > } > > static int > -open_single_tx_pcap(const char *pcap_filename, pcap_dumper_t **dumper) > +open_single_tx_pcap(const char *pcap_filename, pcap_dumper_t **dumper, int snaplen) > { > pcap_t *tx_pcap; > - > + int caplen = RTE_ETH_PCAP_SNAPSHOT_LEN; > + if (snaplen >= RTE_PCAP_MIN_SNAPLEN) > + caplen = snaplen; ditto > /* > * We need to create a dummy empty pcap_t to use it > * with pcap_dump_open(). We create big enough an Ethernet > * pcap holder. > */ > tx_pcap = pcap_open_dead_with_tstamp_precision(DLT_EN10MB, > - RTE_ETH_PCAP_SNAPSHOT_LEN, PCAP_TSTAMP_PRECISION_NANO); > + caplen, PCAP_TSTAMP_PRECISION_NANO); > if (tx_pcap == NULL) { > PMD_LOG(ERR, "Couldn't create dead pcap"); > return -1; > @@ -612,7 +628,7 @@ eth_dev_start(struct rte_eth_dev *dev) > > if (!pp->tx_pcap[0] && > strcmp(tx->type, ETH_PCAP_IFACE_ARG) == 0) { > - if (open_single_iface(tx->name, &pp->tx_pcap[0]) < 0) > + if (open_single_iface(tx->name, &pp->tx_pcap[0], pp->snaplen) < 0) > return -1; > pp->rx_pcap[0] = pp->tx_pcap[0]; > } > @@ -627,11 +643,11 @@ eth_dev_start(struct rte_eth_dev *dev) > if (!pp->tx_dumper[i] && > strcmp(tx->type, ETH_PCAP_TX_PCAP_ARG) == 0) { > if (open_single_tx_pcap(tx->name, > - &pp->tx_dumper[i]) < 0) > + &pp->tx_dumper[i], pp->snaplen) < 0) > return -1; > } else if (!pp->tx_pcap[i] && > strcmp(tx->type, ETH_PCAP_TX_IFACE_ARG) == 0) { > - if (open_single_iface(tx->name, &pp->tx_pcap[i]) < 0) > + if (open_single_iface(tx->name, &pp->tx_pcap[i], pp->snaplen) < 0) > return -1; > } > } > @@ -647,7 +663,7 @@ eth_dev_start(struct rte_eth_dev *dev) > if (open_single_rx_pcap(rx->name, &pp->rx_pcap[i]) < 0) > return -1; > } else if (strcmp(rx->type, ETH_PCAP_RX_IFACE_ARG) == 0) { > - if (open_single_iface(rx->name, &pp->rx_pcap[i]) < 0) > + if (open_single_iface(rx->name, &pp->rx_pcap[i], pp->snaplen) < 0) > return -1; > } > } > @@ -1055,7 +1071,7 @@ open_tx_pcap(const char *key, const char *value, void *extra_args) > struct pmd_devargs *dumpers = extra_args; > pcap_dumper_t *dumper; > > - if (open_single_tx_pcap(pcap_filename, &dumper) < 0) > + if (open_single_tx_pcap(pcap_filename, &dumper, dumpers->snaplen) < 0) > return -1; > > if (add_queue(dumpers, pcap_filename, key, NULL, dumper) < 0) { > @@ -1066,6 +1082,16 @@ open_tx_pcap(const char *key, const char *value, void *extra_args) > return 0; > } > > +static int > +parse_uint_value(const char *key, const char *value, void *extra_args) > +{ > + (void)key; please use '__rte_unused' keyword, instead of assigning to (void) > + char *end; > + int *val = extra_args;> + *val = strtoul(value, &end, 10); > + return 0; > +} > + > /* > * Opens an interface for reading and writing > */ > @@ -1076,7 +1102,7 @@ open_rx_tx_iface(const char *key, const char *value, void *extra_args) > struct pmd_devargs *tx = extra_args; > pcap_t *pcap = NULL; > > - if (open_single_iface(iface, &pcap) < 0) > + if (open_single_iface(iface, &pcap, tx->snaplen) < 0) > return -1; > > tx->queue[0].pcap = pcap; > @@ -1108,7 +1134,7 @@ open_iface(const char *key, const char *value, void *extra_args) > struct pmd_devargs *pmd = extra_args; > pcap_t *pcap = NULL; > > - if (open_single_iface(iface, &pcap) < 0) > + if (open_single_iface(iface, &pcap, pmd->snaplen) < 0) When this function (open_iface) is called by 'open_rx_iface', 'pmd' will be rx_queues ('pcaps'), and I guess 'pmd->snaplen' will be 0 in that case, won't this cause a problem? > return -1; > if (add_queue(pmd, iface, key, pcap, NULL) < 0) { > pcap_close(pcap); > @@ -1403,6 +1429,7 @@ pmd_pcap_probe(struct rte_vdev_device *dev) > struct rte_eth_dev *eth_dev = NULL; > struct pmd_internals *internal; > int ret = 0; > + int snaplen = 0; Why not use 'dumpers.snaplen' directly, instead of having a temporary variable? > > struct pmd_devargs_all devargs_all = { > .single_iface = 0, > @@ -1444,6 +1471,12 @@ pmd_pcap_probe(struct rte_vdev_device *dev) > return -1; > } > > + if (rte_kvargs_count(kvlist, ETH_PCAP_SNAPLEN_ARG) == 1) { > + ret = rte_kvargs_process(kvlist, ETH_PCAP_SNAPLEN_ARG, > + &parse_uint_value, &snaplen) should handle 'ret < 0' case. Also input value needs to be verified here, before accepted, I guess it should be RTE_PCAP_MIN_SNAPLEN <= snaplen <= RTE_ETH_PCAP_SNAPLEN > + dumpers.snaplen = snaplen; > + } > + > /* > * If iface argument is passed we open the NICs and use them for > * reading / writing > @@ -1593,7 +1626,7 @@ pmd_pcap_probe(struct rte_vdev_device *dev) > pp->tx_dumper[i] = dumpers.queue[i].dumper; > pp->tx_pcap[i] = dumpers.queue[i].pcap; > } > - > + pp->snaplen = snaplen; > eth_dev->process_private = pp; > eth_dev->rx_pkt_burst = eth_pcap_rx; > if (devargs_all.is_tx_pcap)