Skip to content

Commit 758b595

Browse files
lmcjomadavem330
authored andcommitted
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: Jon Maloy <jmaloy@redhat.com> Acked-by: Ying Xue <ying.xue@windriver.com> Acked-by: Hoang Le <hoang.h.le@dektech.com.au> Acked-by: Tung Nguyen <tung.q.nguyen@dektech.com.au> Acked-by: Xin Long <lucien.xin@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 86b2509 commit 758b595

File tree

4 files changed

+56
-37
lines changed

4 files changed

+56
-37
lines changed

net/tipc/msg.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -723,8 +723,8 @@ bool tipc_msg_lookup_dest(struct net *net, struct sk_buff *skb, int *err)
723723
if (msg_reroute_cnt(msg))
724724
return false;
725725
dnode = tipc_scope2node(net, msg_lookup_scope(msg));
726-
dport = tipc_nametbl_translate(net, msg_nametype(msg),
727-
msg_nameinst(msg), &dnode);
726+
dport = tipc_nametbl_lookup_anycast(net, msg_nametype(msg),
727+
msg_nameinst(msg), &dnode);
728728
if (!dport)
729729
return false;
730730
msg_incr_reroute_cnt(msg);

net/tipc/name_table.c

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -544,24 +544,26 @@ struct publication *tipc_nametbl_remove_publ(struct net *net,
544544
}
545545

546546
/**
547-
* tipc_nametbl_translate - perform service instance to socket translation
547+
* tipc_nametbl_lookup_anycast - perform service instance to socket translation
548548
* @net: network namespace
549549
* @type: message type
550550
* @instance: message instance
551551
* @dnode: the search domain used during translation
552552
*
553+
* On entry, 'dnode' is the search domain used during the lookup
554+
*
553555
* On exit:
554-
* - if translation is deferred to another node, leave 'dnode' unchanged and
555-
* return 0
556-
* - if translation is attempted and succeeds, set 'dnode' to the publishing
557-
* node and return the published (non-zero) port number
558-
* - if translation is attempted and fails, set 'dnode' to 0 and return 0
556+
* - if lookup is deferred to another node, leave 'dnode' unchanged and return 0
557+
* - if lookup is attempted and succeeds, set 'dnode' to the publishing node and
558+
* return the published (non-zero) port number
559+
* - if lookup is attempted and fails, set 'dnode' to 0 and return 0
559560
*
560561
* Note that for legacy users (node configured with Z.C.N address format) the
561562
* 'closest-first' lookup algorithm must be maintained, i.e., if dnode is 0
562563
* we must look in the local binding list first
563564
*/
564-
u32 tipc_nametbl_translate(struct net *net, u32 type, u32 instance, u32 *dnode)
565+
u32 tipc_nametbl_lookup_anycast(struct net *net, u32 type,
566+
u32 instance, u32 *dnode)
565567
{
566568
struct tipc_net *tn = tipc_net(net);
567569
bool legacy = tn->legacy_addr_format;
@@ -617,9 +619,15 @@ u32 tipc_nametbl_translate(struct net *net, u32 type, u32 instance, u32 *dnode)
617619
return port;
618620
}
619621

620-
bool tipc_nametbl_lookup(struct net *net, u32 type, u32 instance, u32 scope,
621-
struct list_head *dsts, int *dstcnt, u32 exclude,
622-
bool all)
622+
/* tipc_nametbl_lookup_group(): lookup destinaton(s) in a communication group
623+
* Returns a list of one (== group anycast) or more (== group multicast)
624+
* destination socket/node pairs matching the given address.
625+
* The requester may or may not want to exclude himself from the list.
626+
*/
627+
bool tipc_nametbl_lookup_group(struct net *net, u32 type, u32 instance,
628+
u32 scope, struct list_head *dsts,
629+
int *dstcnt, u32 exclude,
630+
bool mcast)
623631
{
624632
u32 self = tipc_own_addr(net);
625633
struct service_range *sr;
@@ -646,7 +654,7 @@ bool tipc_nametbl_lookup(struct net *net, u32 type, u32 instance, u32 scope,
646654
continue;
647655
tipc_dest_push(dsts, p->sk.node, p->sk.ref);
648656
(*dstcnt)++;
649-
if (all)
657+
if (mcast)
650658
continue;
651659
list_move_tail(&p->all_publ, &sr->all_publ);
652660
break;
@@ -658,8 +666,14 @@ bool tipc_nametbl_lookup(struct net *net, u32 type, u32 instance, u32 scope,
658666
return !list_empty(dsts);
659667
}
660668

661-
void tipc_nametbl_mc_lookup(struct net *net, u32 type, u32 lower, u32 upper,
662-
u32 scope, bool exact, struct list_head *dports)
669+
/* tipc_nametbl_lookup_mcast_sockets(): look up node local destinaton sockets
670+
* matching the given address
671+
* Used on nodes which have received a multicast/broadcast message
672+
* Returns a list of local sockets
673+
*/
674+
void tipc_nametbl_lookup_mcast_sockets(struct net *net, u32 type, u32 lower,
675+
u32 upper, u32 scope, bool exact,
676+
struct list_head *dports)
663677
{
664678
struct service_range *sr;
665679
struct tipc_service *sc;
@@ -682,12 +696,13 @@ void tipc_nametbl_mc_lookup(struct net *net, u32 type, u32 lower, u32 upper,
682696
rcu_read_unlock();
683697
}
684698

685-
/* tipc_nametbl_lookup_dst_nodes - find broadcast destination nodes
686-
* - Creates list of nodes that overlap the given multicast address
687-
* - Determines if any node local destinations overlap
699+
/* tipc_nametbl_lookup_mcast_nodes(): look up all destination nodes matching
700+
* the given address. Used in sending node.
701+
* Used on nodes which are sending out a multicast/broadcast message
702+
* Returns a list of nodes, including own node if applicable
688703
*/
689-
void tipc_nametbl_lookup_dst_nodes(struct net *net, u32 type, u32 lower,
690-
u32 upper, struct tipc_nlist *nodes)
704+
void tipc_nametbl_lookup_mcast_nodes(struct net *net, u32 type, u32 lower,
705+
u32 upper, struct tipc_nlist *nodes)
691706
{
692707
struct service_range *sr;
693708
struct tipc_service *sc;

net/tipc/name_table.h

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -111,16 +111,19 @@ struct name_table {
111111

112112
int tipc_nl_name_table_dump(struct sk_buff *skb, struct netlink_callback *cb);
113113

114-
u32 tipc_nametbl_translate(struct net *net, u32 type, u32 instance, u32 *node);
115-
void tipc_nametbl_mc_lookup(struct net *net, u32 type, u32 lower, u32 upper,
116-
u32 scope, bool exact, struct list_head *dports);
114+
u32 tipc_nametbl_lookup_anycast(struct net *net, u32 type, u32 instance,
115+
u32 *node);
116+
void tipc_nametbl_lookup_mcast_sockets(struct net *net, u32 type, u32 lower,
117+
u32 upper, u32 scope, bool exact,
118+
struct list_head *dports);
119+
void tipc_nametbl_lookup_mcast_nodes(struct net *net, u32 type, u32 lower,
120+
u32 upper, struct tipc_nlist *nodes);
121+
bool tipc_nametbl_lookup_group(struct net *net, u32 type, u32 instance,
122+
u32 domain, struct list_head *dsts,
123+
int *dstcnt, u32 exclude,
124+
bool all);
117125
void tipc_nametbl_build_group(struct net *net, struct tipc_group *grp,
118126
u32 type, u32 domain);
119-
void tipc_nametbl_lookup_dst_nodes(struct net *net, u32 type, u32 lower,
120-
u32 upper, struct tipc_nlist *nodes);
121-
bool tipc_nametbl_lookup(struct net *net, u32 type, u32 instance, u32 domain,
122-
struct list_head *dsts, int *dstcnt, u32 exclude,
123-
bool all);
124127
struct publication *tipc_nametbl_publish(struct net *net, struct tipc_uaddr *ua,
125128
struct tipc_socket_addr *sk, u32 key);
126129
void tipc_nametbl_withdraw(struct net *net, struct tipc_uaddr *ua,

net/tipc/socket.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -863,8 +863,8 @@ static int tipc_sendmcast(struct socket *sock, struct tipc_service_range *seq,
863863

864864
/* Lookup destination nodes */
865865
tipc_nlist_init(&dsts, tipc_own_addr(net));
866-
tipc_nametbl_lookup_dst_nodes(net, seq->type, seq->lower,
867-
seq->upper, &dsts);
866+
tipc_nametbl_lookup_mcast_nodes(net, seq->type, seq->lower,
867+
seq->upper, &dsts);
868868
if (!dsts.local && !dsts.remote)
869869
return -EHOSTUNREACH;
870870

@@ -1032,8 +1032,9 @@ static int tipc_send_group_anycast(struct socket *sock, struct msghdr *m,
10321032

10331033
/* Look for a non-congested destination member, if any */
10341034
while (1) {
1035-
if (!tipc_nametbl_lookup(net, type, inst, scope, &dsts,
1036-
&dstcnt, exclude, false))
1035+
if (!tipc_nametbl_lookup_group(net, type, inst, scope,
1036+
&dsts, &dstcnt, exclude,
1037+
false))
10371038
return -EHOSTUNREACH;
10381039
tipc_dest_pop(&dsts, &node, &port);
10391040
cong = tipc_group_cong(tsk->group, node, port, blks,
@@ -1179,8 +1180,8 @@ static int tipc_send_group_mcast(struct socket *sock, struct msghdr *m,
11791180
scope = msg_lookup_scope(hdr);
11801181
exclude = tipc_group_exclude(grp);
11811182

1182-
if (!tipc_nametbl_lookup(net, type, inst, scope, &dsts,
1183-
&dstcnt, exclude, true))
1183+
if (!tipc_nametbl_lookup_group(net, type, inst, scope, &dsts,
1184+
&dstcnt, exclude, true))
11841185
return -EHOSTUNREACH;
11851186

11861187
if (dstcnt == 1) {
@@ -1254,8 +1255,8 @@ void tipc_sk_mcast_rcv(struct net *net, struct sk_buff_head *arrvq,
12541255
}
12551256

12561257
/* Create destination port list: */
1257-
tipc_nametbl_mc_lookup(net, type, lower, upper,
1258-
scope, exact, &dports);
1258+
tipc_nametbl_lookup_mcast_sockets(net, type, lower, upper,
1259+
scope, exact, &dports);
12591260

12601261
/* Clone message per destination */
12611262
while (tipc_dest_pop(&dports, NULL, &portid)) {
@@ -1485,7 +1486,7 @@ static int __tipc_sendmsg(struct socket *sock, struct msghdr *m, size_t dlen)
14851486
type = dest->addr.name.name.type;
14861487
inst = dest->addr.name.name.instance;
14871488
dnode = dest->addr.name.domain;
1488-
dport = tipc_nametbl_translate(net, type, inst, &dnode);
1489+
dport = tipc_nametbl_lookup_anycast(net, type, inst, &dnode);
14891490
if (unlikely(!dport && !dnode))
14901491
return -EHOSTUNREACH;
14911492
} else if (dest->addrtype == TIPC_SOCKET_ADDR) {

0 commit comments

Comments
 (0)