]> git.droids-corp.org - dpdk.git/commitdiff
rib: constify arguments
authorStephen Hemminger <stephen@networkplumber.org>
Thu, 25 Jun 2020 20:32:06 +0000 (13:32 -0700)
committerThomas Monjalon <thomas@monjalon.net>
Tue, 7 Jul 2020 21:22:05 +0000 (23:22 +0200)
The getter functions should take a constant pointer
to make it clear that node is not modified.

The rib create functions do not modify their config structure.
Mark the config as constant so that programs can pass
simple constant data.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com>
lib/librte_rib/rte_rib.c
lib/librte_rib/rte_rib.h
lib/librte_rib/rte_rib6.c
lib/librte_rib/rte_rib6.h

index 55d612dc2e275c8aafd78e8ced6f206cafec22e1..e40cf715c099ed91ad2d5e47ec0b35ea92100cea 100644 (file)
@@ -342,7 +342,7 @@ rte_rib_insert(struct rte_rib *rib, uint32_t ip, uint8_t depth)
 }
 
 int
-rte_rib_get_ip(struct rte_rib_node *node, uint32_t *ip)
+rte_rib_get_ip(const struct rte_rib_node *node, uint32_t *ip)
 {
        if ((node == NULL) || (ip == NULL)) {
                rte_errno = EINVAL;
@@ -353,7 +353,7 @@ rte_rib_get_ip(struct rte_rib_node *node, uint32_t *ip)
 }
 
 int
-rte_rib_get_depth(struct rte_rib_node *node, uint8_t *depth)
+rte_rib_get_depth(const struct rte_rib_node *node, uint8_t *depth)
 {
        if ((node == NULL) || (depth == NULL)) {
                rte_errno = EINVAL;
@@ -370,7 +370,7 @@ rte_rib_get_ext(struct rte_rib_node *node)
 }
 
 int
-rte_rib_get_nh(struct rte_rib_node *node, uint64_t *nh)
+rte_rib_get_nh(const struct rte_rib_node *node, uint64_t *nh)
 {
        if ((node == NULL) || (nh == NULL)) {
                rte_errno = EINVAL;
@@ -392,7 +392,7 @@ rte_rib_set_nh(struct rte_rib_node *node, uint64_t nh)
 }
 
 struct rte_rib *
-rte_rib_create(const char *name, int socket_id, struct rte_rib_conf *conf)
+rte_rib_create(const char *name, int socket_id, const struct rte_rib_conf *conf)
 {
        char mem_name[RTE_RIB_NAMESIZE];
        struct rte_rib *rib = NULL;
index da558c417e2dca4004f8834f61caf0d005d2cad0..a9bb42f6fa3bfb65783a6cbab9418967bf8fbb61 100644 (file)
@@ -178,7 +178,7 @@ rte_rib_insert(struct rte_rib *rib, uint32_t ip, uint8_t depth);
  */
 __rte_experimental
 int
-rte_rib_get_ip(struct rte_rib_node *node, uint32_t *ip);
+rte_rib_get_ip(const struct rte_rib_node *node, uint32_t *ip);
 
 /**
  * Get a depth from rte_rib_node
@@ -193,7 +193,7 @@ rte_rib_get_ip(struct rte_rib_node *node, uint32_t *ip);
  */
 __rte_experimental
 int
-rte_rib_get_depth(struct rte_rib_node *node, uint8_t *depth);
+rte_rib_get_depth(const struct rte_rib_node *node, uint8_t *depth);
 
 /**
  * Get ext field from the rib node
@@ -222,7 +222,7 @@ rte_rib_get_ext(struct rte_rib_node *node);
  */
 __rte_experimental
 int
-rte_rib_get_nh(struct rte_rib_node *node, uint64_t *nh);
+rte_rib_get_nh(const struct rte_rib_node *node, uint64_t *nh);
 
 /**
  * Set nexthop into the rib node
@@ -254,7 +254,8 @@ rte_rib_set_nh(struct rte_rib_node *node, uint64_t nh);
  */
 __rte_experimental
 struct rte_rib *
-rte_rib_create(const char *name, int socket_id, struct rte_rib_conf *conf);
+rte_rib_create(const char *name, int socket_id,
+              const struct rte_rib_conf *conf);
 
 /**
  * Find an existing RIB object and return a pointer to it.
index 78b8dcfd94a9ec5b154f0851e769368115b7cc82..02563b951620a225c4d583d76e1537aa1ea64f7f 100644 (file)
@@ -399,7 +399,8 @@ rte_rib6_insert(struct rte_rib6 *rib,
 }
 
 int
-rte_rib6_get_ip(struct rte_rib6_node *node, uint8_t ip[RTE_RIB6_IPV6_ADDR_SIZE])
+rte_rib6_get_ip(const struct rte_rib6_node *node,
+               uint8_t ip[RTE_RIB6_IPV6_ADDR_SIZE])
 {
        if ((node == NULL) || (ip == NULL)) {
                rte_errno = EINVAL;
@@ -410,7 +411,7 @@ rte_rib6_get_ip(struct rte_rib6_node *node, uint8_t ip[RTE_RIB6_IPV6_ADDR_SIZE])
 }
 
 int
-rte_rib6_get_depth(struct rte_rib6_node *node, uint8_t *depth)
+rte_rib6_get_depth(const struct rte_rib6_node *node, uint8_t *depth)
 {
        if ((node == NULL) || (depth == NULL)) {
                rte_errno = EINVAL;
@@ -427,7 +428,7 @@ rte_rib6_get_ext(struct rte_rib6_node *node)
 }
 
 int
-rte_rib6_get_nh(struct rte_rib6_node *node, uint64_t *nh)
+rte_rib6_get_nh(const struct rte_rib6_node *node, uint64_t *nh)
 {
        if ((node == NULL) || (nh == NULL)) {
                rte_errno = EINVAL;
@@ -449,7 +450,8 @@ rte_rib6_set_nh(struct rte_rib6_node *node, uint64_t nh)
 }
 
 struct rte_rib6 *
-rte_rib6_create(const char *name, int socket_id, struct rte_rib6_conf *conf)
+rte_rib6_create(const char *name, int socket_id,
+               const struct rte_rib6_conf *conf)
 {
        char mem_name[RTE_RIB6_NAMESIZE];
        struct rte_rib6 *rib = NULL;
index 4b284c913c70bb9845b7385530aec6a08e1f8eed..24faf4632859bdb9094e12f4aa265a5634a21c67 100644 (file)
@@ -77,7 +77,7 @@ rte_rib6_copy_addr(uint8_t *dst, const uint8_t *src)
  *  0 otherwise
  */
 static inline int
-rte_rib6_is_equal(uint8_t *ip1, uint8_t *ip2) {
+rte_rib6_is_equal(const uint8_t *ip1, const uint8_t *ip2) {
        int i;
 
        if ((ip1 == NULL) || (ip2 == NULL))
@@ -234,8 +234,8 @@ rte_rib6_insert(struct rte_rib6 *rib,
  */
 __rte_experimental
 int
-rte_rib6_get_ip(struct rte_rib6_node *node,
-       uint8_t ip[RTE_RIB6_IPV6_ADDR_SIZE]);
+rte_rib6_get_ip(const struct rte_rib6_node *node,
+               uint8_t ip[RTE_RIB6_IPV6_ADDR_SIZE]);
 
 /**
  * Get a depth from rte_rib6_node
@@ -250,7 +250,7 @@ rte_rib6_get_ip(struct rte_rib6_node *node,
  */
 __rte_experimental
 int
-rte_rib6_get_depth(struct rte_rib6_node *node, uint8_t *depth);
+rte_rib6_get_depth(const struct rte_rib6_node *node, uint8_t *depth);
 
 /**
  * Get ext field from the rte_rib6_node
@@ -279,7 +279,7 @@ rte_rib6_get_ext(struct rte_rib6_node *node);
  */
 __rte_experimental
 int
-rte_rib6_get_nh(struct rte_rib6_node *node, uint64_t *nh);
+rte_rib6_get_nh(const struct rte_rib6_node *node, uint64_t *nh);
 
 /**
  * Set nexthop into the rte_rib6_node
@@ -311,7 +311,8 @@ rte_rib6_set_nh(struct rte_rib6_node *node, uint64_t nh);
  */
 __rte_experimental
 struct rte_rib6 *
-rte_rib6_create(const char *name, int socket_id, struct rte_rib6_conf *conf);
+rte_rib6_create(const char *name, int socket_id,
+               const struct rte_rib6_conf *conf);
 
 /**
  * Find an existing RIB object and return a pointer to it.