[v2] lpm6: make IPv6 addresses immutable

Message ID 20200310091326.5017-1-aostruszka@marvell.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series [v2] lpm6: make IPv6 addresses immutable |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/travis-robot success Travis build: passed
ci/Intel-compilation success Compilation OK

Commit Message

Andrzej Ostruszka [C] March 10, 2020, 9:13 a.m. UTC
  None of the public functions modify IPv6 address passed.  So their
parameters are made const - with the exception of bulk functions.
This exception is due to compatibility problems - some compilers report
problems with const-casting of array of arrays.

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 <aostruszka@marvell.com>
---

V2 changes:
-----------
* reverted changes to the bulk functions and modified commit message to
  reflect that

---
 lib/librte_lpm/rte_lpm6.c | 6 +++---
 lib/librte_lpm/rte_lpm6.h | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)
  

Comments

Vladimir Medvedkin March 10, 2020, 2:47 p.m. UTC | #1
On 10/03/2020 09:13, Andrzej Ostruszka wrote:
> None of the public functions modify IPv6 address passed.  So their
> parameters are made const - with the exception of bulk functions.
> This exception is due to compatibility problems - some compilers report
> problems with const-casting of array of arrays.
>
> 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 <aostruszka@marvell.com>
> ---
>
> V2 changes:
> -----------
> * reverted changes to the bulk functions and modified commit message to
>    reflect that
>
> ---
>   lib/librte_lpm/rte_lpm6.c | 6 +++---
>   lib/librte_lpm/rte_lpm6.h | 6 +++---
>   2 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/lib/librte_lpm/rte_lpm6.c b/lib/librte_lpm/rte_lpm6.c
> index d515600f1..1047efa8a 100644
> --- a/lib/librte_lpm/rte_lpm6.c
> +++ b/lib/librte_lpm/rte_lpm6.c
> @@ -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];
>   
> @@ -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..f96f3372e 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.
Acked-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com>
  
Thomas Monjalon March 31, 2020, 7:46 p.m. UTC | #2
10/03/2020 15:47, Medvedkin, Vladimir:
> On 10/03/2020 09:13, Andrzej Ostruszka wrote:
> > None of the public functions modify IPv6 address passed.  So their
> > parameters are made const - with the exception of bulk functions.
> > This exception is due to compatibility problems - some compilers report
> > problems with const-casting of array of arrays.
> >
> > 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

+ Cc: stable@dpdk.org

> > Signed-off-by: Andrzej Ostruszka <aostruszka@marvell.com>
> 
> Acked-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com>

Applied, thanks
  

Patch

diff --git a/lib/librte_lpm/rte_lpm6.c b/lib/librte_lpm/rte_lpm6.c
index d515600f1..1047efa8a 100644
--- a/lib/librte_lpm/rte_lpm6.c
+++ b/lib/librte_lpm/rte_lpm6.c
@@ -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];
 
@@ -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..f96f3372e 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.