[sheepdog] [PATCH 1/6] sheep: add nid_to_str() for formatting node id from sockfd subsystem

Hitoshi Mitake mitake.hitoshi at gmail.com
Tue Aug 13 18:27:36 CEST 2013


sockfd subsystem only has node_id for representing node of each sockfd
entry, so it cannot use node_to_str() for formatting node id. This
patch implements a new function nid_to_str() for sockfd
subsystem, and make node_to_str() a wrapper for it.

Signed-off-by: Hitoshi Mitake <mitake.hitoshi at lab.ntt.co.jp>
---
 include/sheep.h | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/include/sheep.h b/include/sheep.h
index 1d146bd..bb40974 100644
--- a/include/sheep.h
+++ b/include/sheep.h
@@ -315,11 +315,11 @@ static inline int nodes_to_vnodes(struct sd_node *nodes, int nr,
 
 #define MAX_NODE_STR_LEN 256
 
-static inline const char *node_to_str(const struct sd_node *id)
+static inline const char *nid_to_str(const struct node_id *id)
 {
 	static __thread char str[MAX_NODE_STR_LEN];
 	int af = AF_INET6;
-	const uint8_t *addr = id->nid.addr;
+	const uint8_t *addr = (const uint8_t *)id->addr;
 
 	/* Find address family type */
 	if (addr[12]) {
@@ -332,11 +332,16 @@ static inline const char *node_to_str(const struct sd_node *id)
 
 	snprintf(str, sizeof(str), "%s ip:%s port:%d",
 		(af == AF_INET) ? "IPv4" : "IPv6",
-		addr_to_str(id->nid.addr, 0), id->nid.port);
+		addr_to_str(addr, 0), id->port);
 
 	return str;
 }
 
+static inline const char *node_to_str(const struct sd_node *id)
+{
+	return nid_to_str(&id->nid);
+}
+
 static inline struct sd_node *str_to_node(const char *str, struct sd_node *id)
 {
 	int port;
-- 
1.8.1.2




More information about the sheepdog mailing list