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 83EC2A052E; Mon, 9 Mar 2020 14:39:00 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 353241C06D; Mon, 9 Mar 2020 14:38:59 +0100 (CET) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 800411C06C for ; Mon, 9 Mar 2020 14:38:56 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Mar 2020 06:38:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,533,1574150400"; d="scan'208,217";a="276518589" Received: from vmedvedk-mobl.ger.corp.intel.com (HELO [10.237.220.123]) ([10.237.220.123]) by fmsmga002.fm.intel.com with ESMTP; 09 Mar 2020 06:38:53 -0700 To: Andrzej Ostruszka , dev@dpdk.org, Bruce Richardson Cc: stephen@networkplumber.org References: <20200303125345.26317-1-aostruszka@marvell.com> From: "Medvedkin, Vladimir" Message-ID: <2d22e4b0-6b3c-08c0-e687-b7b420c53150@intel.com> Date: Mon, 9 Mar 2020 13:38:53 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: <20200303125345.26317-1-aostruszka@marvell.com> Content-Language: en-US Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: Re: [dpdk-dev] [PATCH] lpm6: make IPv6 addresses immutable 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" Hi Andrze, Adding const qualifier for bulk lookup leads to compilation problems (see http://c-faq.com/ansi/constmismatch.html) Also I don't think it would be good for usability to make users explicitly cast to (const uint8_t **) when passing 'ips' argument. I'd suggest leaving lookup_bulk as is. On 03/03/2020 12:53, Andrzej Ostruszka wrote: > None of the public functions modify IPv6 address passed so their > parameters are made const. > > Previously only lookup and add were updated to have addresses passed as > const so I'm adding this fixline. > > Fixes: d82927d2f81d ("lpm6: make IPv6 address immutable") > Cc: stephen@networkplumber.org > > Signed-off-by: Andrzej Ostruszka > --- > lib/librte_lpm/rte_lpm6.c | 14 +++++++------- > lib/librte_lpm/rte_lpm6.h | 13 +++++++------ > 2 files changed, 14 insertions(+), 13 deletions(-) > > diff --git a/lib/librte_lpm/rte_lpm6.c b/lib/librte_lpm/rte_lpm6.c > index d515600f1..6089217d6 100644 > --- a/lib/librte_lpm/rte_lpm6.c > +++ b/lib/librte_lpm/rte_lpm6.c > @@ -975,8 +975,8 @@ rte_lpm6_lookup(const struct rte_lpm6 *lpm, const uint8_t *ip, > */ > int > rte_lpm6_lookup_bulk_func(const struct rte_lpm6 *lpm, > - uint8_t ips[][RTE_LPM6_IPV6_ADDR_SIZE], > - int32_t *next_hops, unsigned int n) > + const uint8_t ips[][RTE_LPM6_IPV6_ADDR_SIZE], > + int32_t *next_hops, unsigned int n) > { > unsigned int i; > const struct rte_lpm6_tbl_entry *tbl; > @@ -1019,8 +1019,8 @@ rte_lpm6_lookup_bulk_func(const struct rte_lpm6 *lpm, > * Look for a rule in the high-level rules table > */ > int > -rte_lpm6_is_rule_present(struct rte_lpm6 *lpm, uint8_t *ip, uint8_t depth, > - uint32_t *next_hop) > +rte_lpm6_is_rule_present(struct rte_lpm6 *lpm, const uint8_t *ip, uint8_t depth, > + uint32_t *next_hop) > { > uint8_t masked_ip[RTE_LPM6_IPV6_ADDR_SIZE]; > > @@ -1069,8 +1069,8 @@ rule_delete(struct rte_lpm6 *lpm, uint8_t *ip, uint8_t depth) > */ > int > rte_lpm6_delete_bulk_func(struct rte_lpm6 *lpm, > - uint8_t ips[][RTE_LPM6_IPV6_ADDR_SIZE], uint8_t *depths, > - unsigned n) > + const uint8_t ips[][RTE_LPM6_IPV6_ADDR_SIZE], > + uint8_t *depths, unsigned n) > { > uint8_t masked_ip[RTE_LPM6_IPV6_ADDR_SIZE]; > unsigned i; > @@ -1290,7 +1290,7 @@ remove_tbl(struct rte_lpm6 *lpm, struct rte_lpm_tbl8_hdr *tbl_hdr, > * Deletes a rule > */ > int > -rte_lpm6_delete(struct rte_lpm6 *lpm, uint8_t *ip, uint8_t depth) > +rte_lpm6_delete(struct rte_lpm6 *lpm, const uint8_t *ip, uint8_t depth) > { > uint8_t masked_ip[RTE_LPM6_IPV6_ADDR_SIZE]; > struct rte_lpm6_rule lsp_rule_obj; > diff --git a/lib/librte_lpm/rte_lpm6.h b/lib/librte_lpm/rte_lpm6.h > index 042991f8c..facf09b2b 100644 > --- a/lib/librte_lpm/rte_lpm6.h > +++ b/lib/librte_lpm/rte_lpm6.h > @@ -113,8 +113,8 @@ rte_lpm6_add(struct rte_lpm6 *lpm, const uint8_t *ip, uint8_t depth, > * 1 if the rule exists, 0 if it does not, a negative value on failure > */ > int > -rte_lpm6_is_rule_present(struct rte_lpm6 *lpm, uint8_t *ip, uint8_t depth, > - uint32_t *next_hop); > +rte_lpm6_is_rule_present(struct rte_lpm6 *lpm, const uint8_t *ip, uint8_t depth, > + uint32_t *next_hop); > > /** > * Delete a rule from the LPM table. > @@ -129,7 +129,7 @@ rte_lpm6_is_rule_present(struct rte_lpm6 *lpm, uint8_t *ip, uint8_t depth, > * 0 on success, negative value otherwise > */ > int > -rte_lpm6_delete(struct rte_lpm6 *lpm, uint8_t *ip, uint8_t depth); > +rte_lpm6_delete(struct rte_lpm6 *lpm, const uint8_t *ip, uint8_t depth); > > /** > * Delete a rule from the LPM table. > @@ -147,7 +147,8 @@ rte_lpm6_delete(struct rte_lpm6 *lpm, uint8_t *ip, uint8_t depth); > */ > int > rte_lpm6_delete_bulk_func(struct rte_lpm6 *lpm, > - uint8_t ips[][RTE_LPM6_IPV6_ADDR_SIZE], uint8_t *depths, unsigned n); > + const uint8_t ips[][RTE_LPM6_IPV6_ADDR_SIZE], > + uint8_t *depths, unsigned n); > > /** > * Delete all rules from the LPM table. > @@ -191,8 +192,8 @@ rte_lpm6_lookup(const struct rte_lpm6 *lpm, const uint8_t *ip, uint32_t *next_ho > */ > int > rte_lpm6_lookup_bulk_func(const struct rte_lpm6 *lpm, > - uint8_t ips[][RTE_LPM6_IPV6_ADDR_SIZE], > - int32_t *next_hops, unsigned int n); > + const uint8_t ips[][RTE_LPM6_IPV6_ADDR_SIZE], > + int32_t *next_hops, unsigned int n); > > #ifdef __cplusplus > } -- Regards, Vladimir