[TIPC]: Prevent name table corruption if no room for new publication
[pandora-kernel.git] / net / tipc / name_table.c
index 972c83e..0511436 100644 (file)
@@ -46,7 +46,7 @@
 #include "cluster.h"
 #include "bcast.h"
 
-int tipc_nametbl_size = 1024;          /* must be a power of 2 */
+static int tipc_nametbl_size = 1024;           /* must be a power of 2 */
 
 /**
  * struct sub_seq - container for all published instances of a name sequence
@@ -99,12 +99,12 @@ struct name_table {
        u32 local_publ_count;
 };
 
-struct name_table table = { NULL } ;
+static struct name_table table = { NULL } ;
 static atomic_t rsv_publ_ok = ATOMIC_INIT(0);
-rwlock_t nametbl_lock = RW_LOCK_UNLOCKED;
+rwlock_t tipc_nametbl_lock = RW_LOCK_UNLOCKED;
 
 
-static inline int hash(int x)
+static int hash(int x)
 {
        return(x & (tipc_nametbl_size - 1));
 }
@@ -121,7 +121,7 @@ static struct publication *publ_create(u32 type, u32 lower, u32 upper,
                (struct publication *)kmalloc(sizeof(*publ), GFP_ATOMIC);
        if (publ == NULL) {
                warn("Memory squeeze; failed to create publication\n");
-               return 0;
+               return NULL;
        }
 
        memset(publ, 0, sizeof(*publ));
@@ -139,10 +139,10 @@ static struct publication *publ_create(u32 type, u32 lower, u32 upper,
 }
 
 /**
- * subseq_alloc - allocate a specified number of sub-sequence structures
+ * tipc_subseq_alloc - allocate a specified number of sub-sequence structures
  */
 
-struct sub_seq *subseq_alloc(u32 cnt)
+static struct sub_seq *tipc_subseq_alloc(u32 cnt)
 {
        u32 sz = cnt * sizeof(struct sub_seq);
        struct sub_seq *sseq = (struct sub_seq *)kmalloc(sz, GFP_ATOMIC);
@@ -153,29 +153,29 @@ struct sub_seq *subseq_alloc(u32 cnt)
 }
 
 /**
- * nameseq_create - create a name sequence structure for the specified 'type'
+ * tipc_nameseq_create - create a name sequence structure for the specified 'type'
  * 
  * Allocates a single sub-sequence structure and sets it to all 0's.
  */
 
-struct name_seq *nameseq_create(u32 type, struct hlist_head *seq_head)
+static struct name_seq *tipc_nameseq_create(u32 type, struct hlist_head *seq_head)
 {
        struct name_seq *nseq = 
                (struct name_seq *)kmalloc(sizeof(*nseq), GFP_ATOMIC);
-       struct sub_seq *sseq = subseq_alloc(1);
+       struct sub_seq *sseq = tipc_subseq_alloc(1);
 
        if (!nseq || !sseq) {
                warn("Memory squeeze; failed to create name sequence\n");
                kfree(nseq);
                kfree(sseq);
-               return 0;
+               return NULL;
        }
 
        memset(nseq, 0, sizeof(*nseq));
        nseq->lock = SPIN_LOCK_UNLOCKED;
        nseq->type = type;
        nseq->sseqs = sseq;
-       dbg("nameseq_create() nseq = %x type %u, ssseqs %x, ff: %u\n",
+       dbg("tipc_nameseq_create() nseq = %x type %u, ssseqs %x, ff: %u\n",
            nseq, type, nseq->sseqs, nseq->first_free);
        nseq->alloc = 1;
        INIT_HLIST_NODE(&nseq->ns_list);
@@ -190,8 +190,8 @@ struct name_seq *nameseq_create(u32 type, struct hlist_head *seq_head)
  * Very time-critical, so binary searches through sub-sequence array.
  */
 
-static inline struct sub_seq *nameseq_find_subseq(struct name_seq *nseq, 
-                                                 u32 instance)
+static struct sub_seq *nameseq_find_subseq(struct name_seq *nseq,
+                                          u32 instance)
 {
        struct sub_seq *sseqs = nseq->sseqs;
        int low = 0;
@@ -207,7 +207,7 @@ static inline struct sub_seq *nameseq_find_subseq(struct name_seq *nseq,
                else
                        return &sseqs[mid];
        }
-       return 0;
+       return NULL;
 }
 
 /**
@@ -240,12 +240,12 @@ static u32 nameseq_locate_subseq(struct name_seq *nseq, u32 instance)
 }
 
 /**
- * nameseq_insert_publ - 
+ * tipc_nameseq_insert_publ - 
  */
 
-struct publication *nameseq_insert_publ(struct name_seq *nseq,
-                                       u32 type, u32 lower, u32 upper,
-                                       u32 scope, u32 node, u32 port, u32 key)
+static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq,
+                                                   u32 type, u32 lower, u32 upper,
+                                                   u32 scope, u32 node, u32 port, u32 key)
 {
        struct subscription *s;
        struct subscription *st;
@@ -263,7 +263,7 @@ struct publication *nameseq_insert_publ(struct name_seq *nseq,
 
                if ((sseq->lower != lower) || (sseq->upper != upper)) {
                        warn("Overlapping publ <%u,%u,%u>\n", type, lower, upper);
-                       return 0;
+                       return NULL;
                }
        } else {
                u32 inspos;
@@ -278,24 +278,24 @@ struct publication *nameseq_insert_publ(struct name_seq *nseq,
                if ((inspos < nseq->first_free) &&
                    (upper >= nseq->sseqs[inspos].lower)) {
                        warn("Overlapping publ <%u,%u,%u>\n", type, lower, upper);
-                       return 0;
+                       return NULL;
                }
 
                /* Ensure there is space for new sub-sequence */
 
                if (nseq->first_free == nseq->alloc) {
-                       struct sub_seq *sseqs = nseq->sseqs;
-                       nseq->sseqs = subseq_alloc(nseq->alloc * 2);
-                       if (nseq->sseqs != NULL) {
-                               memcpy(nseq->sseqs, sseqs,
-                                      nseq->alloc * sizeof (struct sub_seq));
-                               kfree(sseqs);
-                               dbg("Allocated %u sseqs\n", nseq->alloc);
-                               nseq->alloc *= 2;
-                       } else {
+                       struct sub_seq *sseqs = tipc_subseq_alloc(nseq->alloc * 2);
+
+                       if (!sseqs) {
                                warn("Memory squeeze; failed to create sub-sequence\n");
-                               return 0;
+                               return NULL;
                        }
+                       dbg("Allocated %u more sseqs\n", nseq->alloc);
+                       memcpy(sseqs, nseq->sseqs,
+                              nseq->alloc * sizeof(struct sub_seq));
+                       kfree(nseq->sseqs);
+                       nseq->sseqs = sseqs;
+                       nseq->alloc *= 2;
                }
                dbg("Have %u sseqs for type %u\n", nseq->alloc, type);
 
@@ -319,7 +319,7 @@ struct publication *nameseq_insert_publ(struct name_seq *nseq,
 
        publ = publ_create(type, lower, upper, scope, node, port, key);
        if (!publ)
-               return 0;
+               return NULL;
        dbg("inserting publ %x, node=%x publ->node=%x, subscr->node=%x\n",
            publ, node, publ->node, publ->subscr.node);
 
@@ -354,23 +354,23 @@ struct publication *nameseq_insert_publ(struct name_seq *nseq,
         */
        list_for_each_entry_safe(s, st, &nseq->subscriptions, nameseq_list) {
                dbg("calling report_overlap()\n");
-               subscr_report_overlap(s,
-                                     publ->lower,
-                                     publ->upper,
-                                     TIPC_PUBLISHED,
-                                     publ->ref, 
-                                     publ->node,
-                                     created_subseq);
+               tipc_subscr_report_overlap(s,
+                                          publ->lower,
+                                          publ->upper,
+                                          TIPC_PUBLISHED,
+                                          publ->ref, 
+                                          publ->node,
+                                          created_subseq);
        }
        return publ;
 }
 
 /**
- * nameseq_remove_publ -
+ * tipc_nameseq_remove_publ -
  */
 
-struct publication *nameseq_remove_publ(struct name_seq *nseq, u32 inst,
-                                       u32 node, u32 ref, u32 key)
+static struct publication *tipc_nameseq_remove_publ(struct name_seq *nseq, u32 inst,
+                                                   u32 node, u32 ref, u32 key)
 {
        struct publication *publ;
        struct publication *prev;
@@ -394,7 +394,7 @@ struct publication *nameseq_remove_publ(struct name_seq *nseq, u32 inst,
                            i, &nseq->sseqs[i], nseq->sseqs[i].lower,
                            nseq->sseqs[i].upper);
                }
-               return 0;
+               return NULL;
        }
        dbg("nameseq_remove: seq: %x, sseq %x, <%u,%u> key %u\n",
            nseq, sseq, nseq->type, inst, key);
@@ -413,7 +413,7 @@ struct publication *nameseq_remove_publ(struct name_seq *nseq, u32 inst,
                prev->zone_list_next = publ->zone_list_next;
                sseq->zone_list = publ->zone_list_next;
        } else {
-               sseq->zone_list = 0;
+               sseq->zone_list = NULL;
        }
 
        if (in_own_cluster(node)) {
@@ -431,7 +431,7 @@ struct publication *nameseq_remove_publ(struct name_seq *nseq, u32 inst,
                        prev->cluster_list_next = publ->cluster_list_next;
                        sseq->cluster_list = publ->cluster_list_next;
                } else {
-                       sseq->cluster_list = 0;
+                       sseq->cluster_list = NULL;
                }
        }
 
@@ -450,7 +450,7 @@ struct publication *nameseq_remove_publ(struct name_seq *nseq, u32 inst,
                        prev->node_list_next = publ->node_list_next;
                        sseq->node_list = publ->node_list_next;
                } else {
-                       sseq->node_list = 0;
+                       sseq->node_list = NULL;
                }
        }
        assert(!publ->node || (publ->node == node));
@@ -470,24 +470,24 @@ struct publication *nameseq_remove_publ(struct name_seq *nseq, u32 inst,
         * Any subscriptions waiting ? 
         */
        list_for_each_entry_safe(s, st, &nseq->subscriptions, nameseq_list) {
-               subscr_report_overlap(s,
-                                     publ->lower,
-                                     publ->upper,
-                                     TIPC_WITHDRAWN, 
-                                     publ->ref, 
-                                     publ->node,
-                                     removed_subseq);
+               tipc_subscr_report_overlap(s,
+                                          publ->lower,
+                                          publ->upper,
+                                          TIPC_WITHDRAWN, 
+                                          publ->ref, 
+                                          publ->node,
+                                          removed_subseq);
        }
        return publ;
 }
 
 /**
- * nameseq_subscribe: attach a subscription, and issue
+ * tipc_nameseq_subscribe: attach a subscription, and issue
  * the prescribed number of events if there is any sub-
  * sequence overlapping with the requested sequence
  */
 
-void nameseq_subscribe(struct name_seq *nseq, struct subscription *s)
+void tipc_nameseq_subscribe(struct name_seq *nseq, struct subscription *s)
 {
        struct sub_seq *sseq = nseq->sseqs;
 
@@ -498,18 +498,18 @@ void nameseq_subscribe(struct name_seq *nseq, struct subscription *s)
 
        while (sseq != &nseq->sseqs[nseq->first_free]) {
                struct publication *zl = sseq->zone_list;
-               if (zl && subscr_overlap(s,sseq->lower,sseq->upper)) {
+               if (zl && tipc_subscr_overlap(s,sseq->lower,sseq->upper)) {
                        struct publication *crs = zl;
                        int must_report = 1;
 
                        do {
-                               subscr_report_overlap(s, 
-                                                      sseq->lower, 
-                                                      sseq->upper,
-                                                      TIPC_PUBLISHED,
-                                                      crs->ref,
-                                                      crs->node,
-                                                      must_report);
+                               tipc_subscr_report_overlap(s, 
+                                                          sseq->lower, 
+                                                          sseq->upper,
+                                                          TIPC_PUBLISHED,
+                                                          crs->ref,
+                                                          crs->node,
+                                                          must_report);
                                must_report = 0;
                                crs = crs->zone_list_next;
                        } while (crs != zl);
@@ -535,11 +535,11 @@ static struct name_seq *nametbl_find_seq(u32 type)
                }
        }
 
-       return 0;
+       return NULL;
 };
 
-struct publication *nametbl_insert_publ(u32 type, u32 lower, u32 upper,
-                   u32 scope, u32 node, u32 port, u32 key)
+struct publication *tipc_nametbl_insert_publ(u32 type, u32 lower, u32 upper,
+                                            u32 scope, u32 node, u32 port, u32 key)
 {
        struct name_seq *seq = nametbl_find_seq(type);
 
@@ -547,33 +547,33 @@ struct publication *nametbl_insert_publ(u32 type, u32 lower, u32 upper,
        if (lower > upper) {
                warn("Failed to publish illegal <%u,%u,%u>\n",
                     type, lower, upper);
-               return 0;
+               return NULL;
        }
 
        dbg("Publishing <%u,%u,%u> from %x\n", type, lower, upper, node);
        if (!seq) {
-               seq = nameseq_create(type, &table.types[hash(type)]);
-               dbg("nametbl_insert_publ: created %x\n", seq);
+               seq = tipc_nameseq_create(type, &table.types[hash(type)]);
+               dbg("tipc_nametbl_insert_publ: created %x\n", seq);
        }
        if (!seq)
-               return 0;
+               return NULL;
 
        assert(seq->type == type);
-       return nameseq_insert_publ(seq, type, lower, upper,
-                                  scope, node, port, key);
+       return tipc_nameseq_insert_publ(seq, type, lower, upper,
+                                       scope, node, port, key);
 }
 
-struct publication *nametbl_remove_publ(u32 type, u32 lower, 
-                                       u32 node, u32 ref, u32 key)
+struct publication *tipc_nametbl_remove_publ(u32 type, u32 lower, 
+                                            u32 node, u32 ref, u32 key)
 {
        struct publication *publ;
        struct name_seq *seq = nametbl_find_seq(type);
 
        if (!seq)
-               return 0;
+               return NULL;
 
        dbg("Withdrawing <%u,%u> from %x\n", type, lower, node);
-       publ = nameseq_remove_publ(seq, lower, node, ref, key);
+       publ = tipc_nameseq_remove_publ(seq, lower, node, ref, key);
 
        if (!seq->first_free && list_empty(&seq->subscriptions)) {
                hlist_del_init(&seq->ns_list);
@@ -584,24 +584,24 @@ struct publication *nametbl_remove_publ(u32 type, u32 lower,
 }
 
 /*
- * nametbl_translate(): Translate tipc_name -> tipc_portid.
+ * tipc_nametbl_translate(): Translate tipc_name -> tipc_portid.
  *                      Very time-critical.
  *
  * Note: on entry 'destnode' is the search domain used during translation;
  *       on exit it passes back the node address of the matching port (if any)
  */
 
-u32 nametbl_translate(u32 type, u32 instance, u32 *destnode)
+u32 tipc_nametbl_translate(u32 type, u32 instance, u32 *destnode)
 {
        struct sub_seq *sseq;
-       struct publication *publ = 0;
+       struct publication *publ = NULL;
        struct name_seq *seq;
        u32 ref;
 
        if (!in_scope(*destnode, tipc_own_addr))
                return 0;
 
-       read_lock_bh(&nametbl_lock);
+       read_lock_bh(&tipc_nametbl_lock);
        seq = nametbl_find_seq(type);
        if (unlikely(!seq))
                goto not_found;
@@ -619,7 +619,7 @@ found:
                        ref = publ->ref;
                        *destnode = publ->node;
                        spin_unlock_bh(&seq->lock);
-                       read_unlock_bh(&nametbl_lock);
+                       read_unlock_bh(&tipc_nametbl_lock);
                        return ref;
                }
                publ = sseq->cluster_list;
@@ -657,12 +657,12 @@ found:
        spin_unlock_bh(&seq->lock);
 not_found:
        *destnode = 0;
-       read_unlock_bh(&nametbl_lock);
+       read_unlock_bh(&tipc_nametbl_lock);
        return 0;
 }
 
 /**
- * nametbl_mc_translate - find multicast destinations
+ * tipc_nametbl_mc_translate - find multicast destinations
  * 
  * Creates list of all local ports that overlap the given multicast address;
  * also determines if any off-node ports overlap.
@@ -674,15 +674,15 @@ not_found:
  * Returns non-zero if any off-node ports overlap
  */
 
-int nametbl_mc_translate(u32 type, u32 lower, u32 upper, u32 limit,
-                        struct port_list *dports)
+int tipc_nametbl_mc_translate(u32 type, u32 lower, u32 upper, u32 limit,
+                             struct port_list *dports)
 {
        struct name_seq *seq;
        struct sub_seq *sseq;
        struct sub_seq *sseq_stop;
        int res = 0;
 
-       read_lock_bh(&nametbl_lock);
+       read_lock_bh(&tipc_nametbl_lock);
        seq = nametbl_find_seq(type);
        if (!seq)
                goto exit;
@@ -700,7 +700,7 @@ int nametbl_mc_translate(u32 type, u32 lower, u32 upper, u32 limit,
                if (publ && (publ->scope <= limit))
                        do {
                                if (publ->node == tipc_own_addr)
-                                       port_list_add(dports, publ->ref);
+                                       tipc_port_list_add(dports, publ->ref);
                                else
                                        res = 1;
                                publ = publ->cluster_list_next;
@@ -709,15 +709,15 @@ int nametbl_mc_translate(u32 type, u32 lower, u32 upper, u32 limit,
 
        spin_unlock_bh(&seq->lock);
 exit:
-       read_unlock_bh(&nametbl_lock);
+       read_unlock_bh(&tipc_nametbl_lock);
        return res;
 }
 
 /**
- * nametbl_publish_rsv - publish port name using a reserved name type
+ * tipc_nametbl_publish_rsv - publish port name using a reserved name type
  */
 
-int nametbl_publish_rsv(u32 ref, unsigned int scope, 
+int tipc_nametbl_publish_rsv(u32 ref, unsigned int scope, 
                        struct tipc_name_seq const *seq)
 {
        int res;
@@ -729,10 +729,10 @@ int nametbl_publish_rsv(u32 ref, unsigned int scope,
 }
 
 /**
- * nametbl_publish - add name publication to network name tables
+ * tipc_nametbl_publish - add name publication to network name tables
  */
 
-struct publication *nametbl_publish(u32 type, u32 lower, u32 upper, 
+struct publication *tipc_nametbl_publish(u32 type, u32 lower, u32 upper, 
                                    u32 scope, u32 port_ref, u32 key)
 {
        struct publication *publ;
@@ -740,85 +740,85 @@ struct publication *nametbl_publish(u32 type, u32 lower, u32 upper,
        if (table.local_publ_count >= tipc_max_publications) {
                warn("Failed publish: max %u local publication\n", 
                     tipc_max_publications);
-               return 0;
+               return NULL;
        }
        if ((type < TIPC_RESERVED_TYPES) && !atomic_read(&rsv_publ_ok)) {
                warn("Failed to publish reserved name <%u,%u,%u>\n",
                     type, lower, upper);
-               return 0;
+               return NULL;
        }
 
-       write_lock_bh(&nametbl_lock);
+       write_lock_bh(&tipc_nametbl_lock);
        table.local_publ_count++;
-       publ = nametbl_insert_publ(type, lower, upper, scope,
+       publ = tipc_nametbl_insert_publ(type, lower, upper, scope,
                                   tipc_own_addr, port_ref, key);
        if (publ && (scope != TIPC_NODE_SCOPE)) {
-               named_publish(publ);
+               tipc_named_publish(publ);
        }
-       write_unlock_bh(&nametbl_lock);
+       write_unlock_bh(&tipc_nametbl_lock);
        return publ;
 }
 
 /**
- * nametbl_withdraw - withdraw name publication from network name tables
+ * tipc_nametbl_withdraw - withdraw name publication from network name tables
  */
 
-int nametbl_withdraw(u32 type, u32 lower, u32 ref, u32 key)
+int tipc_nametbl_withdraw(u32 type, u32 lower, u32 ref, u32 key)
 {
        struct publication *publ;
 
-       dbg("nametbl_withdraw:<%d,%d,%d>\n", type, lower, key);
-       write_lock_bh(&nametbl_lock);
-       publ = nametbl_remove_publ(type, lower, tipc_own_addr, ref, key);
+       dbg("tipc_nametbl_withdraw:<%d,%d,%d>\n", type, lower, key);
+       write_lock_bh(&tipc_nametbl_lock);
+       publ = tipc_nametbl_remove_publ(type, lower, tipc_own_addr, ref, key);
        if (publ) {
                table.local_publ_count--;
                if (publ->scope != TIPC_NODE_SCOPE)
-                       named_withdraw(publ);
-               write_unlock_bh(&nametbl_lock);
+                       tipc_named_withdraw(publ);
+               write_unlock_bh(&tipc_nametbl_lock);
                list_del_init(&publ->pport_list);
                kfree(publ);
                return 1;
        }
-       write_unlock_bh(&nametbl_lock);
+       write_unlock_bh(&tipc_nametbl_lock);
        return 0;
 }
 
 /**
- * nametbl_subscribe - add a subscription object to the name table
+ * tipc_nametbl_subscribe - add a subscription object to the name table
  */
 
 void
-nametbl_subscribe(struct subscription *s)
+tipc_nametbl_subscribe(struct subscription *s)
 {
        u32 type = s->seq.type;
        struct name_seq *seq;
 
-        write_lock_bh(&nametbl_lock);
+        write_lock_bh(&tipc_nametbl_lock);
        seq = nametbl_find_seq(type);
        if (!seq) {
-               seq = nameseq_create(type, &table.types[hash(type)]);
+               seq = tipc_nameseq_create(type, &table.types[hash(type)]);
        }
         if (seq){
                 spin_lock_bh(&seq->lock);
-                dbg("nametbl_subscribe:found %x for <%u,%u,%u>\n",
+                dbg("tipc_nametbl_subscribe:found %x for <%u,%u,%u>\n",
                     seq, type, s->seq.lower, s->seq.upper);
                 assert(seq->type == type);
-                nameseq_subscribe(seq, s);
+                tipc_nameseq_subscribe(seq, s);
                 spin_unlock_bh(&seq->lock);
         }
-        write_unlock_bh(&nametbl_lock);
+        write_unlock_bh(&tipc_nametbl_lock);
 }
 
 /**
- * nametbl_unsubscribe - remove a subscription object from name table
+ * tipc_nametbl_unsubscribe - remove a subscription object from name table
  */
 
 void
-nametbl_unsubscribe(struct subscription *s)
+tipc_nametbl_unsubscribe(struct subscription *s)
 {
        struct name_seq *seq;
 
-        write_lock_bh(&nametbl_lock);
+        write_lock_bh(&tipc_nametbl_lock);
         seq = nametbl_find_seq(s->seq.type);
        if (seq != NULL){
                 spin_lock_bh(&seq->lock);
@@ -830,7 +830,7 @@ nametbl_unsubscribe(struct subscription *s)
                         kfree(seq);
                 }
         }
-        write_unlock_bh(&nametbl_lock);
+        write_unlock_bh(&tipc_nametbl_lock);
 }
 
 
@@ -983,17 +983,19 @@ static void nametbl_list(struct print_buf *buf, u32 depth_info,
        }
 }
 
-void nametbl_print(struct print_buf *buf, const char *str)
+#if 0
+void tipc_nametbl_print(struct print_buf *buf, const char *str)
 {
        tipc_printf(buf, str);
-       read_lock_bh(&nametbl_lock);
+       read_lock_bh(&tipc_nametbl_lock);
        nametbl_list(buf, 0, 0, 0, 0);
-       read_unlock_bh(&nametbl_lock);
+       read_unlock_bh(&tipc_nametbl_lock);
 }
+#endif
 
 #define MAX_NAME_TBL_QUERY 32768
 
-struct sk_buff *nametbl_get(const void *req_tlv_area, int req_tlv_space)
+struct sk_buff *tipc_nametbl_get(const void *req_tlv_area, int req_tlv_space)
 {
        struct sk_buff *buf;
        struct tipc_name_table_query *argv;
@@ -1002,20 +1004,20 @@ struct sk_buff *nametbl_get(const void *req_tlv_area, int req_tlv_space)
        int str_len;
 
        if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_NAME_TBL_QUERY))
-               return cfg_reply_error_string(TIPC_CFG_TLV_ERROR);
+               return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR);
 
-       buf = cfg_reply_alloc(TLV_SPACE(MAX_NAME_TBL_QUERY));
+       buf = tipc_cfg_reply_alloc(TLV_SPACE(MAX_NAME_TBL_QUERY));
        if (!buf)
                return NULL;
 
        rep_tlv = (struct tlv_desc *)buf->data;
-       printbuf_init(&b, TLV_DATA(rep_tlv), MAX_NAME_TBL_QUERY);
+       tipc_printbuf_init(&b, TLV_DATA(rep_tlv), MAX_NAME_TBL_QUERY);
        argv = (struct tipc_name_table_query *)TLV_DATA(req_tlv_area);
-       read_lock_bh(&nametbl_lock);
+       read_lock_bh(&tipc_nametbl_lock);
        nametbl_list(&b, ntohl(argv->depth), ntohl(argv->type), 
                     ntohl(argv->lowbound), ntohl(argv->upbound));
-       read_unlock_bh(&nametbl_lock);
-       str_len = printbuf_validate(&b);
+       read_unlock_bh(&tipc_nametbl_lock);
+       str_len = tipc_printbuf_validate(&b);
 
        skb_put(buf, TLV_SPACE(str_len));
        TLV_SET(rep_tlv, TIPC_TLV_ULTRA_STRING, NULL, str_len);
@@ -1023,12 +1025,14 @@ struct sk_buff *nametbl_get(const void *req_tlv_area, int req_tlv_space)
        return buf;
 }
 
-void nametbl_dump(void)
+#if 0
+void tipc_nametbl_dump(void)
 {
-       nametbl_list(CONS, 0, 0, 0, 0);
+       nametbl_list(TIPC_CONS, 0, 0, 0, 0);
 }
+#endif
 
-int nametbl_init(void)
+int tipc_nametbl_init(void)
 {
        int array_size = sizeof(struct hlist_head) * tipc_nametbl_size;
 
@@ -1036,14 +1040,14 @@ int nametbl_init(void)
        if (!table.types)
                return -ENOMEM;
 
-       write_lock_bh(&nametbl_lock);
+       write_lock_bh(&tipc_nametbl_lock);
        memset(table.types, 0, array_size);
        table.local_publ_count = 0;
-       write_unlock_bh(&nametbl_lock);
+       write_unlock_bh(&tipc_nametbl_lock);
        return 0;
 }
 
-void nametbl_stop(void)
+void tipc_nametbl_stop(void)
 {
        struct hlist_head *seq_head;
        struct hlist_node *seq_node;
@@ -1054,7 +1058,7 @@ void nametbl_stop(void)
        if (!table.types)
                return;
 
-       write_lock_bh(&nametbl_lock);
+       write_lock_bh(&tipc_nametbl_lock);
        for (i = 0; i < tipc_nametbl_size; i++) {
                seq_head = &table.types[i];
                hlist_for_each_entry_safe(seq, seq_node, tmp, seq_head, ns_list) {
@@ -1075,5 +1079,5 @@ void nametbl_stop(void)
        }
        kfree(table.types);
        table.types = NULL;
-       write_unlock_bh(&nametbl_lock);
+       write_unlock_bh(&tipc_nametbl_lock);
 }