DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: "Medvedkin, Vladimir" <vladimir.medvedkin@intel.com>
Cc: dev@dpdk.org, Stephen Hemminger <stephen@networkplumber.org>
Subject: [dpdk-dev] [PATCH 1/3] rib: constify arguments
Date: Thu, 25 Jun 2020 13:32:06 -0700	[thread overview]
Message-ID: <20200625203208.19315-2-stephen@networkplumber.org> (raw)
In-Reply-To: <20200625203208.19315-1-stephen@networkplumber.org>

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>
---
 lib/librte_rib/rte_rib.c  |  8 ++++----
 lib/librte_rib/rte_rib.h  |  9 +++++----
 lib/librte_rib/rte_rib6.c | 10 ++++++----
 lib/librte_rib/rte_rib6.h | 13 +++++++------
 4 files changed, 22 insertions(+), 18 deletions(-)

diff --git a/lib/librte_rib/rte_rib.c b/lib/librte_rib/rte_rib.c
index 55d612dc2e27..e40cf715c099 100644
--- a/lib/librte_rib/rte_rib.c
+++ b/lib/librte_rib/rte_rib.c
@@ -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;
diff --git a/lib/librte_rib/rte_rib.h b/lib/librte_rib/rte_rib.h
index 6b70de980a2c..a7daa9d8a76e 100644
--- a/lib/librte_rib/rte_rib.h
+++ b/lib/librte_rib/rte_rib.h
@@ -171,7 +171,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
@@ -186,7 +186,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
@@ -215,7 +215,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
@@ -247,7 +247,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.
diff --git a/lib/librte_rib/rte_rib6.c b/lib/librte_rib/rte_rib6.c
index 78b8dcfd94a9..02563b951620 100644
--- a/lib/librte_rib/rte_rib6.c
+++ b/lib/librte_rib/rte_rib6.c
@@ -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;
diff --git a/lib/librte_rib/rte_rib6.h b/lib/librte_rib/rte_rib6.h
index 871457138d7b..e6b4b7fff98c 100644
--- a/lib/librte_rib/rte_rib6.h
+++ b/lib/librte_rib/rte_rib6.h
@@ -70,7 +70,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))
@@ -227,8 +227,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
@@ -243,7 +243,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
@@ -272,7 +272,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
@@ -304,7 +304,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.
-- 
2.26.2


  reply	other threads:[~2020-06-25 20:32 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-25 20:32 [dpdk-dev] [PATCH 0/3] rib: minor fixes Stephen Hemminger
2020-06-25 20:32 ` Stephen Hemminger [this message]
2020-06-26 14:03   ` [dpdk-dev] [PATCH 1/3] rib: constify arguments Medvedkin, Vladimir
2020-06-25 20:32 ` [dpdk-dev] [PATCH 2/3] rib: check for invalid max_nodes Stephen Hemminger
2020-06-26 14:03   ` Medvedkin, Vladimir
2020-06-25 20:32 ` [dpdk-dev] [PATCH 3/3] rib: add C++ include guard Stephen Hemminger
2020-06-26 14:04   ` Medvedkin, Vladimir
2020-07-07 21:25 ` [dpdk-dev] [PATCH 0/3] rib: minor fixes Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200625203208.19315-2-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --cc=dev@dpdk.org \
    --cc=vladimir.medvedkin@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).