From b89afb116ca2830cc982624f93e888860868a84b Mon Sep 17 00:00:00 2001 From: Jon Maloy Date: Thu, 22 Mar 2018 20:42:48 +0100 Subject: 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 Signed-off-by: Jon Maloy Signed-off-by: David S. Miller --- net/tipc/discover.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'net/tipc/discover.c') 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, struct tipc_net *tn = tipc_net(net); struct tipc_msg *hdr = buf_msg(skb); u16 caps = msg_node_capabilities(hdr); + bool legacy = tn->legacy_addr_format; u32 signature = msg_node_sig(hdr); u32 dst = msg_dest_domain(hdr); u32 net_id = msg_bc_netid(hdr); @@ -165,13 +166,11 @@ void tipc_disc_rcv(struct net *net, struct sk_buff *skb, disc_dupl_alert(b, self, &maddr); return; } - /* Domain filter only works if both peers use legacy address format */ - if (b->domain) { - if (!tipc_in_scope(dst, self)) - return; - if (!tipc_in_scope(b->domain, src)) - return; - } + if (!tipc_in_scope(legacy, dst, self)) + return; + if (!tipc_in_scope(legacy, b->domain, src)) + return; + tipc_node_check_dest(net, src, b, caps, signature, &maddr, &respond, &dupl_addr); if (dupl_addr) -- cgit v1.2.3-59-g8ed1b