aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc
diff options
context:
space:
mode:
authorJon Maloy <jon.maloy@ericsson.com>2018-03-15 11:48:53 -0400
committerDavid S. Miller <davem@davemloft.net>2018-03-17 17:11:46 -0400
commitba765ec63786583e210b55073a908a9d7ea284fa (patch)
tree95a3dcc4112ae3de0cecd8d4ce65dd9ea6431672 /net/tipc
parent64a52b26d5633d6efc35cdf1e0c627cc4189e55a (diff)
tipc: remove zone_list member in struct publication
As a further consequence of the previous commits, we can also remove the member 'zone_list 'in struct name_info and struct publication. Instead, we now let the member cluster_list take over the role a container of all publications of a given <type,lower, upper>. We also remove the counters for the size of those lists, since they don't serve any purpose. 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/name_table.c101
-rw-r--r--net/tipc/name_table.h5
2 files changed, 30 insertions, 76 deletions
diff --git a/net/tipc/name_table.c b/net/tipc/name_table.c
index 1a3a327018c5..6d7b4c7ff4b7 100644
--- a/net/tipc/name_table.c
+++ b/net/tipc/name_table.c
@@ -50,24 +50,12 @@
50 50
51/** 51/**
52 * struct name_info - name sequence publication info 52 * struct name_info - name sequence publication info
53 * @node_list: circular list of publications made by own node 53 * @node_list: list of publications on own node of this <type,lower,upper>
54 * @cluster_list: circular list of publications made by own cluster 54 * @cluster_list: list of all publications of this <type,lower,upper>
55 * @zone_list: circular list of publications made by own zone
56 * @node_list_size: number of entries in "node_list"
57 * @cluster_list_size: number of entries in "cluster_list"
58 * @zone_list_size: number of entries in "zone_list"
59 *
60 * Note: The zone list always contains at least one entry, since all
61 * publications of the associated name sequence belong to it.
62 * (The cluster and node lists may be empty.)
63 */ 55 */
64struct name_info { 56struct name_info {
65 struct list_head node_list; 57 struct list_head node_list;
66 struct list_head cluster_list; 58 struct list_head cluster_list;
67 struct list_head zone_list;
68 u32 node_list_size;
69 u32 cluster_list_size;
70 u32 zone_list_size;
71}; 59};
72 60
73/** 61/**
@@ -249,7 +237,7 @@ static struct publication *tipc_nameseq_insert_publ(struct net *net,
249 info = sseq->info; 237 info = sseq->info;
250 238
251 /* Check if an identical publication already exists */ 239 /* Check if an identical publication already exists */
252 list_for_each_entry(publ, &info->zone_list, zone_list) { 240 list_for_each_entry(publ, &info->cluster_list, cluster_list) {
253 if ((publ->ref == port) && (publ->key == key) && 241 if ((publ->ref == port) && (publ->key == key) &&
254 (!publ->node || (publ->node == node))) 242 (!publ->node || (publ->node == node)))
255 return NULL; 243 return NULL;
@@ -292,7 +280,6 @@ static struct publication *tipc_nameseq_insert_publ(struct net *net,
292 280
293 INIT_LIST_HEAD(&info->node_list); 281 INIT_LIST_HEAD(&info->node_list);
294 INIT_LIST_HEAD(&info->cluster_list); 282 INIT_LIST_HEAD(&info->cluster_list);
295 INIT_LIST_HEAD(&info->zone_list);
296 283
297 /* Insert new sub-sequence */ 284 /* Insert new sub-sequence */
298 sseq = &nseq->sseqs[inspos]; 285 sseq = &nseq->sseqs[inspos];
@@ -311,18 +298,10 @@ static struct publication *tipc_nameseq_insert_publ(struct net *net,
311 if (!publ) 298 if (!publ)
312 return NULL; 299 return NULL;
313 300
314 list_add(&publ->zone_list, &info->zone_list); 301 list_add(&publ->cluster_list, &info->cluster_list);
315 info->zone_list_size++;
316
317 if (in_own_cluster(net, node)) {
318 list_add(&publ->cluster_list, &info->cluster_list);
319 info->cluster_list_size++;
320 }
321 302
322 if (in_own_node(net, node)) { 303 if (in_own_node(net, node))
323 list_add(&publ->node_list, &info->node_list); 304 list_add(&publ->node_list, &info->node_list);
324 info->node_list_size++;
325 }
326 305
327 /* Any subscriptions waiting for notification? */ 306 /* Any subscriptions waiting for notification? */
328 list_for_each_entry_safe(s, st, &nseq->subscriptions, nameseq_list) { 307 list_for_each_entry_safe(s, st, &nseq->subscriptions, nameseq_list) {
@@ -363,7 +342,7 @@ static struct publication *tipc_nameseq_remove_publ(struct net *net,
363 info = sseq->info; 342 info = sseq->info;
364 343
365 /* Locate publication, if it exists */ 344 /* Locate publication, if it exists */
366 list_for_each_entry(publ, &info->zone_list, zone_list) { 345 list_for_each_entry(publ, &info->cluster_list, cluster_list) {
367 if ((publ->key == key) && (publ->ref == ref) && 346 if ((publ->key == key) && (publ->ref == ref) &&
368 (!publ->node || (publ->node == node))) 347 (!publ->node || (publ->node == node)))
369 goto found; 348 goto found;
@@ -371,24 +350,12 @@ static struct publication *tipc_nameseq_remove_publ(struct net *net,
371 return NULL; 350 return NULL;
372 351
373found: 352found:
374 /* Remove publication from zone scope list */ 353 list_del(&publ->cluster_list);
375 list_del(&publ->zone_list); 354 if (in_own_node(net, node))
376 info->zone_list_size--;
377
378 /* Remove publication from cluster scope list, if present */
379 if (in_own_cluster(net, node)) {
380 list_del(&publ->cluster_list);
381 info->cluster_list_size--;
382 }
383
384 /* Remove publication from node scope list, if present */
385 if (in_own_node(net, node)) {
386 list_del(&publ->node_list); 355 list_del(&publ->node_list);
387 info->node_list_size--;
388 }
389 356
390 /* Contract subseq list if no more publications for that subseq */ 357 /* Contract subseq list if no more publications for that subseq */
391 if (list_empty(&info->zone_list)) { 358 if (list_empty(&info->cluster_list)) {
392 kfree(info); 359 kfree(info);
393 free = &nseq->sseqs[nseq->first_free--]; 360 free = &nseq->sseqs[nseq->first_free--];
394 memmove(sseq, sseq + 1, (free - (sseq + 1)) * sizeof(*sseq)); 361 memmove(sseq, sseq + 1, (free - (sseq + 1)) * sizeof(*sseq));
@@ -435,7 +402,8 @@ static void tipc_nameseq_subscribe(struct name_seq *nseq,
435 struct name_info *info = sseq->info; 402 struct name_info *info = sseq->info;
436 int must_report = 1; 403 int must_report = 1;
437 404
438 list_for_each_entry(crs, &info->zone_list, zone_list) { 405 list_for_each_entry(crs, &info->cluster_list,
406 cluster_list) {
439 tipc_sub_report_overlap(sub, sseq->lower, 407 tipc_sub_report_overlap(sub, sseq->lower,
440 sseq->upper, 408 sseq->upper,
441 TIPC_PUBLISHED, 409 TIPC_PUBLISHED,
@@ -559,18 +527,12 @@ u32 tipc_nametbl_translate(struct net *net, u32 type, u32 instance,
559 node_list); 527 node_list);
560 list_move_tail(&publ->node_list, 528 list_move_tail(&publ->node_list,
561 &info->node_list); 529 &info->node_list);
562 } else if (!list_empty(&info->cluster_list)) { 530 } else {
563 publ = list_first_entry(&info->cluster_list, 531 publ = list_first_entry(&info->cluster_list,
564 struct publication, 532 struct publication,
565 cluster_list); 533 cluster_list);
566 list_move_tail(&publ->cluster_list, 534 list_move_tail(&publ->cluster_list,
567 &info->cluster_list); 535 &info->cluster_list);
568 } else {
569 publ = list_first_entry(&info->zone_list,
570 struct publication,
571 zone_list);
572 list_move_tail(&publ->zone_list,
573 &info->zone_list);
574 } 536 }
575 } 537 }
576 538
@@ -581,16 +543,10 @@ u32 tipc_nametbl_translate(struct net *net, u32 type, u32 instance,
581 publ = list_first_entry(&info->node_list, struct publication, 543 publ = list_first_entry(&info->node_list, struct publication,
582 node_list); 544 node_list);
583 list_move_tail(&publ->node_list, &info->node_list); 545 list_move_tail(&publ->node_list, &info->node_list);
584 } else if (in_own_cluster_exact(net, *destnode)) { 546 } else {
585 if (list_empty(&info->cluster_list))
586 goto no_match;
587 publ = list_first_entry(&info->cluster_list, struct publication, 547 publ = list_first_entry(&info->cluster_list, struct publication,
588 cluster_list); 548 cluster_list);
589 list_move_tail(&publ->cluster_list, &info->cluster_list); 549 list_move_tail(&publ->cluster_list, &info->cluster_list);
590 } else {
591 publ = list_first_entry(&info->zone_list, struct publication,
592 zone_list);
593 list_move_tail(&publ->zone_list, &info->zone_list);
594 } 550 }
595 551
596 ref = publ->ref; 552 ref = publ->ref;
@@ -622,7 +578,7 @@ bool tipc_nametbl_lookup(struct net *net, u32 type, u32 instance, u32 scope,
622 sseq = nameseq_find_subseq(seq, instance); 578 sseq = nameseq_find_subseq(seq, instance);
623 if (likely(sseq)) { 579 if (likely(sseq)) {
624 info = sseq->info; 580 info = sseq->info;
625 list_for_each_entry(publ, &info->zone_list, zone_list) { 581 list_for_each_entry(publ, &info->cluster_list, cluster_list) {
626 if (publ->scope != scope) 582 if (publ->scope != scope)
627 continue; 583 continue;
628 if (publ->ref == exclude && publ->node == self) 584 if (publ->ref == exclude && publ->node == self)
@@ -631,7 +587,8 @@ bool tipc_nametbl_lookup(struct net *net, u32 type, u32 instance, u32 scope,
631 (*dstcnt)++; 587 (*dstcnt)++;
632 if (all) 588 if (all)
633 continue; 589 continue;
634 list_move_tail(&publ->zone_list, &info->zone_list); 590 list_move_tail(&publ->cluster_list,
591 &info->cluster_list);
635 break; 592 break;
636 } 593 }
637 } 594 }
@@ -641,15 +598,14 @@ exit:
641 return !list_empty(dsts); 598 return !list_empty(dsts);
642} 599}
643 600
644int tipc_nametbl_mc_lookup(struct net *net, u32 type, u32 lower, u32 upper, 601void tipc_nametbl_mc_lookup(struct net *net, u32 type, u32 lower, u32 upper,
645 u32 scope, bool exact, struct list_head *dports) 602 u32 scope, bool exact, struct list_head *dports)
646{ 603{
647 struct sub_seq *sseq_stop; 604 struct sub_seq *sseq_stop;
648 struct name_info *info; 605 struct name_info *info;
649 struct publication *p; 606 struct publication *p;
650 struct name_seq *seq; 607 struct name_seq *seq;
651 struct sub_seq *sseq; 608 struct sub_seq *sseq;
652 int res = 0;
653 609
654 rcu_read_lock(); 610 rcu_read_lock();
655 seq = nametbl_find_seq(net, type); 611 seq = nametbl_find_seq(net, type);
@@ -667,14 +623,10 @@ int tipc_nametbl_mc_lookup(struct net *net, u32 type, u32 lower, u32 upper,
667 if (p->scope == scope || (!exact && p->scope < scope)) 623 if (p->scope == scope || (!exact && p->scope < scope))
668 tipc_dest_push(dports, 0, p->ref); 624 tipc_dest_push(dports, 0, p->ref);
669 } 625 }
670
671 if (info->cluster_list_size != info->node_list_size)
672 res = 1;
673 } 626 }
674 spin_unlock_bh(&seq->lock); 627 spin_unlock_bh(&seq->lock);
675exit: 628exit:
676 rcu_read_unlock(); 629 rcu_read_unlock();
677 return res;
678} 630}
679 631
680/* tipc_nametbl_lookup_dst_nodes - find broadcast destination nodes 632/* tipc_nametbl_lookup_dst_nodes - find broadcast destination nodes
@@ -699,7 +651,7 @@ void tipc_nametbl_lookup_dst_nodes(struct net *net, u32 type, u32 lower,
699 stop = seq->sseqs + seq->first_free; 651 stop = seq->sseqs + seq->first_free;
700 for (; sseq != stop && sseq->lower <= upper; sseq++) { 652 for (; sseq != stop && sseq->lower <= upper; sseq++) {
701 info = sseq->info; 653 info = sseq->info;
702 list_for_each_entry(publ, &info->zone_list, zone_list) { 654 list_for_each_entry(publ, &info->cluster_list, cluster_list) {
703 tipc_nlist_add(nodes, publ->node); 655 tipc_nlist_add(nodes, publ->node);
704 } 656 }
705 } 657 }
@@ -728,7 +680,7 @@ void tipc_nametbl_build_group(struct net *net, struct tipc_group *grp,
728 stop = seq->sseqs + seq->first_free; 680 stop = seq->sseqs + seq->first_free;
729 for (; sseq != stop; sseq++) { 681 for (; sseq != stop; sseq++) {
730 info = sseq->info; 682 info = sseq->info;
731 list_for_each_entry(p, &info->zone_list, zone_list) { 683 list_for_each_entry(p, &info->cluster_list, cluster_list) {
732 if (p->scope != scope) 684 if (p->scope != scope)
733 continue; 685 continue;
734 tipc_group_add_member(grp, p->node, p->ref, p->lower); 686 tipc_group_add_member(grp, p->node, p->ref, p->lower);
@@ -899,7 +851,8 @@ static void tipc_purge_publications(struct net *net, struct name_seq *seq)
899 spin_lock_bh(&seq->lock); 851 spin_lock_bh(&seq->lock);
900 sseq = seq->sseqs; 852 sseq = seq->sseqs;
901 info = sseq->info; 853 info = sseq->info;
902 list_for_each_entry_safe(publ, safe, &info->zone_list, zone_list) { 854 list_for_each_entry_safe(publ, safe, &info->cluster_list,
855 cluster_list) {
903 tipc_nameseq_remove_publ(net, seq, publ->lower, publ->node, 856 tipc_nameseq_remove_publ(net, seq, publ->lower, publ->node,
904 publ->ref, publ->key); 857 publ->ref, publ->key);
905 kfree_rcu(publ, rcu); 858 kfree_rcu(publ, rcu);
@@ -948,17 +901,19 @@ static int __tipc_nl_add_nametable_publ(struct tipc_nl_msg *msg,
948 struct publication *p; 901 struct publication *p;
949 902
950 if (*last_publ) { 903 if (*last_publ) {
951 list_for_each_entry(p, &sseq->info->zone_list, zone_list) 904 list_for_each_entry(p, &sseq->info->cluster_list,
905 cluster_list)
952 if (p->key == *last_publ) 906 if (p->key == *last_publ)
953 break; 907 break;
954 if (p->key != *last_publ) 908 if (p->key != *last_publ)
955 return -EPIPE; 909 return -EPIPE;
956 } else { 910 } else {
957 p = list_first_entry(&sseq->info->zone_list, struct publication, 911 p = list_first_entry(&sseq->info->cluster_list,
958 zone_list); 912 struct publication,
913 cluster_list);
959 } 914 }
960 915
961 list_for_each_entry_from(p, &sseq->info->zone_list, zone_list) { 916 list_for_each_entry_from(p, &sseq->info->cluster_list, cluster_list) {
962 *last_publ = p->key; 917 *last_publ = p->key;
963 918
964 hdr = genlmsg_put(msg->skb, msg->portid, msg->seq, 919 hdr = genlmsg_put(msg->skb, msg->portid, msg->seq,
diff --git a/net/tipc/name_table.h b/net/tipc/name_table.h
index 47f72cddfb39..a9063e25ee74 100644
--- a/net/tipc/name_table.h
+++ b/net/tipc/name_table.h
@@ -81,7 +81,6 @@ struct publication {
81 struct list_head pport_list; 81 struct list_head pport_list;
82 struct list_head node_list; 82 struct list_head node_list;
83 struct list_head cluster_list; 83 struct list_head cluster_list;
84 struct list_head zone_list;
85 struct rcu_head rcu; 84 struct rcu_head rcu;
86}; 85};
87 86
@@ -102,8 +101,8 @@ struct name_table {
102int tipc_nl_name_table_dump(struct sk_buff *skb, struct netlink_callback *cb); 101int tipc_nl_name_table_dump(struct sk_buff *skb, struct netlink_callback *cb);
103 102
104u32 tipc_nametbl_translate(struct net *net, u32 type, u32 instance, u32 *node); 103u32 tipc_nametbl_translate(struct net *net, u32 type, u32 instance, u32 *node);
105int tipc_nametbl_mc_lookup(struct net *net, u32 type, u32 lower, u32 upper, 104void tipc_nametbl_mc_lookup(struct net *net, u32 type, u32 lower, u32 upper,
106 u32 scope, bool exact, struct list_head *dports); 105 u32 scope, bool exact, struct list_head *dports);
107void tipc_nametbl_build_group(struct net *net, struct tipc_group *grp, 106void tipc_nametbl_build_group(struct net *net, struct tipc_group *grp,
108 u32 type, u32 domain); 107 u32 type, u32 domain);
109void tipc_nametbl_lookup_dst_nodes(struct net *net, u32 type, u32 lower, 108void tipc_nametbl_lookup_dst_nodes(struct net *net, u32 type, u32 lower,