From: Ferruh Yigit Subject: Re: [PATCH v2 2/3] net/af_packet: move parse and validation of iface Date: Tue, 27 Nov 2018 17:42:54 +0000 Message-ID: References: <1542707697-175836-1-git-send-email-tiago.lam@intel.com> <1542709592-215007-1-git-send-email-tiago.lam@intel.com> <1542709592-215007-2-git-send-email-tiago.lam@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Cc: linville@tuxdriver.com To: Tiago Lam , dev@dpdk.org Return-path: Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id 9F4F71B45B for ; Tue, 27 Nov 2018 18:42:56 +0100 (CET) In-Reply-To: <1542709592-215007-2-git-send-email-tiago.lam@intel.com> Content-Language: en-US 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 11/20/2018 10:26 AM, Tiago Lam wrote: > Instead of re-iterating through kvlist just to parse the > ETH_AF_PACKET_IFACE_ARG argument in rte_pmd_init_internals(), we now use > the already existing iteration in rte_eth_from_packet() to parse and > validate the ETH_AF_PACKET_IFACE_ARG argument. +1 > > This will be useful for a later commit, which needs to access the > interface name to get the underlying configured MTU. > > Signed-off-by: Tiago Lam > --- > > v2: Fix checkpatches.sh and check-git-log.sh warnings. > > --- > drivers/net/af_packet/rte_eth_af_packet.c | 77 ++++++++++++++++--------------- > 1 file changed, 41 insertions(+), 36 deletions(-) > > diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c > index 264cfc0..8d749a2 100644 > --- a/drivers/net/af_packet/rte_eth_af_packet.c > +++ b/drivers/net/af_packet/rte_eth_af_packet.c > @@ -540,15 +540,12 @@ rte_pmd_init_internals(struct rte_vdev_device *dev, > unsigned int qdisc_bypass, > struct pmd_internals **internals, > struct rte_eth_dev **eth_dev, > - struct rte_kvargs *kvlist) > + const char *ifname) Please align other parameter formatting. <...> > @@ -877,6 +856,32 @@ rte_eth_from_packet(struct rte_vdev_device *dev, > } > continue; > } > + if (strstr(pair->key, ETH_AF_PACKET_IFACE_ARG) != NULL) { > + ifname = pair->value; > + if (strlen(ifname) == 0) { > + RTE_LOG(ERR, PMD, > + "%s: invalid iface value\n", > + name); > + return -1; > + } > + > + continue; > + } Indeed instead of accessing kvargs internal pair->values, this should call rte_kvargs_process() but that is for another patch to fix all occurrences. > + } > + > + if (ifname == NULL) { > + RTE_LOG(ERR, PMD, > + "%s: no interface specified for AF_PACKET ethdev\n", > + name); > + return -1; > + } > + > + ifnamelen = strlen(ifname); I am aware this is copy-paste but since update, perhaps we can use strnlen() instead.