From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id E316FA3160 for ; Wed, 9 Oct 2019 17:14:46 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B63951E8B3; Wed, 9 Oct 2019 17:14:46 +0200 (CEST) Received: from mail-pg1-f194.google.com (mail-pg1-f194.google.com [209.85.215.194]) by dpdk.org (Postfix) with ESMTP id 0D2EE1B994 for ; Wed, 9 Oct 2019 17:14:45 +0200 (CEST) Received: by mail-pg1-f194.google.com with SMTP id p1so1612433pgi.4 for ; Wed, 09 Oct 2019 08:14:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HvMfTj3/yFjka0amZZSlCL4ZaUcN1I9wBfuGa4Dcf0w=; b=u1017cFLR/BR+nVoFEF2cekLuB6E3OFzqXwE22CZ0CL6R1ckBFVuzwApqKBM4VBfwR DJLp+eIjJNEl1EJmVSNwhcdhfhoKDzLXaf3Kt6OYA4PuIZcHFdBHC7CD4qlBGlNgwLuh pBxBT/9RECZA7X9Fc+LJanPhRZGflfGlCkfku/zoHPFKHDo1b1gkbwqq0WthfMg6lWRi ROIhtQCAI8E8AlrAQRulrRrfjJtVu0Jd55m795zlcmqPE1gHHOu0VhLlmcyb9VnnGIPT 9GfcGGwjqrYtoK7yMz5xqlYSmhP8FvSln/NdxKprQtA6GOsWb1Eqv2nmq/Qw6kieyhQ5 GcEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HvMfTj3/yFjka0amZZSlCL4ZaUcN1I9wBfuGa4Dcf0w=; b=H3fHdpC1u3nTLm72+8xBKlKG4XAVtutqllSPGQpeIAmnMim5yYb4jnJnrzp5oW8sgo TlHcATeSI1eYIw/qLf68cVkzgIrNR1GH8GMJ/IKdujgtoJQQ1bwTmmI4vGEnEYZ2N774 edWP2bd2+HD8zlvA105bHzSEOkq40LJW2HzDpsYvlvIA1xzk9AO3F0tNBe37WTZuWFy/ J8qK+mzn+hQ3X+MOr/3FCDvl+gdSrSPch/ncC5AKAjkW6TeWpWL4ZlArLifDviWilbWG /qq5AL0ah3UxAg0gbib4Own0XPks+mBnEH8j5qxv6dU73oj1rs0jUKIstiM6dOO941Vp Ryww== X-Gm-Message-State: APjAAAV4DOeW2gPHcU4a//0br/WJM86wJk6x1X5IJ3T1c1FWLDj3wp8b YeqUpOGoazmK0kp0HFIdidgXQA== X-Google-Smtp-Source: APXvYqw2UCA1F/MApjFyzI/o4fOS8zgY3dc0rlp+BpfgL4qrp9YO2GzMdBkz/Ul8dwgUEuIp6/MrXg== X-Received: by 2002:a62:3441:: with SMTP id b62mr4196717pfa.12.1570634084240; Wed, 09 Oct 2019 08:14:44 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id x10sm4655730pfr.44.2019.10.09.08.14.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Oct 2019 08:14:44 -0700 (PDT) Date: Wed, 9 Oct 2019 08:14:42 -0700 From: Stephen Hemminger To: Morten =?UTF-8?B?QnLDuHJ1cA==?= Cc: "Ananyev, Konstantin" , "dpdk-dev" , "Jerin Jacob" Message-ID: <20191009081442.3e7f1af4@hermes.lan> In-Reply-To: <98CBD80474FA8B44BF855DF32C47DC35C60B69@smartserver.smartshare.dk> References: <98CBD80474FA8B44BF855DF32C47DC35C60B67@smartserver.smartshare.dk> <2601191342CEEE43887BDE71AB977258019197431F@irsmsx105.ger.corp.intel.com> <20191009080218.3711bef3@hermes.lan> <98CBD80474FA8B44BF855DF32C47DC35C60B69@smartserver.smartshare.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [dpdk-dev] packet data access bug in bpf and pdump libs X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Wed, 9 Oct 2019 17:06:24 +0200 Morten Br=C3=B8rup wrote: > > -----Original Message----- > > From: Stephen Hemminger [mailto:stephen@networkplumber.org] > > Sent: Wednesday, October 9, 2019 5:02 PM > >=20 > > On Wed, 9 Oct 2019 11:11:46 +0000 > > "Ananyev, Konstantin" wrote: > > =20 > > > Hi Morten, > > > =20 > > > > > > > > Hi Konstantin and Stephen, > > > > > > > > I just noticed the same bug in your bpf and pcap libraries: > > > > > > > > You are using rte_pktmbuf_mtod(), but should be using =20 > > rte_pktmbuf_read(). Otherwise you cannot read data across multiple > > segments. =20 > > > > > > In plain data buffer mode expected input for BPF program is start of = =20 > > first segment packet data. =20 > > > Other segments are simply not available to BPF program in that mode. > > > AFAIK, cBPF uses the same model. > > > =20 > > > > > > > > > > > > Med venlig hilsen / kind regards > > > > - Morten Br=C3=B8rup =20 > > > =20 > >=20 > > For packet capture, the BPF program is only allowed to look at first > > segment. > > pktmbuf_read is expensive and can cause a copy. =20 >=20 > It is only expensive if going beyond the first segment: >=20 > static inline const void *rte_pktmbuf_read(const struct rte_mbuf *m, > uint32_t off, uint32_t len, void *buf) > { > if (likely(off + len <=3D rte_pktmbuf_data_len(m))) > return rte_pktmbuf_mtod_offset(m, char *, off); > else > return __rte_pktmbuf_read(m, off, len, buf); > } But it would mean potentially big buffer on the stack (in case)