aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/name_table.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/tipc/name_table.c')
-rw-r--r--net/tipc/name_table.c40
1 files changed, 34 insertions, 6 deletions
diff --git a/net/tipc/name_table.c b/net/tipc/name_table.c
index 92a1533af4e0..042e8e3cabc0 100644
--- a/net/tipc/name_table.c
+++ b/net/tipc/name_table.c
@@ -941,20 +941,48 @@ int tipc_nametbl_init(void)
941 return 0; 941 return 0;
942} 942}
943 943
944void tipc_nametbl_stop(void) 944/**
945 * tipc_purge_publications - remove all publications for a given type
946 *
947 * tipc_nametbl_lock must be held when calling this function
948 */
949static void tipc_purge_publications(struct name_seq *seq)
945{ 950{
946 u32 i; 951 struct publication *publ, *safe;
952 struct sub_seq *sseq;
953 struct name_info *info;
947 954
948 if (!table.types) 955 if (!seq->sseqs) {
956 nameseq_delete_empty(seq);
949 return; 957 return;
958 }
959 sseq = seq->sseqs;
960 info = sseq->info;
961 list_for_each_entry_safe(publ, safe, &info->zone_list, zone_list) {
962 tipc_nametbl_remove_publ(publ->type, publ->lower, publ->node,
963 publ->ref, publ->key);
964 }
965}
966
967void tipc_nametbl_stop(void)
968{
969 u32 i;
970 struct name_seq *seq;
971 struct hlist_head *seq_head;
972 struct hlist_node *safe;
950 973
951 /* Verify name table is empty, then release it */ 974 /* Verify name table is empty and purge any lingering
975 * publications, then release the name table
976 */
952 write_lock_bh(&tipc_nametbl_lock); 977 write_lock_bh(&tipc_nametbl_lock);
953 for (i = 0; i < TIPC_NAMETBL_SIZE; i++) { 978 for (i = 0; i < TIPC_NAMETBL_SIZE; i++) {
954 if (hlist_empty(&table.types[i])) 979 if (hlist_empty(&table.types[i]))
955 continue; 980 continue;
956 pr_err("nametbl_stop(): orphaned hash chain detected\n"); 981 seq_head = &table.types[i];
957 break; 982 hlist_for_each_entry_safe(seq, safe, seq_head, ns_list) {
983 tipc_purge_publications(seq);
984 }
985 continue;
958 } 986 }
959 kfree(table.types); 987 kfree(table.types);
960 table.types = NULL; 988 table.types = NULL;