Commit 66db239c authored by Jon Maloy's avatar Jon Maloy Committed by David S. Miller

tipc: rename binding table lookup functions

The binding table provides four different lookup functions, which
purpose is not obvious neither by their names nor by the (lack of)
descriptions.

We now give these functions names that better match their purposes,
and improve the comments that describe what they are doing.
Signed-off-by: default avatarJon Maloy <jmaloy@redhat.com>
Acked-by: default avatarYing Xue <ying.xue@windriver.com>
Acked-by: default avatarHoang Le <hoang.h.le@dektech.com.au>
Acked-by: default avatarTung Nguyen <tung.q.nguyen@dektech.com.au>
Acked-by: default avatarXin Long <lucien.xin@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 2c98da07
...@@ -723,7 +723,7 @@ bool tipc_msg_lookup_dest(struct net *net, struct sk_buff *skb, int *err) ...@@ -723,7 +723,7 @@ bool tipc_msg_lookup_dest(struct net *net, struct sk_buff *skb, int *err)
if (msg_reroute_cnt(msg)) if (msg_reroute_cnt(msg))
return false; return false;
dnode = tipc_scope2node(net, msg_lookup_scope(msg)); dnode = tipc_scope2node(net, msg_lookup_scope(msg));
dport = tipc_nametbl_translate(net, msg_nametype(msg), dport = tipc_nametbl_lookup_anycast(net, msg_nametype(msg),
msg_nameinst(msg), &dnode); msg_nameinst(msg), &dnode);
if (!dport) if (!dport)
return false; return false;
......
...@@ -544,24 +544,26 @@ struct publication *tipc_nametbl_remove_publ(struct net *net, ...@@ -544,24 +544,26 @@ struct publication *tipc_nametbl_remove_publ(struct net *net,
} }
/** /**
* tipc_nametbl_translate - perform service instance to socket translation * tipc_nametbl_lookup_anycast - perform service instance to socket translation
* @net: network namespace * @net: network namespace
* @type: message type * @type: message type
* @instance: message instance * @instance: message instance
* @dnode: the search domain used during translation * @dnode: the search domain used during translation
* *
* On entry, 'dnode' is the search domain used during the lookup
*
* On exit: * On exit:
* - if translation is deferred to another node, leave 'dnode' unchanged and * - if lookup is deferred to another node, leave 'dnode' unchanged and return 0
* return 0 * - if lookup is attempted and succeeds, set 'dnode' to the publishing node and
* - if translation is attempted and succeeds, set 'dnode' to the publishing * return the published (non-zero) port number
* node and return the published (non-zero) port number * - if lookup is attempted and fails, set 'dnode' to 0 and return 0
* - if translation is attempted and fails, set 'dnode' to 0 and return 0
* *
* Note that for legacy users (node configured with Z.C.N address format) the * Note that for legacy users (node configured with Z.C.N address format) the
* 'closest-first' lookup algorithm must be maintained, i.e., if dnode is 0 * 'closest-first' lookup algorithm must be maintained, i.e., if dnode is 0
* we must look in the local binding list first * we must look in the local binding list first
*/ */
u32 tipc_nametbl_translate(struct net *net, u32 type, u32 instance, u32 *dnode) u32 tipc_nametbl_lookup_anycast(struct net *net, u32 type,
u32 instance, u32 *dnode)
{ {
struct tipc_net *tn = tipc_net(net); struct tipc_net *tn = tipc_net(net);
bool legacy = tn->legacy_addr_format; bool legacy = tn->legacy_addr_format;
...@@ -617,9 +619,15 @@ u32 tipc_nametbl_translate(struct net *net, u32 type, u32 instance, u32 *dnode) ...@@ -617,9 +619,15 @@ u32 tipc_nametbl_translate(struct net *net, u32 type, u32 instance, u32 *dnode)
return port; return port;
} }
bool tipc_nametbl_lookup(struct net *net, u32 type, u32 instance, u32 scope, /* tipc_nametbl_lookup_group(): lookup destinaton(s) in a communication group
struct list_head *dsts, int *dstcnt, u32 exclude, * Returns a list of one (== group anycast) or more (== group multicast)
bool all) * destination socket/node pairs matching the given address.
* The requester may or may not want to exclude himself from the list.
*/
bool tipc_nametbl_lookup_group(struct net *net, u32 type, u32 instance,
u32 scope, struct list_head *dsts,
int *dstcnt, u32 exclude,
bool mcast)
{ {
u32 self = tipc_own_addr(net); u32 self = tipc_own_addr(net);
struct service_range *sr; struct service_range *sr;
...@@ -646,7 +654,7 @@ bool tipc_nametbl_lookup(struct net *net, u32 type, u32 instance, u32 scope, ...@@ -646,7 +654,7 @@ bool tipc_nametbl_lookup(struct net *net, u32 type, u32 instance, u32 scope,
continue; continue;
tipc_dest_push(dsts, p->sk.node, p->sk.ref); tipc_dest_push(dsts, p->sk.node, p->sk.ref);
(*dstcnt)++; (*dstcnt)++;
if (all) if (mcast)
continue; continue;
list_move_tail(&p->all_publ, &sr->all_publ); list_move_tail(&p->all_publ, &sr->all_publ);
break; break;
...@@ -658,8 +666,14 @@ bool tipc_nametbl_lookup(struct net *net, u32 type, u32 instance, u32 scope, ...@@ -658,8 +666,14 @@ bool tipc_nametbl_lookup(struct net *net, u32 type, u32 instance, u32 scope,
return !list_empty(dsts); return !list_empty(dsts);
} }
void tipc_nametbl_mc_lookup(struct net *net, u32 type, u32 lower, u32 upper, /* tipc_nametbl_lookup_mcast_sockets(): look up node local destinaton sockets
u32 scope, bool exact, struct list_head *dports) * matching the given address
* Used on nodes which have received a multicast/broadcast message
* Returns a list of local sockets
*/
void tipc_nametbl_lookup_mcast_sockets(struct net *net, u32 type, u32 lower,
u32 upper, u32 scope, bool exact,
struct list_head *dports)
{ {
struct service_range *sr; struct service_range *sr;
struct tipc_service *sc; struct tipc_service *sc;
...@@ -682,11 +696,12 @@ void tipc_nametbl_mc_lookup(struct net *net, u32 type, u32 lower, u32 upper, ...@@ -682,11 +696,12 @@ void tipc_nametbl_mc_lookup(struct net *net, u32 type, u32 lower, u32 upper,
rcu_read_unlock(); rcu_read_unlock();
} }
/* tipc_nametbl_lookup_dst_nodes - find broadcast destination nodes /* tipc_nametbl_lookup_mcast_nodes(): look up all destination nodes matching
* - Creates list of nodes that overlap the given multicast address * the given address. Used in sending node.
* - Determines if any node local destinations overlap * Used on nodes which are sending out a multicast/broadcast message
* Returns a list of nodes, including own node if applicable
*/ */
void tipc_nametbl_lookup_dst_nodes(struct net *net, u32 type, u32 lower, void tipc_nametbl_lookup_mcast_nodes(struct net *net, u32 type, u32 lower,
u32 upper, struct tipc_nlist *nodes) u32 upper, struct tipc_nlist *nodes)
{ {
struct service_range *sr; struct service_range *sr;
......
...@@ -111,16 +111,19 @@ struct name_table { ...@@ -111,16 +111,19 @@ struct name_table {
int tipc_nl_name_table_dump(struct sk_buff *skb, struct netlink_callback *cb); int tipc_nl_name_table_dump(struct sk_buff *skb, struct netlink_callback *cb);
u32 tipc_nametbl_translate(struct net *net, u32 type, u32 instance, u32 *node); u32 tipc_nametbl_lookup_anycast(struct net *net, u32 type, u32 instance,
void tipc_nametbl_mc_lookup(struct net *net, u32 type, u32 lower, u32 upper, u32 *node);
u32 scope, bool exact, struct list_head *dports); void tipc_nametbl_lookup_mcast_sockets(struct net *net, u32 type, u32 lower,
void tipc_nametbl_build_group(struct net *net, struct tipc_group *grp, u32 upper, u32 scope, bool exact,
u32 type, u32 domain); struct list_head *dports);
void tipc_nametbl_lookup_dst_nodes(struct net *net, u32 type, u32 lower, void tipc_nametbl_lookup_mcast_nodes(struct net *net, u32 type, u32 lower,
u32 upper, struct tipc_nlist *nodes); u32 upper, struct tipc_nlist *nodes);
bool tipc_nametbl_lookup(struct net *net, u32 type, u32 instance, u32 domain, bool tipc_nametbl_lookup_group(struct net *net, u32 type, u32 instance,
struct list_head *dsts, int *dstcnt, u32 exclude, u32 domain, struct list_head *dsts,
int *dstcnt, u32 exclude,
bool all); bool all);
void tipc_nametbl_build_group(struct net *net, struct tipc_group *grp,
u32 type, u32 domain);
struct publication *tipc_nametbl_publish(struct net *net, struct tipc_uaddr *ua, struct publication *tipc_nametbl_publish(struct net *net, struct tipc_uaddr *ua,
struct tipc_socket_addr *sk, u32 key); struct tipc_socket_addr *sk, u32 key);
void tipc_nametbl_withdraw(struct net *net, struct tipc_uaddr *ua, void tipc_nametbl_withdraw(struct net *net, struct tipc_uaddr *ua,
......
...@@ -863,7 +863,7 @@ static int tipc_sendmcast(struct socket *sock, struct tipc_service_range *seq, ...@@ -863,7 +863,7 @@ static int tipc_sendmcast(struct socket *sock, struct tipc_service_range *seq,
/* Lookup destination nodes */ /* Lookup destination nodes */
tipc_nlist_init(&dsts, tipc_own_addr(net)); tipc_nlist_init(&dsts, tipc_own_addr(net));
tipc_nametbl_lookup_dst_nodes(net, seq->type, seq->lower, tipc_nametbl_lookup_mcast_nodes(net, seq->type, seq->lower,
seq->upper, &dsts); seq->upper, &dsts);
if (!dsts.local && !dsts.remote) if (!dsts.local && !dsts.remote)
return -EHOSTUNREACH; return -EHOSTUNREACH;
...@@ -1032,8 +1032,9 @@ static int tipc_send_group_anycast(struct socket *sock, struct msghdr *m, ...@@ -1032,8 +1032,9 @@ static int tipc_send_group_anycast(struct socket *sock, struct msghdr *m,
/* Look for a non-congested destination member, if any */ /* Look for a non-congested destination member, if any */
while (1) { while (1) {
if (!tipc_nametbl_lookup(net, type, inst, scope, &dsts, if (!tipc_nametbl_lookup_group(net, type, inst, scope,
&dstcnt, exclude, false)) &dsts, &dstcnt, exclude,
false))
return -EHOSTUNREACH; return -EHOSTUNREACH;
tipc_dest_pop(&dsts, &node, &port); tipc_dest_pop(&dsts, &node, &port);
cong = tipc_group_cong(tsk->group, node, port, blks, cong = tipc_group_cong(tsk->group, node, port, blks,
...@@ -1179,7 +1180,7 @@ static int tipc_send_group_mcast(struct socket *sock, struct msghdr *m, ...@@ -1179,7 +1180,7 @@ static int tipc_send_group_mcast(struct socket *sock, struct msghdr *m,
scope = msg_lookup_scope(hdr); scope = msg_lookup_scope(hdr);
exclude = tipc_group_exclude(grp); exclude = tipc_group_exclude(grp);
if (!tipc_nametbl_lookup(net, type, inst, scope, &dsts, if (!tipc_nametbl_lookup_group(net, type, inst, scope, &dsts,
&dstcnt, exclude, true)) &dstcnt, exclude, true))
return -EHOSTUNREACH; return -EHOSTUNREACH;
...@@ -1254,7 +1255,7 @@ void tipc_sk_mcast_rcv(struct net *net, struct sk_buff_head *arrvq, ...@@ -1254,7 +1255,7 @@ void tipc_sk_mcast_rcv(struct net *net, struct sk_buff_head *arrvq,
} }
/* Create destination port list: */ /* Create destination port list: */
tipc_nametbl_mc_lookup(net, type, lower, upper, tipc_nametbl_lookup_mcast_sockets(net, type, lower, upper,
scope, exact, &dports); scope, exact, &dports);
/* Clone message per destination */ /* Clone message per destination */
...@@ -1485,7 +1486,7 @@ static int __tipc_sendmsg(struct socket *sock, struct msghdr *m, size_t dlen) ...@@ -1485,7 +1486,7 @@ static int __tipc_sendmsg(struct socket *sock, struct msghdr *m, size_t dlen)
type = dest->addr.name.name.type; type = dest->addr.name.name.type;
inst = dest->addr.name.name.instance; inst = dest->addr.name.name.instance;
dnode = dest->addr.name.domain; dnode = dest->addr.name.domain;
dport = tipc_nametbl_translate(net, type, inst, &dnode); dport = tipc_nametbl_lookup_anycast(net, type, inst, &dnode);
if (unlikely(!dport && !dnode)) if (unlikely(!dport && !dnode))
return -EHOSTUNREACH; return -EHOSTUNREACH;
} else if (dest->addrtype == TIPC_SOCKET_ADDR) { } else if (dest->addrtype == TIPC_SOCKET_ADDR) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment