From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wg0-f46.google.com (mail-wg0-f46.google.com [74.125.82.46]) by dpdk.org (Postfix) with ESMTP id 732145A56 for ; Wed, 3 Jun 2015 10:28:02 +0200 (CEST) Received: by wgez8 with SMTP id z8so2673046wge.0 for ; Wed, 03 Jun 2015 01:28:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:organization :user-agent:in-reply-to:references:mime-version :content-transfer-encoding:content-type; bh=yONKaOwxWLEMblJmmjX3qbpFDohpzz9KVcZQi3KB1es=; b=HqXLAbM9EM3AyuhxkusJFbBKn/X27iQl4aI7eyYaq7kaJdlen7G4SekHmczRmHoMee LXlbD4WxZythlrG6uluo+VoaZq2gtqpTObHQ5jydNCGaCIEULsN3aJW1TUl/ka7cS2Ck c5NMD8IAz2Q9vBOLsrnWHq1ybIuPGgWHQSsP+7DVJ620Vs7JYk3uiu+iwvEWNNh8DGPa Ryxynl1AfmgnQK+kif2utt6oSFFT4oCBXjHzJ92rV7QkEeqxfXWlNhyZ19rICG+gLuer MfiYp2mKFwPUpgcRFAij0OySHGiKmT4aJlnCeAa29Jw5Oq0f9nOkEz8xpNzdqTyvdoq+ HFIQ== X-Gm-Message-State: ALoCoQleAOyFAM4qpWa0rmiJIEoJ2D0C0HV6EbvY2vcGUoRymxPl6l9L3KnFmULa2ol2HhKFTz5J X-Received: by 10.180.85.72 with SMTP id f8mr38647235wiz.62.1433320082336; Wed, 03 Jun 2015 01:28:02 -0700 (PDT) Received: from xps13.localnet (136-92-190-109.dsl.ovh.fr. [109.190.92.136]) by mx.google.com with ESMTPSA id dz4sm25386578wib.17.2015.06.03.01.28.00 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Jun 2015 01:28:01 -0700 (PDT) From: Thomas Monjalon To: "Chilikin, Andrey" Date: Wed, 03 Jun 2015 10:27:11 +0200 Message-ID: <3487943.gKaMDFnUlK@xps13> Organization: 6WIND User-Agent: KMail/4.14.8 (Linux/4.0.4-2-ARCH; KDE/4.14.8; x86_64; ; ) In-Reply-To: References: <1431706132-13223-1-git-send-email-andrey.chilikin@intel.com> <1651836.zg52yVUy7l@xps13> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Cc: dev@dpdk.org Subject: Re: [dpdk-dev] [PATCH] examples: add ip version check for l3fwd app X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Jun 2015 08:28:02 -0000 2015-06-03 08:24, Chilikin, Andrey: > From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com] > > 2015-05-15 17:08, Andrey Chilikin: > > > Added optional ip version check to l3fwd app to allow to detect the ip > > > version if mbuf ol_flags are not set in case of running in a VM with > > > emulated network controllers > > > > > > Signed-off-by: Andrey Chilikin > > [...] > > > +#define DO_IP_VERSION_CHECK 0 > > [...] > > > @@ -953,6 +955,15 @@ l3fwd_simple_forward(struct rte_mbuf *m, uint8_t > > portid, struct lcore_conf *qcon > > > void *d_addr_bytes; > > > uint8_t dst_port; > > > > > > +#if DO_IP_VERSION_CHECK > > > + if (!(m->ol_flags & (PKT_RX_IPV4_HDR | PKT_RX_IPV6_HDR))) { > > > + uint8_t ip_ver = *(uint8_t *)(rte_pktmbuf_mtod(m, unsigned > > char *) + > > > + sizeof(struct ether_hdr)) >> 4; > > > + if (ip_ver == 4) > > > + m->ol_flags |= PKT_RX_IPV4_HDR; > > > + } > > > +#endif > > > > You are adding dead code. When ol_flags will be updated, it will be forget until > > someone enables it. > > In general, compile-time configurations are avoided and it's even worst when > > this is hidden and not easily testable like here. > > Agree, we already thinking about creating separate example l3fwd-vm to cover emulated network controllers. Or you can try to implement some callbacks and choose the implementation at init when detecting the environment.