aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/net.c
diff options
context:
space:
mode:
authorJon Maloy <jon.maloy@ericsson.com>2018-03-22 15:42:50 -0400
committerDavid S. Miller <davem@davemloft.net>2018-03-23 13:12:18 -0400
commitd50ccc2d3909fc1b4d40e4af16b026f05dc68707 (patch)
tree09ef046f87dc8eb6d4611b26a355477293a01bbd /net/tipc/net.c
parent23fd3eace088ab1872ee59c19191a119ec779ac9 (diff)
tipc: add 128-bit node identifier
We add a 128-bit node identity, as an alternative to the currently used 32-bit node address. For the sake of compatibility and to minimize message header changes we retain the existing 32-bit address field. When not set explicitly by the user, this field will be filled with a hash value generated from the much longer node identity, and be used as a shorthand value for the latter. We permit either the address or the identity to be set by configuration, but not both, so when the address value is set by a legacy user the corresponding 128-bit node identity is generated based on the that value. Acked-by: Ying Xue <ying.xue@windriver.com> Signed-off-by: Jon Maloy <jon.maloy@ericsson.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tipc/net.c')
-rw-r--r--net/tipc/net.c51
1 files changed, 35 insertions, 16 deletions
diff --git a/net/tipc/net.c b/net/tipc/net.c
index 7f140a5308ee..e78674891166 100644
--- a/net/tipc/net.c
+++ b/net/tipc/net.c
@@ -104,27 +104,31 @@
104 * - A local spin_lock protecting the queue of subscriber events. 104 * - A local spin_lock protecting the queue of subscriber events.
105*/ 105*/
106 106
107int tipc_net_start(struct net *net, u32 addr) 107int tipc_net_init(struct net *net, u8 *node_id, u32 addr)
108{ 108{
109 struct tipc_net *tn = tipc_net(net); 109 if (tipc_own_id(net)) {
110 char addr_string[16]; 110 pr_info("Cannot configure node identity twice\n");
111 return -1;
112 }
113 pr_info("Started in network mode\n");
111 114
112 tn->own_addr = addr; 115 if (node_id) {
116 tipc_set_node_id(net, node_id);
117 tipc_net_finalize(net, tipc_own_addr(net));
118 }
119 if (addr)
120 tipc_net_finalize(net, addr);
121 return 0;
122}
113 123
114 /* Ensure that the new address is visible before we reinit. */ 124void tipc_net_finalize(struct net *net, u32 addr)
125{
126 tipc_set_node_addr(net, addr);
115 smp_mb(); 127 smp_mb();
116
117 tipc_named_reinit(net); 128 tipc_named_reinit(net);
118 tipc_sk_reinit(net); 129 tipc_sk_reinit(net);
119
120 tipc_nametbl_publish(net, TIPC_CFG_SRV, addr, addr, 130 tipc_nametbl_publish(net, TIPC_CFG_SRV, addr, addr,
121 TIPC_CLUSTER_SCOPE, 0, addr); 131 TIPC_CLUSTER_SCOPE, 0, addr);
122
123 pr_info("Started in network mode\n");
124 pr_info("Own node address %s, cluster identity %u\n",
125 tipc_addr_string_fill(addr_string, addr),
126 tn->net_id);
127 return 0;
128} 132}
129 133
130void tipc_net_stop(struct net *net) 134void tipc_net_stop(struct net *net)
@@ -146,8 +150,10 @@ void tipc_net_stop(struct net *net)
146static int __tipc_nl_add_net(struct net *net, struct tipc_nl_msg *msg) 150static int __tipc_nl_add_net(struct net *net, struct tipc_nl_msg *msg)
147{ 151{
148 struct tipc_net *tn = net_generic(net, tipc_net_id); 152 struct tipc_net *tn = net_generic(net, tipc_net_id);
149 void *hdr; 153 u64 *w0 = (u64 *)&tn->node_id[0];
154 u64 *w1 = (u64 *)&tn->node_id[8];
150 struct nlattr *attrs; 155 struct nlattr *attrs;
156 void *hdr;
151 157
152 hdr = genlmsg_put(msg->skb, msg->portid, msg->seq, &tipc_genl_family, 158 hdr = genlmsg_put(msg->skb, msg->portid, msg->seq, &tipc_genl_family,
153 NLM_F_MULTI, TIPC_NL_NET_GET); 159 NLM_F_MULTI, TIPC_NL_NET_GET);
@@ -160,7 +166,10 @@ static int __tipc_nl_add_net(struct net *net, struct tipc_nl_msg *msg)
160 166
161 if (nla_put_u32(msg->skb, TIPC_NLA_NET_ID, tn->net_id)) 167 if (nla_put_u32(msg->skb, TIPC_NLA_NET_ID, tn->net_id))
162 goto attr_msg_full; 168 goto attr_msg_full;
163 169 if (nla_put_u64_64bit(msg->skb, TIPC_NLA_NET_NODEID, *w0, 0))
170 goto attr_msg_full;
171 if (nla_put_u64_64bit(msg->skb, TIPC_NLA_NET_NODEID_W1, *w1, 0))
172 goto attr_msg_full;
164 nla_nest_end(msg->skb, attrs); 173 nla_nest_end(msg->skb, attrs);
165 genlmsg_end(msg->skb, hdr); 174 genlmsg_end(msg->skb, hdr);
166 175
@@ -212,6 +221,7 @@ int __tipc_nl_net_set(struct sk_buff *skb, struct genl_info *info)
212 err = nla_parse_nested(attrs, TIPC_NLA_NET_MAX, 221 err = nla_parse_nested(attrs, TIPC_NLA_NET_MAX,
213 info->attrs[TIPC_NLA_NET], tipc_nl_net_policy, 222 info->attrs[TIPC_NLA_NET], tipc_nl_net_policy,
214 info->extack); 223 info->extack);
224
215 if (err) 225 if (err)
216 return err; 226 return err;
217 227
@@ -236,9 +246,18 @@ int __tipc_nl_net_set(struct sk_buff *skb, struct genl_info *info)
236 if (!addr) 246 if (!addr)
237 return -EINVAL; 247 return -EINVAL;
238 tn->legacy_addr_format = true; 248 tn->legacy_addr_format = true;
239 tipc_net_start(net, addr); 249 tipc_net_init(net, NULL, addr);
240 } 250 }
241 251
252 if (attrs[TIPC_NLA_NET_NODEID]) {
253 u8 node_id[NODE_ID_LEN];
254 u64 *w0 = (u64 *)&node_id[0];
255 u64 *w1 = (u64 *)&node_id[8];
256
257 *w0 = nla_get_u64(attrs[TIPC_NLA_NET_NODEID]);
258 *w1 = nla_get_u64(attrs[TIPC_NLA_NET_NODEID_W1]);
259 tipc_net_init(net, node_id, 0);
260 }
242 return 0; 261 return 0;
243} 262}
244 263