diff options
author | Jon Paul Maloy <jon.maloy@ericsson.com> | 2017-01-18 13:50:51 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-01-20 12:10:16 -0500 |
commit | 2ae0b8af1fe35ddaa2e46704ae31a2f9cac0349d (patch) | |
tree | fb6ff13876c71217c98fad4456695b479f81e64f /net/tipc | |
parent | 9999974a8318b605ebae08a87e86232659e56a52 (diff) |
tipc: add functionality to lookup multicast destination nodes
As a further preparation for the upcoming 'replicast' functionality,
we add some necessary structs and functions for looking up and returning
a list of all nodes that host destinations for a given multicast message.
Reviewed-by: Parthasarathy Bhuvaragan <parthasarathy.bhuvaragan@ericsson.com>
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/bcast.c | 33 | ||||
-rw-r--r-- | net/tipc/bcast.h | 15 | ||||
-rw-r--r-- | net/tipc/name_table.c | 38 | ||||
-rw-r--r-- | net/tipc/name_table.h | 9 |
4 files changed, 87 insertions, 8 deletions
diff --git a/net/tipc/bcast.c b/net/tipc/bcast.c index 325627612bac..412d3351abb7 100644 --- a/net/tipc/bcast.c +++ b/net/tipc/bcast.c | |||
@@ -39,9 +39,8 @@ | |||
39 | #include "socket.h" | 39 | #include "socket.h" |
40 | #include "msg.h" | 40 | #include "msg.h" |
41 | #include "bcast.h" | 41 | #include "bcast.h" |
42 | #include "name_distr.h" | ||
43 | #include "link.h" | 42 | #include "link.h" |
44 | #include "node.h" | 43 | #include "name_table.h" |
45 | 44 | ||
46 | #define BCLINK_WIN_DEFAULT 50 /* bcast link window size (default) */ | 45 | #define BCLINK_WIN_DEFAULT 50 /* bcast link window size (default) */ |
47 | #define BCLINK_WIN_MIN 32 /* bcast minimum link window size */ | 46 | #define BCLINK_WIN_MIN 32 /* bcast minimum link window size */ |
@@ -434,3 +433,33 @@ void tipc_bcast_stop(struct net *net) | |||
434 | kfree(tn->bcbase); | 433 | kfree(tn->bcbase); |
435 | kfree(tn->bcl); | 434 | kfree(tn->bcl); |
436 | } | 435 | } |
436 | |||
437 | void tipc_nlist_init(struct tipc_nlist *nl, u32 self) | ||
438 | { | ||
439 | memset(nl, 0, sizeof(*nl)); | ||
440 | INIT_LIST_HEAD(&nl->list); | ||
441 | nl->self = self; | ||
442 | } | ||
443 | |||
444 | void tipc_nlist_add(struct tipc_nlist *nl, u32 node) | ||
445 | { | ||
446 | if (node == nl->self) | ||
447 | nl->local = true; | ||
448 | else if (u32_push(&nl->list, node)) | ||
449 | nl->remote++; | ||
450 | } | ||
451 | |||
452 | void tipc_nlist_del(struct tipc_nlist *nl, u32 node) | ||
453 | { | ||
454 | if (node == nl->self) | ||
455 | nl->local = false; | ||
456 | else if (u32_del(&nl->list, node)) | ||
457 | nl->remote--; | ||
458 | } | ||
459 | |||
460 | void tipc_nlist_purge(struct tipc_nlist *nl) | ||
461 | { | ||
462 | u32_list_purge(&nl->list); | ||
463 | nl->remote = 0; | ||
464 | nl->local = 0; | ||
465 | } | ||
diff --git a/net/tipc/bcast.h b/net/tipc/bcast.h index 855d53c64ab3..18f379198f8f 100644 --- a/net/tipc/bcast.h +++ b/net/tipc/bcast.h | |||
@@ -42,9 +42,22 @@ | |||
42 | struct tipc_node; | 42 | struct tipc_node; |
43 | struct tipc_msg; | 43 | struct tipc_msg; |
44 | struct tipc_nl_msg; | 44 | struct tipc_nl_msg; |
45 | struct tipc_node_map; | 45 | struct tipc_nlist; |
46 | struct tipc_nitem; | ||
46 | extern const char tipc_bclink_name[]; | 47 | extern const char tipc_bclink_name[]; |
47 | 48 | ||
49 | struct tipc_nlist { | ||
50 | struct list_head list; | ||
51 | u32 self; | ||
52 | u16 remote; | ||
53 | bool local; | ||
54 | }; | ||
55 | |||
56 | void tipc_nlist_init(struct tipc_nlist *nl, u32 self); | ||
57 | void tipc_nlist_purge(struct tipc_nlist *nl); | ||
58 | void tipc_nlist_add(struct tipc_nlist *nl, u32 node); | ||
59 | void tipc_nlist_del(struct tipc_nlist *nl, u32 node); | ||
60 | |||
48 | int tipc_bcast_init(struct net *net); | 61 | int tipc_bcast_init(struct net *net); |
49 | void tipc_bcast_stop(struct net *net); | 62 | void tipc_bcast_stop(struct net *net); |
50 | void tipc_bcast_add_peer(struct net *net, struct tipc_link *l, | 63 | void tipc_bcast_add_peer(struct net *net, struct tipc_link *l, |
diff --git a/net/tipc/name_table.c b/net/tipc/name_table.c index 5a86df1e5fc2..9be6592e4a6f 100644 --- a/net/tipc/name_table.c +++ b/net/tipc/name_table.c | |||
@@ -645,6 +645,39 @@ exit: | |||
645 | return res; | 645 | return res; |
646 | } | 646 | } |
647 | 647 | ||
648 | /* tipc_nametbl_lookup_dst_nodes - find broadcast destination nodes | ||
649 | * - Creates list of nodes that overlap the given multicast address | ||
650 | * - Determines if any node local ports overlap | ||
651 | */ | ||
652 | void tipc_nametbl_lookup_dst_nodes(struct net *net, u32 type, u32 lower, | ||
653 | u32 upper, u32 domain, | ||
654 | struct tipc_nlist *nodes) | ||
655 | { | ||
656 | struct sub_seq *sseq, *stop; | ||
657 | struct publication *publ; | ||
658 | struct name_info *info; | ||
659 | struct name_seq *seq; | ||
660 | |||
661 | rcu_read_lock(); | ||
662 | seq = nametbl_find_seq(net, type); | ||
663 | if (!seq) | ||
664 | goto exit; | ||
665 | |||
666 | spin_lock_bh(&seq->lock); | ||
667 | sseq = seq->sseqs + nameseq_locate_subseq(seq, lower); | ||
668 | stop = seq->sseqs + seq->first_free; | ||
669 | for (; sseq->lower <= upper && sseq != stop; sseq++) { | ||
670 | info = sseq->info; | ||
671 | list_for_each_entry(publ, &info->zone_list, zone_list) { | ||
672 | if (tipc_in_scope(domain, publ->node)) | ||
673 | tipc_nlist_add(nodes, publ->node); | ||
674 | } | ||
675 | } | ||
676 | spin_unlock_bh(&seq->lock); | ||
677 | exit: | ||
678 | rcu_read_unlock(); | ||
679 | } | ||
680 | |||
648 | /* | 681 | /* |
649 | * tipc_nametbl_publish - add name publication to network name tables | 682 | * tipc_nametbl_publish - add name publication to network name tables |
650 | */ | 683 | */ |
@@ -1022,11 +1055,6 @@ int tipc_nl_name_table_dump(struct sk_buff *skb, struct netlink_callback *cb) | |||
1022 | return skb->len; | 1055 | return skb->len; |
1023 | } | 1056 | } |
1024 | 1057 | ||
1025 | struct u32_item { | ||
1026 | struct list_head list; | ||
1027 | u32 value; | ||
1028 | }; | ||
1029 | |||
1030 | bool u32_find(struct list_head *l, u32 value) | 1058 | bool u32_find(struct list_head *l, u32 value) |
1031 | { | 1059 | { |
1032 | struct u32_item *item; | 1060 | struct u32_item *item; |
diff --git a/net/tipc/name_table.h b/net/tipc/name_table.h index c89bb3f5c364..6ebdeb1d84a5 100644 --- a/net/tipc/name_table.h +++ b/net/tipc/name_table.h | |||
@@ -39,6 +39,7 @@ | |||
39 | 39 | ||
40 | struct tipc_subscription; | 40 | struct tipc_subscription; |
41 | struct tipc_plist; | 41 | struct tipc_plist; |
42 | struct tipc_nlist; | ||
42 | 43 | ||
43 | /* | 44 | /* |
44 | * TIPC name types reserved for internal TIPC use (both current and planned) | 45 | * TIPC name types reserved for internal TIPC use (both current and planned) |
@@ -100,6 +101,9 @@ int tipc_nl_name_table_dump(struct sk_buff *skb, struct netlink_callback *cb); | |||
100 | u32 tipc_nametbl_translate(struct net *net, u32 type, u32 instance, u32 *node); | 101 | u32 tipc_nametbl_translate(struct net *net, u32 type, u32 instance, u32 *node); |
101 | int tipc_nametbl_mc_translate(struct net *net, u32 type, u32 lower, u32 upper, | 102 | int tipc_nametbl_mc_translate(struct net *net, u32 type, u32 lower, u32 upper, |
102 | u32 limit, struct list_head *dports); | 103 | u32 limit, struct list_head *dports); |
104 | void tipc_nametbl_lookup_dst_nodes(struct net *net, u32 type, u32 lower, | ||
105 | u32 upper, u32 domain, | ||
106 | struct tipc_nlist *nodes); | ||
103 | struct publication *tipc_nametbl_publish(struct net *net, u32 type, u32 lower, | 107 | struct publication *tipc_nametbl_publish(struct net *net, u32 type, u32 lower, |
104 | u32 upper, u32 scope, u32 port_ref, | 108 | u32 upper, u32 scope, u32 port_ref, |
105 | u32 key); | 109 | u32 key); |
@@ -116,6 +120,11 @@ void tipc_nametbl_unsubscribe(struct tipc_subscription *s); | |||
116 | int tipc_nametbl_init(struct net *net); | 120 | int tipc_nametbl_init(struct net *net); |
117 | void tipc_nametbl_stop(struct net *net); | 121 | void tipc_nametbl_stop(struct net *net); |
118 | 122 | ||
123 | struct u32_item { | ||
124 | struct list_head list; | ||
125 | u32 value; | ||
126 | }; | ||
127 | |||
119 | bool u32_push(struct list_head *l, u32 value); | 128 | bool u32_push(struct list_head *l, u32 value); |
120 | u32 u32_pop(struct list_head *l); | 129 | u32 u32_pop(struct list_head *l); |
121 | bool u32_find(struct list_head *l, u32 value); | 130 | bool u32_find(struct list_head *l, u32 value); |