Commit 30865231 authored by Parthasarathy Bhuvaragan's avatar Parthasarathy Bhuvaragan Committed by David S. Miller

tipc: remove filter and timeout elements from struct tipc_subscription

Until now, struct tipc_subscription has duplicate timeout and filter
attributes present:
1. directly as members of struct tipc_subscription
2. in struct tipc_subscr, which is contained in struct tipc_event

In this commit, we remove the references to these elements as
members of struct tipc_subscription and replace them with elements
from struct tipc_subscr.
Acked-by: default avatarYing Xue <ying.xue@windriver.com>
Reviewed-by: default avatarJon Maloy <jon.maloy@ericsson.com>
Signed-off-by: default avatarParthasarathy Bhuvaragan <parthasarathy.bhuvaragan@ericsson.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 4f61d4ef
...@@ -110,7 +110,8 @@ void tipc_subscrp_report_overlap(struct tipc_subscription *sub, u32 found_lower, ...@@ -110,7 +110,8 @@ void tipc_subscrp_report_overlap(struct tipc_subscription *sub, u32 found_lower,
{ {
if (!tipc_subscrp_check_overlap(sub, found_lower, found_upper)) if (!tipc_subscrp_check_overlap(sub, found_lower, found_upper))
return; return;
if (!must && !(sub->filter & TIPC_SUB_PORTS)) if (!must &&
!(htohl(sub->evt.s.filter, sub->swap) & TIPC_SUB_PORTS))
return; return;
tipc_subscrp_send_event(sub, found_lower, found_upper, event, port_ref, tipc_subscrp_send_event(sub, found_lower, found_upper, event, port_ref,
...@@ -222,6 +223,7 @@ static int tipc_subscrp_create(struct net *net, struct tipc_subscr *s, ...@@ -222,6 +223,7 @@ static int tipc_subscrp_create(struct net *net, struct tipc_subscr *s,
{ {
struct tipc_net *tn = net_generic(net, tipc_net_id); struct tipc_net *tn = net_generic(net, tipc_net_id);
struct tipc_subscription *sub; struct tipc_subscription *sub;
u32 timeout, filter;
int swap; int swap;
/* Determine subscriber's endianness */ /* Determine subscriber's endianness */
...@@ -253,10 +255,8 @@ static int tipc_subscrp_create(struct net *net, struct tipc_subscr *s, ...@@ -253,10 +255,8 @@ static int tipc_subscrp_create(struct net *net, struct tipc_subscr *s,
sub->seq.type = htohl(s->seq.type, swap); sub->seq.type = htohl(s->seq.type, swap);
sub->seq.lower = htohl(s->seq.lower, swap); sub->seq.lower = htohl(s->seq.lower, swap);
sub->seq.upper = htohl(s->seq.upper, swap); sub->seq.upper = htohl(s->seq.upper, swap);
sub->timeout = msecs_to_jiffies(htohl(s->timeout, swap)); filter = htohl(s->filter, swap);
sub->filter = htohl(s->filter, swap); if (((filter & TIPC_SUB_PORTS) && (filter & TIPC_SUB_SERVICE)) ||
if ((!(sub->filter & TIPC_SUB_PORTS) ==
!(sub->filter & TIPC_SUB_SERVICE)) ||
(sub->seq.lower > sub->seq.upper)) { (sub->seq.lower > sub->seq.upper)) {
pr_warn("Subscription rejected, illegal request\n"); pr_warn("Subscription rejected, illegal request\n");
kfree(sub); kfree(sub);
...@@ -265,13 +265,14 @@ static int tipc_subscrp_create(struct net *net, struct tipc_subscr *s, ...@@ -265,13 +265,14 @@ static int tipc_subscrp_create(struct net *net, struct tipc_subscr *s,
spin_lock_bh(&subscriber->lock); spin_lock_bh(&subscriber->lock);
list_add(&sub->subscrp_list, &subscriber->subscrp_list); list_add(&sub->subscrp_list, &subscriber->subscrp_list);
spin_unlock_bh(&subscriber->lock); spin_unlock_bh(&subscriber->lock);
sub->subscriber = subscriber; sub->subscriber = subscriber;
sub->swap = swap; sub->swap = swap;
memcpy(&sub->evt.s, s, sizeof(*s)); memcpy(&sub->evt.s, s, sizeof(*s));
atomic_inc(&tn->subscription_count); atomic_inc(&tn->subscription_count);
setup_timer(&sub->timer, tipc_subscrp_timeout, (unsigned long)sub); setup_timer(&sub->timer, tipc_subscrp_timeout, (unsigned long)sub);
sub->timeout += jiffies; timeout = htohl(sub->evt.s.timeout, swap);
if (!mod_timer(&sub->timer, sub->timeout)) if (!mod_timer(&sub->timer, jiffies + msecs_to_jiffies(timeout)))
tipc_subscrb_get(subscriber); tipc_subscrb_get(subscriber);
*sub_p = sub; *sub_p = sub;
return 0; return 0;
......
...@@ -50,12 +50,9 @@ struct tipc_subscriber; ...@@ -50,12 +50,9 @@ struct tipc_subscriber;
* @subscriber: pointer to its subscriber * @subscriber: pointer to its subscriber
* @seq: name sequence associated with subscription * @seq: name sequence associated with subscription
* @net: point to network namespace * @net: point to network namespace
* @timeout: duration of subscription (in ms)
* @filter: event filtering to be done for subscription
* @timer: timer governing subscription duration (optional) * @timer: timer governing subscription duration (optional)
* @nameseq_list: adjacent subscriptions in name sequence's subscription list * @nameseq_list: adjacent subscriptions in name sequence's subscription list
* @subscrp_list: adjacent subscriptions in subscriber's subscription list * @subscrp_list: adjacent subscriptions in subscriber's subscription list
* @server_ref: object reference of server port associated with subscription
* @swap: indicates if subscriber uses opposite endianness in its messages * @swap: indicates if subscriber uses opposite endianness in its messages
* @evt: template for events generated by subscription * @evt: template for events generated by subscription
*/ */
...@@ -63,8 +60,6 @@ struct tipc_subscription { ...@@ -63,8 +60,6 @@ struct tipc_subscription {
struct tipc_subscriber *subscriber; struct tipc_subscriber *subscriber;
struct tipc_name_seq seq; struct tipc_name_seq seq;
struct net *net; struct net *net;
unsigned long timeout;
u32 filter;
struct timer_list timer; struct timer_list timer;
struct list_head nameseq_list; struct list_head nameseq_list;
struct list_head subscrp_list; struct list_head subscrp_list;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment