linux 2.6.16.38 w/ vs2.0.3-rc1
[linux-2.6.git] / net / tipc / subscr.c
index c51600b..5ff38b9 100644 (file)
@@ -86,7 +86,7 @@ static struct top_srv topsrv = { 0 };
  * Returns converted value
  */
 
-static u32 htohl(u32 in, int swap)
+static inline u32 htohl(u32 in, int swap)
 {
        char *c = (char *)∈
 
@@ -266,8 +266,7 @@ static void subscr_subscribe(struct tipc_subscr *s,
        /* Refuse subscription if global limit exceeded */
 
        if (atomic_read(&topsrv.subscription_count) >= tipc_max_subscriptions) {
-               warn("Subscription rejected, subscription limit reached (%u)\n",
-                    tipc_max_subscriptions);
+               warn("Failed: max %u subscriptions\n", tipc_max_subscriptions);
                subscr_terminate(subscriber);
                return;
        }
@@ -275,8 +274,8 @@ static void subscr_subscribe(struct tipc_subscr *s,
        /* Allocate subscription object */
 
        sub = kmalloc(sizeof(*sub), GFP_ATOMIC);
-       if (!sub) {
-               warn("Subscription rejected, no memory\n");
+       if (sub == NULL) {
+               warn("Memory squeeze; ignoring subscription\n");
                subscr_terminate(subscriber);
                return;
        }
@@ -299,7 +298,8 @@ static void subscr_subscribe(struct tipc_subscr *s,
        if ((((sub->filter != TIPC_SUB_PORTS) 
              && (sub->filter != TIPC_SUB_SERVICE)))
            || (sub->seq.lower > sub->seq.upper)) {
-               warn("Subscription rejected, illegal request\n");
+               warn("Rejecting illegal subscription %u,%u,%u\n",
+                    sub->seq.type, sub->seq.lower, sub->seq.upper);
                kfree(sub);
                subscr_terminate(subscriber);
                return;
@@ -381,28 +381,29 @@ static void subscr_named_msg_event(void *usr_handle,
                                   struct tipc_name_seq const *dest)
 {
        struct subscriber *subscriber;
-       struct iovec msg_sect = {NULL, 0};
+       struct iovec msg_sect = {0, 0};
        spinlock_t *subscriber_lock;
 
        dbg("subscr_named_msg_event: orig = %x own = %x,\n",
            orig->node, tipc_own_addr);
        if (size && (size != sizeof(struct tipc_subscr))) {
-               warn("Subscriber rejected, invalid subscription size\n");
+               warn("Received tipc_subscr of invalid size\n");
                return;
        }
 
        /* Create subscriber object */
 
-       subscriber = kzalloc(sizeof(struct subscriber), GFP_ATOMIC);
+       subscriber = kmalloc(sizeof(struct subscriber), GFP_ATOMIC);
        if (subscriber == NULL) {
-               warn("Subscriber rejected, no memory\n");
+               warn("Memory squeeze; ignoring subscriber setup\n");
                return;
        }
+       memset(subscriber, 0, sizeof(struct subscriber));
        INIT_LIST_HEAD(&subscriber->subscription_list);
        INIT_LIST_HEAD(&subscriber->subscriber_list);
        subscriber->ref = tipc_ref_acquire(subscriber, &subscriber->lock);
        if (subscriber->ref == 0) {
-               warn("Subscriber rejected, reference table exhausted\n");
+               warn("Failed to acquire subscriber reference\n");
                kfree(subscriber);
                return;
        }
@@ -412,16 +413,16 @@ static void subscr_named_msg_event(void *usr_handle,
        tipc_createport(topsrv.user_ref,
                        (void *)(unsigned long)subscriber->ref,
                        importance,
-                       NULL,
-                       NULL,
+                       0,
+                       0,
                        subscr_conn_shutdown_event,
-                       NULL,
-                       NULL,
+                       0,
+                       0,
                        subscr_conn_msg_event,
-                       NULL,
+                       0,
                        &subscriber->port_ref);
        if (subscriber->port_ref == 0) {
-               warn("Subscriber rejected, unable to create port\n");
+               warn("Memory squeeze; failed to create subscription port\n");
                tipc_ref_discard(subscriber->ref);
                kfree(subscriber);
                return;
@@ -456,26 +457,26 @@ int tipc_subscr_start(void)
        int res = -1;
 
        memset(&topsrv, 0, sizeof (topsrv));
-       spin_lock_init(&topsrv.lock);
+       topsrv.lock = SPIN_LOCK_UNLOCKED;
        INIT_LIST_HEAD(&topsrv.subscriber_list);
 
        spin_lock_bh(&topsrv.lock);
-       res = tipc_attach(&topsrv.user_ref, NULL, NULL);
+       res = tipc_attach(&topsrv.user_ref, 0, 0);
        if (res) {
                spin_unlock_bh(&topsrv.lock);
                return res;
        }
 
        res = tipc_createport(topsrv.user_ref,
-                             NULL,
+                             0,
                              TIPC_CRITICAL_IMPORTANCE,
-                             NULL,
-                             NULL,
-                             NULL,
-                             NULL,
+                             0,
+                             0,
+                             0,
+                             0,
                              subscr_named_msg_event,
-                             NULL,
-                             NULL,
+                             0,
+                             0,
                              &topsrv.setup_port);
        if (res)
                goto failed;