diff options
-rw-r--r-- | net/tipc/server.c | 4 | ||||
-rw-r--r-- | net/tipc/server.h | 1 | ||||
-rw-r--r-- | net/tipc/subscr.c | 46 | ||||
-rw-r--r-- | net/tipc/subscr.h | 14 |
4 files changed, 22 insertions, 43 deletions
diff --git a/net/tipc/server.c b/net/tipc/server.c index 5d231fa8e4b5..6a18b10ac271 100644 --- a/net/tipc/server.c +++ b/net/tipc/server.c | |||
@@ -203,7 +203,7 @@ static void tipc_con_delete_sub(struct tipc_conn *con, struct tipc_subscr *s) | |||
203 | spin_lock_bh(&con->sub_lock); | 203 | spin_lock_bh(&con->sub_lock); |
204 | list_for_each_entry_safe(sub, tmp, sub_list, subscrp_list) { | 204 | list_for_each_entry_safe(sub, tmp, sub_list, subscrp_list) { |
205 | if (!s || !memcmp(s, &sub->evt.s, sizeof(*s))) | 205 | if (!s || !memcmp(s, &sub->evt.s, sizeof(*s))) |
206 | tipc_sub_delete(sub); | 206 | tipc_sub_unsubscribe(sub); |
207 | else if (s) | 207 | else if (s) |
208 | break; | 208 | break; |
209 | } | 209 | } |
@@ -278,7 +278,7 @@ static int tipc_con_rcv_sub(struct tipc_server *srv, | |||
278 | tipc_con_delete_sub(con, s); | 278 | tipc_con_delete_sub(con, s); |
279 | return 0; | 279 | return 0; |
280 | } | 280 | } |
281 | sub = tipc_subscrp_subscribe(srv, s, con->conid); | 281 | sub = tipc_sub_subscribe(srv, s, con->conid); |
282 | if (!sub) | 282 | if (!sub) |
283 | return -1; | 283 | return -1; |
284 | 284 | ||
diff --git a/net/tipc/server.h b/net/tipc/server.h index 2de8709b467d..995b79591ffe 100644 --- a/net/tipc/server.h +++ b/net/tipc/server.h | |||
@@ -2,6 +2,7 @@ | |||
2 | * net/tipc/server.h: Include file for TIPC server code | 2 | * net/tipc/server.h: Include file for TIPC server code |
3 | * | 3 | * |
4 | * Copyright (c) 2012-2013, Wind River Systems | 4 | * Copyright (c) 2012-2013, Wind River Systems |
5 | * Copyright (c) 2017, Ericsson AB | ||
5 | * All rights reserved. | 6 | * All rights reserved. |
6 | * | 7 | * |
7 | * Redistribution and use in source and binary forms, with or without | 8 | * Redistribution and use in source and binary forms, with or without |
diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c index 406b09fc227b..8d37b61e3163 100644 --- a/net/tipc/subscr.c +++ b/net/tipc/subscr.c | |||
@@ -134,33 +134,29 @@ void tipc_subscrp_get(struct tipc_subscription *subscription) | |||
134 | kref_get(&subscription->kref); | 134 | kref_get(&subscription->kref); |
135 | } | 135 | } |
136 | 136 | ||
137 | static struct tipc_subscription *tipc_subscrp_create(struct tipc_server *srv, | 137 | struct tipc_subscription *tipc_sub_subscribe(struct tipc_server *srv, |
138 | struct tipc_subscr *s, | 138 | struct tipc_subscr *s, |
139 | int conid) | 139 | int conid) |
140 | { | 140 | { |
141 | struct tipc_net *tn = tipc_net(srv->net); | 141 | struct tipc_net *tn = tipc_net(srv->net); |
142 | struct tipc_subscription *sub; | 142 | struct tipc_subscription *sub; |
143 | u32 filter = tipc_sub_read(s, filter); | 143 | u32 filter = tipc_sub_read(s, filter); |
144 | u32 timeout; | ||
144 | 145 | ||
145 | /* Refuse subscription if global limit exceeded */ | 146 | if (atomic_read(&tn->subscription_count) >= TIPC_MAX_SUBSCR) { |
146 | if (atomic_read(&tn->subscription_count) >= TIPC_MAX_SUBSCRIPTIONS) { | 147 | pr_warn("Subscription rejected, max (%u)\n", TIPC_MAX_SUBSCR); |
147 | pr_warn("Subscription rejected, limit reached (%u)\n", | 148 | return NULL; |
148 | TIPC_MAX_SUBSCRIPTIONS); | 149 | } |
150 | if ((filter & TIPC_SUB_PORTS && filter & TIPC_SUB_SERVICE) || | ||
151 | (tipc_sub_read(s, seq.lower) > tipc_sub_read(s, seq.upper))) { | ||
152 | pr_warn("Subscription rejected, illegal request\n"); | ||
149 | return NULL; | 153 | return NULL; |
150 | } | 154 | } |
151 | |||
152 | /* Allocate subscription object */ | ||
153 | sub = kmalloc(sizeof(*sub), GFP_ATOMIC); | 155 | sub = kmalloc(sizeof(*sub), GFP_ATOMIC); |
154 | if (!sub) { | 156 | if (!sub) { |
155 | pr_warn("Subscription rejected, no memory\n"); | 157 | pr_warn("Subscription rejected, no memory\n"); |
156 | return NULL; | 158 | return NULL; |
157 | } | 159 | } |
158 | |||
159 | /* Initialize subscription object */ | ||
160 | if (filter & TIPC_SUB_PORTS && filter & TIPC_SUB_SERVICE) | ||
161 | goto err; | ||
162 | if (tipc_sub_read(s, seq.lower) > tipc_sub_read(s, seq.upper)) | ||
163 | goto err; | ||
164 | sub->server = srv; | 160 | sub->server = srv; |
165 | sub->conid = conid; | 161 | sub->conid = conid; |
166 | sub->inactive = false; | 162 | sub->inactive = false; |
@@ -168,24 +164,6 @@ static struct tipc_subscription *tipc_subscrp_create(struct tipc_server *srv, | |||
168 | spin_lock_init(&sub->lock); | 164 | spin_lock_init(&sub->lock); |
169 | atomic_inc(&tn->subscription_count); | 165 | atomic_inc(&tn->subscription_count); |
170 | kref_init(&sub->kref); | 166 | kref_init(&sub->kref); |
171 | return sub; | ||
172 | err: | ||
173 | pr_warn("Subscription rejected, illegal request\n"); | ||
174 | kfree(sub); | ||
175 | return NULL; | ||
176 | } | ||
177 | |||
178 | struct tipc_subscription *tipc_subscrp_subscribe(struct tipc_server *srv, | ||
179 | struct tipc_subscr *s, | ||
180 | int conid) | ||
181 | { | ||
182 | struct tipc_subscription *sub = NULL; | ||
183 | u32 timeout; | ||
184 | |||
185 | sub = tipc_subscrp_create(srv, s, conid); | ||
186 | if (!sub) | ||
187 | return NULL; | ||
188 | |||
189 | tipc_nametbl_subscribe(sub); | 167 | tipc_nametbl_subscribe(sub); |
190 | timer_setup(&sub->timer, tipc_subscrp_timeout, 0); | 168 | timer_setup(&sub->timer, tipc_subscrp_timeout, 0); |
191 | timeout = tipc_sub_read(&sub->evt.s, timeout); | 169 | timeout = tipc_sub_read(&sub->evt.s, timeout); |
@@ -194,7 +172,7 @@ struct tipc_subscription *tipc_subscrp_subscribe(struct tipc_server *srv, | |||
194 | return sub; | 172 | return sub; |
195 | } | 173 | } |
196 | 174 | ||
197 | void tipc_sub_delete(struct tipc_subscription *sub) | 175 | void tipc_sub_unsubscribe(struct tipc_subscription *sub) |
198 | { | 176 | { |
199 | tipc_nametbl_unsubscribe(sub); | 177 | tipc_nametbl_unsubscribe(sub); |
200 | if (sub->evt.s.timeout != TIPC_WAIT_FOREVER) | 178 | if (sub->evt.s.timeout != TIPC_WAIT_FOREVER) |
diff --git a/net/tipc/subscr.h b/net/tipc/subscr.h index db80e41bba08..2d35f1046754 100644 --- a/net/tipc/subscr.h +++ b/net/tipc/subscr.h | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * net/tipc/subscr.h: Include file for TIPC network topology service | 2 | * net/tipc/subscr.h: Include file for TIPC network topology service |
3 | * | 3 | * |
4 | * Copyright (c) 2003-2006, Ericsson AB | 4 | * Copyright (c) 2003-2017, Ericsson AB |
5 | * Copyright (c) 2005-2007, 2012-2013, Wind River Systems | 5 | * Copyright (c) 2005-2007, 2012-2013, Wind River Systems |
6 | * All rights reserved. | 6 | * All rights reserved. |
7 | * | 7 | * |
@@ -39,8 +39,8 @@ | |||
39 | 39 | ||
40 | #include "server.h" | 40 | #include "server.h" |
41 | 41 | ||
42 | #define TIPC_MAX_SUBSCRIPTIONS 65535 | 42 | #define TIPC_MAX_SUBSCR 65535 |
43 | #define TIPC_MAX_PUBLICATIONS 65535 | 43 | #define TIPC_MAX_PUBLICATIONS 65535 |
44 | 44 | ||
45 | struct tipc_subscription; | 45 | struct tipc_subscription; |
46 | struct tipc_conn; | 46 | struct tipc_conn; |
@@ -66,10 +66,10 @@ struct tipc_subscription { | |||
66 | spinlock_t lock; /* serialize up/down and timer events */ | 66 | spinlock_t lock; /* serialize up/down and timer events */ |
67 | }; | 67 | }; |
68 | 68 | ||
69 | struct tipc_subscription *tipc_subscrp_subscribe(struct tipc_server *srv, | 69 | struct tipc_subscription *tipc_sub_subscribe(struct tipc_server *srv, |
70 | struct tipc_subscr *s, | 70 | struct tipc_subscr *s, |
71 | int conid); | 71 | int conid); |
72 | void tipc_sub_delete(struct tipc_subscription *sub); | 72 | void tipc_sub_unsubscribe(struct tipc_subscription *sub); |
73 | 73 | ||
74 | int tipc_subscrp_check_overlap(struct tipc_name_seq *seq, u32 found_lower, | 74 | int tipc_subscrp_check_overlap(struct tipc_name_seq *seq, u32 found_lower, |
75 | u32 found_upper); | 75 | u32 found_upper); |