aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc
diff options
context:
space:
mode:
authorJon Maloy <jon.maloy@ericsson.com>2018-03-22 15:42:48 -0400
committerDavid S. Miller <davem@davemloft.net>2018-03-23 13:12:18 -0400
commitb89afb116ca2830cc982624f93e888860868a84b (patch)
tree966e4f18e0330334a3dd534b2a82da56f7dc7005 /net/tipc
parent2026364149db36c6a2c0c8cae8362fe9a7f954dd (diff)
tipc: allow closest-first lookup algorithm when legacy address is configured
The removal of an internal structure of the node address has an unwanted side effect. - Currently, if a user is sending an anycast message with destination domain 0, the tipc_namebl_translate() function will use the 'closest- first' algorithm to first look for a node local destination, and only when no such is found, will it resort to the cluster global 'round- robin' lookup algorithm. - Current users can get around this, and enforce unconditional use of global round-robin by indicating a destination as Z.0.0 or Z.C.0. - This option disappears when we make the node address flat, since the lookup algorithm has no way of recognizing this case. So, as long as there are node local destinations, the algorithm will always select one of those, and there is nothing the sender can do to change this. We solve this by eliminating the 'closest-first' option, which was never a good idea anyway, for non-legacy users, but only for those. To distinguish between legacy users and non-legacy users we introduce a new flag 'legacy_addr_format' in struct tipc_core, to be set when the user configures a legacy-style Z.C.N node address. Hence, when a legacy user indicates a zero lookup domain 'closest-first' is selected, and in all other cases we use 'round-robin'. 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')
-rw-r--r--net/tipc/addr.c12
-rw-r--r--net/tipc/addr.h2
-rw-r--r--net/tipc/core.h3
-rw-r--r--net/tipc/discover.c13
-rw-r--r--net/tipc/name_table.c8
-rw-r--r--net/tipc/net.c2
6 files changed, 22 insertions, 18 deletions
diff --git a/net/tipc/addr.c b/net/tipc/addr.c
index dfc31a730ca5..19987994704f 100644
--- a/net/tipc/addr.c
+++ b/net/tipc/addr.c
@@ -48,15 +48,17 @@ int in_own_node(struct net *net, u32 addr)
48 return (addr == tn->own_addr) || !addr; 48 return (addr == tn->own_addr) || !addr;
49} 49}
50 50
51int tipc_in_scope(u32 domain, u32 addr) 51bool tipc_in_scope(bool legacy_format, u32 domain, u32 addr)
52{ 52{
53 if (!domain || (domain == addr)) 53 if (!domain || (domain == addr))
54 return 1; 54 return true;
55 if (!legacy_format)
56 return false;
55 if (domain == tipc_cluster_mask(addr)) /* domain <Z.C.0> */ 57 if (domain == tipc_cluster_mask(addr)) /* domain <Z.C.0> */
56 return 1; 58 return true;
57 if (domain == (addr & TIPC_ZONE_MASK)) /* domain <Z.0.0> */ 59 if (domain == (addr & TIPC_ZONE_MASK)) /* domain <Z.0.0> */
58 return 1; 60 return true;
59 return 0; 61 return false;
60} 62}
61 63
62char *tipc_addr_string_fill(char *string, u32 addr) 64char *tipc_addr_string_fill(char *string, u32 addr)
diff --git a/net/tipc/addr.h b/net/tipc/addr.h
index 5ffde51b0e68..97bdc0e1a369 100644
--- a/net/tipc/addr.h
+++ b/net/tipc/addr.h
@@ -67,7 +67,7 @@ static inline int tipc_scope2node(struct net *net, int sc)
67 67
68u32 tipc_own_addr(struct net *net); 68u32 tipc_own_addr(struct net *net);
69int in_own_node(struct net *net, u32 addr); 69int in_own_node(struct net *net, u32 addr);
70int tipc_in_scope(u32 domain, u32 addr); 70bool tipc_in_scope(bool legacy_format, u32 domain, u32 addr);
71char *tipc_addr_string_fill(char *string, u32 addr); 71char *tipc_addr_string_fill(char *string, u32 addr);
72 72
73#endif 73#endif
diff --git a/net/tipc/core.h b/net/tipc/core.h
index 347f850dc872..bd2b112680a4 100644
--- a/net/tipc/core.h
+++ b/net/tipc/core.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * net/tipc/core.h: Include file for TIPC global declarations 2 * net/tipc/core.h: Include file for TIPC global declarations
3 * 3 *
4 * Copyright (c) 2005-2006, 2013 Ericsson AB 4 * Copyright (c) 2005-2006, 2013-2018 Ericsson AB
5 * Copyright (c) 2005-2007, 2010-2013, Wind River Systems 5 * Copyright (c) 2005-2007, 2010-2013, Wind River Systems
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
@@ -81,6 +81,7 @@ struct tipc_net {
81 u32 own_addr; 81 u32 own_addr;
82 int net_id; 82 int net_id;
83 int random; 83 int random;
84 bool legacy_addr_format;
84 85
85 /* Node table and node list */ 86 /* Node table and node list */
86 spinlock_t node_list_lock; 87 spinlock_t node_list_lock;
diff --git a/net/tipc/discover.c b/net/tipc/discover.c
index 669af125b3de..82556e19222d 100644
--- a/net/tipc/discover.c
+++ b/net/tipc/discover.c
@@ -139,6 +139,7 @@ void tipc_disc_rcv(struct net *net, struct sk_buff *skb,
139 struct tipc_net *tn = tipc_net(net); 139 struct tipc_net *tn = tipc_net(net);
140 struct tipc_msg *hdr = buf_msg(skb); 140 struct tipc_msg *hdr = buf_msg(skb);
141 u16 caps = msg_node_capabilities(hdr); 141 u16 caps = msg_node_capabilities(hdr);
142 bool legacy = tn->legacy_addr_format;
142 u32 signature = msg_node_sig(hdr); 143 u32 signature = msg_node_sig(hdr);
143 u32 dst = msg_dest_domain(hdr); 144 u32 dst = msg_dest_domain(hdr);
144 u32 net_id = msg_bc_netid(hdr); 145 u32 net_id = msg_bc_netid(hdr);
@@ -165,13 +166,11 @@ void tipc_disc_rcv(struct net *net, struct sk_buff *skb,
165 disc_dupl_alert(b, self, &maddr); 166 disc_dupl_alert(b, self, &maddr);
166 return; 167 return;
167 } 168 }
168 /* Domain filter only works if both peers use legacy address format */ 169 if (!tipc_in_scope(legacy, dst, self))
169 if (b->domain) { 170 return;
170 if (!tipc_in_scope(dst, self)) 171 if (!tipc_in_scope(legacy, b->domain, src))
171 return; 172 return;
172 if (!tipc_in_scope(b->domain, src)) 173
173 return;
174 }
175 tipc_node_check_dest(net, src, b, caps, signature, 174 tipc_node_check_dest(net, src, b, caps, signature,
176 &maddr, &respond, &dupl_addr); 175 &maddr, &respond, &dupl_addr);
177 if (dupl_addr) 176 if (dupl_addr)
diff --git a/net/tipc/name_table.c b/net/tipc/name_table.c
index bbbfc0702634..7478acb39096 100644
--- a/net/tipc/name_table.c
+++ b/net/tipc/name_table.c
@@ -499,7 +499,9 @@ struct publication *tipc_nametbl_remove_publ(struct net *net, u32 type,
499u32 tipc_nametbl_translate(struct net *net, u32 type, u32 instance, 499u32 tipc_nametbl_translate(struct net *net, u32 type, u32 instance,
500 u32 *destnode) 500 u32 *destnode)
501{ 501{
502 struct tipc_net *tn = net_generic(net, tipc_net_id); 502 struct tipc_net *tn = tipc_net(net);
503 bool legacy = tn->legacy_addr_format;
504 u32 self = tipc_own_addr(net);
503 struct sub_seq *sseq; 505 struct sub_seq *sseq;
504 struct name_info *info; 506 struct name_info *info;
505 struct publication *publ; 507 struct publication *publ;
@@ -507,7 +509,7 @@ u32 tipc_nametbl_translate(struct net *net, u32 type, u32 instance,
507 u32 port = 0; 509 u32 port = 0;
508 u32 node = 0; 510 u32 node = 0;
509 511
510 if (!tipc_in_scope(*destnode, tn->own_addr)) 512 if (!tipc_in_scope(legacy, *destnode, self))
511 return 0; 513 return 0;
512 514
513 rcu_read_lock(); 515 rcu_read_lock();
@@ -521,7 +523,7 @@ u32 tipc_nametbl_translate(struct net *net, u32 type, u32 instance,
521 info = sseq->info; 523 info = sseq->info;
522 524
523 /* Closest-First Algorithm */ 525 /* Closest-First Algorithm */
524 if (likely(!*destnode)) { 526 if (legacy && !*destnode) {
525 if (!list_empty(&info->local_publ)) { 527 if (!list_empty(&info->local_publ)) {
526 publ = list_first_entry(&info->local_publ, 528 publ = list_first_entry(&info->local_publ,
527 struct publication, 529 struct publication,
diff --git a/net/tipc/net.c b/net/tipc/net.c
index a074f285e6ea..eb0d7a352e3f 100644
--- a/net/tipc/net.c
+++ b/net/tipc/net.c
@@ -240,7 +240,7 @@ int __tipc_nl_net_set(struct sk_buff *skb, struct genl_info *info)
240 addr = nla_get_u32(attrs[TIPC_NLA_NET_ADDR]); 240 addr = nla_get_u32(attrs[TIPC_NLA_NET_ADDR]);
241 if (!addr) 241 if (!addr)
242 return -EINVAL; 242 return -EINVAL;
243 243 tn->legacy_addr_format = true;
244 tipc_net_start(net, addr); 244 tipc_net_start(net, addr);
245 } 245 }
246 246