Skip to contentSkip to conversation

tipc: changes to addressing structure

PATCH Applied Jon Maloy 2 participants 6 messages Mar 28, 2018 – Mar 29, 2018

Subsystems (3)
lore
Share & tools
lore
author
#1 lore raw

PATCH 1/2 tipc: introduce command for handling a new 128-bit node identity

In reply to Jon Maloy

We add the possibility to set and get a 128 bit node identifier, as an alternative to the legacy 32-bit node address we are using now.

We also add an option to set and get 'clusterid' in the node. This is the same as what we have so far called 'netid' and performs the same operations. For compatibility the old 'netid' commands are retained, -we just remove them from the help texts.

---
 include/uapi/linux/tipc_netlink.h |  2 +
 tipc/misc.c                       | 78 ++++++++++++++++++++++++++++++-
 tipc/misc.h                       |  2 +
 tipc/node.c                       | 98 +++++++++++++++++++++++++++++++++++++--
 4 files changed, 174 insertions(+), 6 deletions(-)
include/uapi/linux/tipc_netlink.h +2 -0
index 469aa67..6bf8ec6 100644
@@ -162,6 +162,8 @@ enum {
 	TIPC_NLA_NET_UNSPEC,
 	TIPC_NLA_NET_ID,		/* u32 */
 	TIPC_NLA_NET_ADDR,		/* u32 */
+	TIPC_NLA_NET_NODEID,		/* u64 */
+	TIPC_NLA_NET_NODEID_W1,		/* u64 */
 
 	__TIPC_NLA_NET_MAX,
 	TIPC_NLA_NET_MAX = __TIPC_NLA_NET_MAX - 1
tipc/misc.c +77 -1

87 lines not on this page · raw message

tipc/misc.h +2 -0
index 585df74..6e8afdd 100644
@@ -15,5 +15,7 @@
 #include <stdint.h>
 
 uint32_t str2addr(char *str);
+int str2nodeid(char *str, uint8_t *id);
+void nodeid2str(uint8_t *id, char *str);
 
 #endif
tipc/node.c +93 -5

130 lines not on this page · raw message

Signature · 6 lines
2.1.4


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
author
#2 lore raw

PATCH 2/2 tipc: change node address printout formats

In reply to Jon Maloy

Since a node address now per definition is only an unstructured 32-bit integer it makes no sense print it out as a structured string.

In this commit, we replace all occurrences of "<Z.C.N>" printouts with just an "%x".

---
 tipc/link.c      |  3 +--
 tipc/nametable.c | 16 +++++-----------
 tipc/node.c      | 11 ++---------
 tipc/socket.c    |  3 +--
 4 files changed, 9 insertions(+), 24 deletions(-)
tipc/link.c +1 -2
index 4ae1c91..02f14aa 100644
@@ -616,8 +616,7 @@ static void link_mon_print_non_applied(uint16_t applied, uint16_t member_cnt,
 		if (i != applied)
 			printf(",");
 
-		sprintf(addr_str, "%u.%u.%u:", tipc_zone(members[i]),
-			tipc_cluster(members[i]), tipc_node(members[i]));
+		sprintf(addr_str, "%x:", members[i]);
 		state = map_get(up_map, i) ? 'U' : 'D';
 		printf("%s%c", addr_str, state);
 	}
tipc/nametable.c +5 -11
index 770a644..2578940 100644
@@ -26,7 +26,6 @@
 static int nametable_show_cb(const struct nlmsghdr *nlh, void *data)
 {
 	int *iteration = data;
-	char port_id[PORTID_STR_LEN];
 	struct genlmsghdr *genl = mnl_nlmsg_get_payload(nlh);
 	struct nlattr *info[TIPC_NLA_MAX + 1] = {};
 	struct nlattr *attrs[TIPC_NLA_NAME_TABLE_MAX + 1] = {};
@@ -46,22 +45,17 @@ static int nametable_show_cb(const struct nlmsghdr *nlh, void *data)
 		return MNL_CB_ERROR;
 
 	if (!*iteration)
-		printf("%-10s %-10s %-10s %-26s %-10s\n",
-		       "Type", "Lower", "Upper", "Port Identity",
+		printf("%-10s %-10s %-10s %-10s %-10s %-10s\n",
+		       "Type", "Lower", "Upper", "Node", "Port",
 		       "Publication Scope");
 	(*iteration)++;
 
-	snprintf(port_id, sizeof(port_id), "<%u.%u.%u:%u>",
-		 tipc_zone(mnl_attr_get_u32(publ[TIPC_NLA_PUBL_NODE])),
-		 tipc_cluster(mnl_attr_get_u32(publ[TIPC_NLA_PUBL_NODE])),
-		 tipc_node(mnl_attr_get_u32(publ[TIPC_NLA_PUBL_NODE])),
-		 mnl_attr_get_u32(publ[TIPC_NLA_PUBL_REF]));
-
-	printf("%-10u %-10u %-10u %-26s %-12u",
+	printf("%-10u %-10u %-10u %-10x %-10u %-12u",
 	       mnl_attr_get_u32(publ[TIPC_NLA_PUBL_TYPE]),
 	       mnl_attr_get_u32(publ[TIPC_NLA_PUBL_LOWER]),
 	       mnl_attr_get_u32(publ[TIPC_NLA_PUBL_UPPER]),
-	       port_id,
+	       mnl_attr_get_u32(publ[TIPC_NLA_PUBL_NODE]),
+	       mnl_attr_get_u32(publ[TIPC_NLA_PUBL_REF]),
 	       mnl_attr_get_u32(publ[TIPC_NLA_PUBL_KEY]));
 
 	printf("%s\n", scope[mnl_attr_get_u32(publ[TIPC_NLA_PUBL_SCOPE])]);
tipc/node.c +2 -9
index 3ebbe0b..b73b644 100644
@@ -40,10 +40,7 @@ static int node_list_cb(const struct nlmsghdr *nlh, void *data)
 		return MNL_CB_ERROR;
 
 	addr = mnl_attr_get_u32(attrs[TIPC_NLA_NODE_ADDR]);
-	printf("<%u.%u.%u>: ",
-		tipc_zone(addr),
-		tipc_cluster(addr),
-		tipc_node(addr));
+	printf("%x: ", addr);
 
 	if (attrs[TIPC_NLA_NODE_UP])
 		printf("up\n");
@@ -123,11 +120,7 @@ static int cmd_node_get_addr(struct nlmsghdr *nlh, const struct cmd *cmd,
 	}
 	close(sk);
 
-	printf("<%u.%u.%u>\n",
-		tipc_zone(addr.addr.id.node),
-		tipc_cluster(addr.addr.id.node),
-		tipc_node(addr.addr.id.node));
-
+	printf("%x\n", addr.addr.id.node);
 	return 0;
 }
 
tipc/socket.c +1 -2
index 48ba821..852984e 100644
@@ -84,8 +84,7 @@ static int sock_list_cb(const struct nlmsghdr *nlh, void *data)
 		mnl_attr_parse_nested(attrs[TIPC_NLA_SOCK_CON], parse_attrs, con);
 		node = mnl_attr_get_u32(con[TIPC_NLA_CON_NODE]);
 
-		printf("  connected to <%u.%u.%u:%u>", tipc_zone(node),
-			tipc_cluster(node), tipc_node(node),
+		printf("  connected to %x:%u", node,
 			mnl_attr_get_u32(con[TIPC_NLA_CON_SOCK]));
 
 		if (con[TIPC_NLA_CON_FLAG])
Signature · 6 lines
2.1.4


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

Jon Maloy

author
#0 lore raw

cover tipc: changes to addressing structure

1: We introduce ability to set/get 128-bit node identities 2: We rename 'net id' to 'cluster id' in the command API,
of course in a compatible way.
3: We print out all 32-bit node addresses as an integer in hex format,
i.e., we remove the assumption about an internal structure.

Jon Maloy (2):
tipc: introduce command for handling a new 128-bit node identity
tipc: change node address printout formats

 include/uapi/linux/tipc_netlink.h |   2 +
 tipc/link.c                       |   3 +-
 tipc/misc.c                       |  78 ++++++++++++++++++++++++++-
 tipc/misc.h                       |   2 +
 tipc/nametable.c                  |  16 ++----
 tipc/node.c                       | 109 +++++++++++++++++++++++++++++++++-----
 tipc/socket.c                     |   3 +-
 7 files changed, 183 insertions(+), 30 deletions(-)
Signature · 1 line
2.1.4
Applied
#3 lore raw
Quoted 6 lines · Jon Maloy

1: We introduce ability to set/get 128-bit node identities 2: We rename 'net id' to 'cluster id' in the command API,
of course in a compatible way.
3: We print out all 32-bit node addresses as an integer in hex format,
i.e., we remove the assumption about an internal structure.

Applied to iproute2-next. Thanks,

#4 lore raw
Quoted 10 lines · David Ahern
Quoted 6 lines · Jon Maloy

1: We introduce ability to set/get 128-bit node identities 2: We rename 'net id' to 'cluster id' in the command API,
of course in a compatible way.
3: We print out all 32-bit node addresses as an integer in hex format,
i.e., we remove the assumption about an internal structure.

Applied to iproute2-next. Thanks,

BTW, please consider adding json support to tipc. It will make tipc command more robust to changes in output format.

author
#5 lore raw
Quoted 8 lines

-----Original Message-----
From: [email protected] [mailto:netdev- [email protected]] On Behalf Of David Ahern
Sent: Thursday, March 29, 2018 13:59
To: Jon Maloy <[email protected]>; [email protected]; [email protected]
Cc: Mohan Krishna Ghanta Krishnamurthy

[..]
bit node addresses as an integer in hex format,

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

i.e., we remove the assumption about an internal structure.

Applied to iproute2-next. Thanks,

BTW, please consider adding json support to tipc. It will make tipc command more robust to changes in output format.

Yes, we will do that.

///jon