tipc: name tipc name table support net namespace
[deliverable/linux.git] / net / tipc / subscr.c
index 0344206b984f7f168a742726e8ad853940ff9cec..b71dbc0ae8f910da80515e5f11351e58625d7f7f 100644 (file)
@@ -50,8 +50,9 @@ struct tipc_subscriber {
        struct list_head subscription_list;
 };
 
-static void subscr_conn_msg_event(int conid, struct sockaddr_tipc *addr,
-                                 void *usr_data, void *buf, size_t len);
+static void subscr_conn_msg_event(struct net *net, int conid,
+                                 struct sockaddr_tipc *addr, void *usr_data,
+                                 void *buf, size_t len);
 static void *subscr_named_msg_event(int conid);
 static void subscr_conn_shutdown_event(int conid, void *usr_data);
 
@@ -141,8 +142,9 @@ void tipc_subscr_report_overlap(struct tipc_subscription *sub, u32 found_lower,
        subscr_send_event(sub, found_lower, found_upper, event, port_ref, node);
 }
 
-static void subscr_timeout(struct tipc_subscription *sub)
+static void subscr_timeout(unsigned long data)
 {
+       struct tipc_subscription *sub = (struct tipc_subscription *)data;
        struct tipc_subscriber *subscriber = sub->subscriber;
 
        /* The spin lock per subscriber is used to protect its members */
@@ -167,7 +169,6 @@ static void subscr_timeout(struct tipc_subscription *sub)
                          TIPC_SUBSCR_TIMEOUT, 0, 0);
 
        /* Now destroy subscription */
-       k_term_timer(&sub->timer);
        kfree(sub);
        atomic_dec(&subscription_count);
 }
@@ -207,8 +208,7 @@ static void subscr_release(struct tipc_subscriber *subscriber)
                                 subscription_list) {
                if (sub->timeout != TIPC_WAIT_FOREVER) {
                        spin_unlock_bh(&subscriber->lock);
-                       k_cancel_timer(&sub->timer);
-                       k_term_timer(&sub->timer);
+                       del_timer_sync(&sub->timer);
                        spin_lock_bh(&subscriber->lock);
                }
                subscr_del(sub);
@@ -250,8 +250,7 @@ static void subscr_cancel(struct tipc_subscr *s,
        if (sub->timeout != TIPC_WAIT_FOREVER) {
                sub->timeout = TIPC_WAIT_FOREVER;
                spin_unlock_bh(&subscriber->lock);
-               k_cancel_timer(&sub->timer);
-               k_term_timer(&sub->timer);
+               del_timer_sync(&sub->timer);
                spin_lock_bh(&subscriber->lock);
        }
        subscr_del(sub);
@@ -262,7 +261,7 @@ static void subscr_cancel(struct tipc_subscr *s,
  *
  * Called with subscriber lock held.
  */
-static int subscr_subscribe(struct tipc_subscr *s,
+static int subscr_subscribe(struct net *net, struct tipc_subscr *s,
                            struct tipc_subscriber *subscriber,
                            struct tipc_subscription **sub_p) {
        struct tipc_subscription *sub;
@@ -293,10 +292,11 @@ static int subscr_subscribe(struct tipc_subscr *s,
        }
 
        /* Initialize subscription object */
+       sub->net = net;
        sub->seq.type = htohl(s->seq.type, swap);
        sub->seq.lower = htohl(s->seq.lower, swap);
        sub->seq.upper = htohl(s->seq.upper, swap);
-       sub->timeout = htohl(s->timeout, swap);
+       sub->timeout = msecs_to_jiffies(htohl(s->timeout, swap));
        sub->filter = htohl(s->filter, swap);
        if ((!(sub->filter & TIPC_SUB_PORTS) ==
             !(sub->filter & TIPC_SUB_SERVICE)) ||
@@ -311,9 +311,8 @@ static int subscr_subscribe(struct tipc_subscr *s,
        memcpy(&sub->evt.s, s, sizeof(struct tipc_subscr));
        atomic_inc(&subscription_count);
        if (sub->timeout != TIPC_WAIT_FOREVER) {
-               k_init_timer(&sub->timer,
-                            (Handler)subscr_timeout, (unsigned long)sub);
-               k_start_timer(&sub->timer, sub->timeout);
+               setup_timer(&sub->timer, subscr_timeout, (unsigned long)sub);
+               mod_timer(&sub->timer, jiffies + sub->timeout);
        }
        *sub_p = sub;
        return 0;
@@ -326,14 +325,16 @@ static void subscr_conn_shutdown_event(int conid, void *usr_data)
 }
 
 /* Handle one request to create a new subscription for the subscriber */
-static void subscr_conn_msg_event(int conid, struct sockaddr_tipc *addr,
-                                 void *usr_data, void *buf, size_t len)
+static void subscr_conn_msg_event(struct net *net, int conid,
+                                 struct sockaddr_tipc *addr, void *usr_data,
+                                 void *buf, size_t len)
 {
        struct tipc_subscriber *subscriber = usr_data;
        struct tipc_subscription *sub = NULL;
 
        spin_lock_bh(&subscriber->lock);
-       if (subscr_subscribe((struct tipc_subscr *)buf, subscriber, &sub) < 0) {
+       if (subscr_subscribe(net, (struct tipc_subscr *)buf, subscriber,
+                            &sub) < 0) {
                spin_unlock_bh(&subscriber->lock);
                subscr_terminate(subscriber);
                return;
This page took 0.042546 seconds and 5 git commands to generate.