Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 1 | /* |
Allan Stephens | 5b06c85c | 2008-05-19 13:30:13 -0700 | [diff] [blame] | 2 | * net/tipc/subscr.c: TIPC network topology service |
YOSHIFUJI Hideaki | c430728 | 2007-02-09 23:25:21 +0900 | [diff] [blame] | 3 | * |
Per Liden | 593a5f2 | 2006-01-11 19:14:19 +0100 | [diff] [blame] | 4 | * Copyright (c) 2000-2006, Ericsson AB |
Allan Stephens | 23dd4cc | 2011-01-07 11:43:40 -0500 | [diff] [blame] | 5 | * Copyright (c) 2005-2007, 2010-2011, Wind River Systems |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 6 | * All rights reserved. |
| 7 | * |
Per Liden | 9ea1fd3 | 2006-01-11 13:30:43 +0100 | [diff] [blame] | 8 | * Redistribution and use in source and binary forms, with or without |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 9 | * modification, are permitted provided that the following conditions are met: |
| 10 | * |
Per Liden | 9ea1fd3 | 2006-01-11 13:30:43 +0100 | [diff] [blame] | 11 | * 1. Redistributions of source code must retain the above copyright |
| 12 | * notice, this list of conditions and the following disclaimer. |
| 13 | * 2. Redistributions in binary form must reproduce the above copyright |
| 14 | * notice, this list of conditions and the following disclaimer in the |
| 15 | * documentation and/or other materials provided with the distribution. |
| 16 | * 3. Neither the names of the copyright holders nor the names of its |
| 17 | * contributors may be used to endorse or promote products derived from |
| 18 | * this software without specific prior written permission. |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 19 | * |
Per Liden | 9ea1fd3 | 2006-01-11 13:30:43 +0100 | [diff] [blame] | 20 | * Alternatively, this software may be distributed under the terms of the |
| 21 | * GNU General Public License ("GPL") version 2 as published by the Free |
| 22 | * Software Foundation. |
| 23 | * |
| 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 27 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
| 28 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 29 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 30 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 31 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 32 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 34 | * POSSIBILITY OF SUCH DAMAGE. |
| 35 | */ |
| 36 | |
| 37 | #include "core.h" |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 38 | #include "name_table.h" |
Allan Stephens | aa70200 | 2010-12-31 18:59:21 +0000 | [diff] [blame] | 39 | #include "port.h" |
Allan Stephens | 5b06c85c | 2008-05-19 13:30:13 -0700 | [diff] [blame] | 40 | #include "subscr.h" |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 41 | |
| 42 | /** |
Paul Gortmaker | 11f9990 | 2011-12-29 20:49:39 -0500 | [diff] [blame] | 43 | * struct tipc_subscriber - TIPC network topology subscriber |
Allan Stephens | 28353e7 | 2008-05-19 13:29:47 -0700 | [diff] [blame] | 44 | * @port_ref: object reference to server port connecting to subscriber |
| 45 | * @lock: pointer to spinlock controlling access to subscriber's server port |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 46 | * @subscriber_list: adjacent subscribers in top. server's list of subscribers |
| 47 | * @subscription_list: list of subscription objects for this subscriber |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 48 | */ |
Paul Gortmaker | 11f9990 | 2011-12-29 20:49:39 -0500 | [diff] [blame] | 49 | struct tipc_subscriber { |
Allan Stephens | 28353e7 | 2008-05-19 13:29:47 -0700 | [diff] [blame] | 50 | u32 port_ref; |
YOSHIFUJI Hideaki | c430728 | 2007-02-09 23:25:21 +0900 | [diff] [blame] | 51 | spinlock_t *lock; |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 52 | struct list_head subscriber_list; |
| 53 | struct list_head subscription_list; |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 54 | }; |
| 55 | |
| 56 | /** |
| 57 | * struct top_srv - TIPC network topology subscription service |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 58 | * @setup_port: reference to TIPC port that handles subscription requests |
| 59 | * @subscription_count: number of active subscriptions (not subscribers!) |
| 60 | * @subscriber_list: list of ports subscribing to service |
| 61 | * @lock: spinlock govering access to subscriber list |
| 62 | */ |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 63 | struct top_srv { |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 64 | u32 setup_port; |
| 65 | atomic_t subscription_count; |
| 66 | struct list_head subscriber_list; |
| 67 | spinlock_t lock; |
| 68 | }; |
| 69 | |
Allan Stephens | e3ec9c7 | 2010-12-31 18:59:34 +0000 | [diff] [blame] | 70 | static struct top_srv topsrv; |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 71 | |
| 72 | /** |
Neil Horman | db5a753 | 2010-10-21 01:06:16 +0000 | [diff] [blame] | 73 | * htohl - convert value to endianness used by destination |
| 74 | * @in: value to convert |
| 75 | * @swap: non-zero if endianness must be reversed |
| 76 | * |
| 77 | * Returns converted value |
| 78 | */ |
Neil Horman | db5a753 | 2010-10-21 01:06:16 +0000 | [diff] [blame] | 79 | static u32 htohl(u32 in, int swap) |
| 80 | { |
| 81 | return swap ? swab32(in) : in; |
| 82 | } |
| 83 | |
| 84 | /** |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 85 | * subscr_send_event - send a message containing a tipc_event to the subscriber |
Allan Stephens | 28353e7 | 2008-05-19 13:29:47 -0700 | [diff] [blame] | 86 | * |
| 87 | * Note: Must not hold subscriber's server port lock, since tipc_send() will |
| 88 | * try to take the lock if the message is rejected and returned! |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 89 | */ |
Paul Gortmaker | fead390 | 2011-12-29 20:43:44 -0500 | [diff] [blame] | 90 | static void subscr_send_event(struct tipc_subscription *sub, |
YOSHIFUJI Hideaki | c430728 | 2007-02-09 23:25:21 +0900 | [diff] [blame] | 91 | u32 found_lower, |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 92 | u32 found_upper, |
YOSHIFUJI Hideaki | c430728 | 2007-02-09 23:25:21 +0900 | [diff] [blame] | 93 | u32 event, |
| 94 | u32 port_ref, |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 95 | u32 node) |
| 96 | { |
| 97 | struct iovec msg_sect; |
| 98 | |
| 99 | msg_sect.iov_base = (void *)&sub->evt; |
| 100 | msg_sect.iov_len = sizeof(struct tipc_event); |
| 101 | |
Neil Horman | db5a753 | 2010-10-21 01:06:16 +0000 | [diff] [blame] | 102 | sub->evt.event = htohl(event, sub->swap); |
| 103 | sub->evt.found_lower = htohl(found_lower, sub->swap); |
| 104 | sub->evt.found_upper = htohl(found_upper, sub->swap); |
| 105 | sub->evt.port.ref = htohl(port_ref, sub->swap); |
| 106 | sub->evt.port.node = htohl(node, sub->swap); |
Allan Stephens | 2689690 | 2011-04-21 10:42:07 -0500 | [diff] [blame] | 107 | tipc_send(sub->server_ref, 1, &msg_sect, msg_sect.iov_len); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 108 | } |
| 109 | |
| 110 | /** |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 111 | * tipc_subscr_overlap - test for subscription overlap with the given values |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 112 | * |
| 113 | * Returns 1 if there is overlap, otherwise 0. |
| 114 | */ |
Paul Gortmaker | fead390 | 2011-12-29 20:43:44 -0500 | [diff] [blame] | 115 | int tipc_subscr_overlap(struct tipc_subscription *sub, |
YOSHIFUJI Hideaki | c430728 | 2007-02-09 23:25:21 +0900 | [diff] [blame] | 116 | u32 found_lower, |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 117 | u32 found_upper) |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 118 | |
| 119 | { |
| 120 | if (found_lower < sub->seq.lower) |
| 121 | found_lower = sub->seq.lower; |
| 122 | if (found_upper > sub->seq.upper) |
| 123 | found_upper = sub->seq.upper; |
| 124 | if (found_lower > found_upper) |
| 125 | return 0; |
| 126 | return 1; |
| 127 | } |
| 128 | |
| 129 | /** |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 130 | * tipc_subscr_report_overlap - issue event if there is subscription overlap |
YOSHIFUJI Hideaki | c430728 | 2007-02-09 23:25:21 +0900 | [diff] [blame] | 131 | * |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 132 | * Protected by nameseq.lock in name_table.c |
| 133 | */ |
Paul Gortmaker | fead390 | 2011-12-29 20:43:44 -0500 | [diff] [blame] | 134 | void tipc_subscr_report_overlap(struct tipc_subscription *sub, |
YOSHIFUJI Hideaki | c430728 | 2007-02-09 23:25:21 +0900 | [diff] [blame] | 135 | u32 found_lower, |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 136 | u32 found_upper, |
YOSHIFUJI Hideaki | c430728 | 2007-02-09 23:25:21 +0900 | [diff] [blame] | 137 | u32 event, |
| 138 | u32 port_ref, |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 139 | u32 node, |
| 140 | int must) |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 141 | { |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 142 | if (!tipc_subscr_overlap(sub, found_lower, found_upper)) |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 143 | return; |
Lijun Chen | eb40946 | 2006-10-16 21:59:42 -0700 | [diff] [blame] | 144 | if (!must && !(sub->filter & TIPC_SUB_PORTS)) |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 145 | return; |
Allan Stephens | e15f880 | 2008-05-19 13:27:31 -0700 | [diff] [blame] | 146 | |
Ying Xue | 7e24477 | 2011-07-19 04:21:56 -0400 | [diff] [blame] | 147 | subscr_send_event(sub, found_lower, found_upper, event, port_ref, node); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 148 | } |
| 149 | |
| 150 | /** |
| 151 | * subscr_timeout - subscription timeout has occurred |
| 152 | */ |
Paul Gortmaker | fead390 | 2011-12-29 20:43:44 -0500 | [diff] [blame] | 153 | static void subscr_timeout(struct tipc_subscription *sub) |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 154 | { |
Allan Stephens | 23dd4cc | 2011-01-07 11:43:40 -0500 | [diff] [blame] | 155 | struct tipc_port *server_port; |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 156 | |
Allan Stephens | 28353e7 | 2008-05-19 13:29:47 -0700 | [diff] [blame] | 157 | /* Validate server port reference (in case subscriber is terminating) */ |
Allan Stephens | 28353e7 | 2008-05-19 13:29:47 -0700 | [diff] [blame] | 158 | server_port = tipc_port_lock(sub->server_ref); |
| 159 | if (server_port == NULL) |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 160 | return; |
| 161 | |
Lijun Chen | eb40946 | 2006-10-16 21:59:42 -0700 | [diff] [blame] | 162 | /* Validate timeout (in case subscription is being cancelled) */ |
Lijun Chen | eb40946 | 2006-10-16 21:59:42 -0700 | [diff] [blame] | 163 | if (sub->timeout == TIPC_WAIT_FOREVER) { |
Allan Stephens | 28353e7 | 2008-05-19 13:29:47 -0700 | [diff] [blame] | 164 | tipc_port_unlock(server_port); |
Lijun Chen | eb40946 | 2006-10-16 21:59:42 -0700 | [diff] [blame] | 165 | return; |
| 166 | } |
| 167 | |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 168 | /* Unlink subscription from name table */ |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 169 | tipc_nametbl_unsubscribe(sub); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 170 | |
Allan Stephens | 28353e7 | 2008-05-19 13:29:47 -0700 | [diff] [blame] | 171 | /* Unlink subscription from subscriber */ |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 172 | list_del(&sub->subscription_list); |
| 173 | |
Allan Stephens | 28353e7 | 2008-05-19 13:29:47 -0700 | [diff] [blame] | 174 | /* Release subscriber's server port */ |
Allan Stephens | 28353e7 | 2008-05-19 13:29:47 -0700 | [diff] [blame] | 175 | tipc_port_unlock(server_port); |
| 176 | |
| 177 | /* Notify subscriber of timeout */ |
Allan Stephens | 28353e7 | 2008-05-19 13:29:47 -0700 | [diff] [blame] | 178 | subscr_send_event(sub, sub->evt.s.seq.lower, sub->evt.s.seq.upper, |
| 179 | TIPC_SUBSCR_TIMEOUT, 0, 0); |
| 180 | |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 181 | /* Now destroy subscription */ |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 182 | k_term_timer(&sub->timer); |
| 183 | kfree(sub); |
| 184 | atomic_dec(&topsrv.subscription_count); |
| 185 | } |
| 186 | |
| 187 | /** |
Lijun Chen | eb40946 | 2006-10-16 21:59:42 -0700 | [diff] [blame] | 188 | * subscr_del - delete a subscription within a subscription list |
| 189 | * |
Allan Stephens | 28353e7 | 2008-05-19 13:29:47 -0700 | [diff] [blame] | 190 | * Called with subscriber port locked. |
Lijun Chen | eb40946 | 2006-10-16 21:59:42 -0700 | [diff] [blame] | 191 | */ |
Paul Gortmaker | fead390 | 2011-12-29 20:43:44 -0500 | [diff] [blame] | 192 | static void subscr_del(struct tipc_subscription *sub) |
Lijun Chen | eb40946 | 2006-10-16 21:59:42 -0700 | [diff] [blame] | 193 | { |
| 194 | tipc_nametbl_unsubscribe(sub); |
| 195 | list_del(&sub->subscription_list); |
| 196 | kfree(sub); |
| 197 | atomic_dec(&topsrv.subscription_count); |
| 198 | } |
| 199 | |
| 200 | /** |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 201 | * subscr_terminate - terminate communication with a subscriber |
YOSHIFUJI Hideaki | c430728 | 2007-02-09 23:25:21 +0900 | [diff] [blame] | 202 | * |
Allan Stephens | 28353e7 | 2008-05-19 13:29:47 -0700 | [diff] [blame] | 203 | * Called with subscriber port locked. Routine must temporarily release lock |
YOSHIFUJI Hideaki | c430728 | 2007-02-09 23:25:21 +0900 | [diff] [blame] | 204 | * to enable subscription timeout routine(s) to finish without deadlocking; |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 205 | * the lock is then reclaimed to allow caller to release it upon return. |
YOSHIFUJI Hideaki | c430728 | 2007-02-09 23:25:21 +0900 | [diff] [blame] | 206 | * (This should work even in the unlikely event some other thread creates |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 207 | * a new object reference in the interim that uses this lock; this routine will |
| 208 | * simply wait for it to be released, then claim it.) |
| 209 | */ |
Paul Gortmaker | 11f9990 | 2011-12-29 20:49:39 -0500 | [diff] [blame] | 210 | static void subscr_terminate(struct tipc_subscriber *subscriber) |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 211 | { |
Allan Stephens | 28353e7 | 2008-05-19 13:29:47 -0700 | [diff] [blame] | 212 | u32 port_ref; |
Paul Gortmaker | fead390 | 2011-12-29 20:43:44 -0500 | [diff] [blame] | 213 | struct tipc_subscription *sub; |
| 214 | struct tipc_subscription *sub_temp; |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 215 | |
| 216 | /* Invalidate subscriber reference */ |
Allan Stephens | 28353e7 | 2008-05-19 13:29:47 -0700 | [diff] [blame] | 217 | port_ref = subscriber->port_ref; |
| 218 | subscriber->port_ref = 0; |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 219 | spin_unlock_bh(subscriber->lock); |
| 220 | |
Allan Stephens | 28353e7 | 2008-05-19 13:29:47 -0700 | [diff] [blame] | 221 | /* Sever connection to subscriber */ |
Allan Stephens | 28353e7 | 2008-05-19 13:29:47 -0700 | [diff] [blame] | 222 | tipc_shutdown(port_ref); |
| 223 | tipc_deleteport(port_ref); |
| 224 | |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 225 | /* Destroy any existing subscriptions for subscriber */ |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 226 | list_for_each_entry_safe(sub, sub_temp, &subscriber->subscription_list, |
| 227 | subscription_list) { |
| 228 | if (sub->timeout != TIPC_WAIT_FOREVER) { |
| 229 | k_cancel_timer(&sub->timer); |
| 230 | k_term_timer(&sub->timer); |
| 231 | } |
Lijun Chen | eb40946 | 2006-10-16 21:59:42 -0700 | [diff] [blame] | 232 | subscr_del(sub); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 233 | } |
| 234 | |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 235 | /* Remove subscriber from topology server's subscriber list */ |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 236 | spin_lock_bh(&topsrv.lock); |
| 237 | list_del(&subscriber->subscriber_list); |
| 238 | spin_unlock_bh(&topsrv.lock); |
| 239 | |
Allan Stephens | 28353e7 | 2008-05-19 13:29:47 -0700 | [diff] [blame] | 240 | /* Reclaim subscriber lock */ |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 241 | spin_lock_bh(subscriber->lock); |
Allan Stephens | 28353e7 | 2008-05-19 13:29:47 -0700 | [diff] [blame] | 242 | |
| 243 | /* Now destroy subscriber */ |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 244 | kfree(subscriber); |
| 245 | } |
| 246 | |
| 247 | /** |
Lijun Chen | eb40946 | 2006-10-16 21:59:42 -0700 | [diff] [blame] | 248 | * subscr_cancel - handle subscription cancellation request |
| 249 | * |
Allan Stephens | 28353e7 | 2008-05-19 13:29:47 -0700 | [diff] [blame] | 250 | * Called with subscriber port locked. Routine must temporarily release lock |
Lijun Chen | eb40946 | 2006-10-16 21:59:42 -0700 | [diff] [blame] | 251 | * to enable the subscription timeout routine to finish without deadlocking; |
| 252 | * the lock is then reclaimed to allow caller to release it upon return. |
| 253 | * |
| 254 | * Note that fields of 's' use subscriber's endianness! |
| 255 | */ |
Lijun Chen | eb40946 | 2006-10-16 21:59:42 -0700 | [diff] [blame] | 256 | static void subscr_cancel(struct tipc_subscr *s, |
Paul Gortmaker | 11f9990 | 2011-12-29 20:49:39 -0500 | [diff] [blame] | 257 | struct tipc_subscriber *subscriber) |
Lijun Chen | eb40946 | 2006-10-16 21:59:42 -0700 | [diff] [blame] | 258 | { |
Paul Gortmaker | fead390 | 2011-12-29 20:43:44 -0500 | [diff] [blame] | 259 | struct tipc_subscription *sub; |
| 260 | struct tipc_subscription *sub_temp; |
Lijun Chen | eb40946 | 2006-10-16 21:59:42 -0700 | [diff] [blame] | 261 | int found = 0; |
| 262 | |
| 263 | /* Find first matching subscription, exit if not found */ |
Lijun Chen | eb40946 | 2006-10-16 21:59:42 -0700 | [diff] [blame] | 264 | list_for_each_entry_safe(sub, sub_temp, &subscriber->subscription_list, |
| 265 | subscription_list) { |
Neil Horman | db5a753 | 2010-10-21 01:06:16 +0000 | [diff] [blame] | 266 | if (!memcmp(s, &sub->evt.s, sizeof(struct tipc_subscr))) { |
| 267 | found = 1; |
| 268 | break; |
| 269 | } |
Lijun Chen | eb40946 | 2006-10-16 21:59:42 -0700 | [diff] [blame] | 270 | } |
| 271 | if (!found) |
| 272 | return; |
| 273 | |
| 274 | /* Cancel subscription timer (if used), then delete subscription */ |
Lijun Chen | eb40946 | 2006-10-16 21:59:42 -0700 | [diff] [blame] | 275 | if (sub->timeout != TIPC_WAIT_FOREVER) { |
| 276 | sub->timeout = TIPC_WAIT_FOREVER; |
| 277 | spin_unlock_bh(subscriber->lock); |
| 278 | k_cancel_timer(&sub->timer); |
| 279 | k_term_timer(&sub->timer); |
| 280 | spin_lock_bh(subscriber->lock); |
| 281 | } |
Lijun Chen | eb40946 | 2006-10-16 21:59:42 -0700 | [diff] [blame] | 282 | subscr_del(sub); |
| 283 | } |
| 284 | |
| 285 | /** |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 286 | * subscr_subscribe - create subscription for subscriber |
YOSHIFUJI Hideaki | c430728 | 2007-02-09 23:25:21 +0900 | [diff] [blame] | 287 | * |
Allan Stephens | 28353e7 | 2008-05-19 13:29:47 -0700 | [diff] [blame] | 288 | * Called with subscriber port locked. |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 289 | */ |
Paul Gortmaker | fead390 | 2011-12-29 20:43:44 -0500 | [diff] [blame] | 290 | static struct tipc_subscription *subscr_subscribe(struct tipc_subscr *s, |
Paul Gortmaker | 11f9990 | 2011-12-29 20:49:39 -0500 | [diff] [blame] | 291 | struct tipc_subscriber *subscriber) |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 292 | { |
Paul Gortmaker | fead390 | 2011-12-29 20:43:44 -0500 | [diff] [blame] | 293 | struct tipc_subscription *sub; |
Neil Horman | db5a753 | 2010-10-21 01:06:16 +0000 | [diff] [blame] | 294 | int swap; |
| 295 | |
| 296 | /* Determine subscriber's endianness */ |
Neil Horman | db5a753 | 2010-10-21 01:06:16 +0000 | [diff] [blame] | 297 | swap = !(s->filter & (TIPC_SUB_PORTS | TIPC_SUB_SERVICE)); |
Lijun Chen | eb40946 | 2006-10-16 21:59:42 -0700 | [diff] [blame] | 298 | |
| 299 | /* Detect & process a subscription cancellation request */ |
Neil Horman | db5a753 | 2010-10-21 01:06:16 +0000 | [diff] [blame] | 300 | if (s->filter & htohl(TIPC_SUB_CANCEL, swap)) { |
| 301 | s->filter &= ~htohl(TIPC_SUB_CANCEL, swap); |
Lijun Chen | eb40946 | 2006-10-16 21:59:42 -0700 | [diff] [blame] | 302 | subscr_cancel(s, subscriber); |
Allan Stephens | 28353e7 | 2008-05-19 13:29:47 -0700 | [diff] [blame] | 303 | return NULL; |
Lijun Chen | eb40946 | 2006-10-16 21:59:42 -0700 | [diff] [blame] | 304 | } |
| 305 | |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 306 | /* Refuse subscription if global limit exceeded */ |
Ying Xue | 34f256c | 2012-08-16 12:09:13 +0000 | [diff] [blame] | 307 | if (atomic_read(&topsrv.subscription_count) >= TIPC_MAX_SUBSCRIPTIONS) { |
Erik Hugne | 2cf8aa1 | 2012-06-29 00:16:37 -0400 | [diff] [blame] | 308 | pr_warn("Subscription rejected, limit reached (%u)\n", |
Ying Xue | 34f256c | 2012-08-16 12:09:13 +0000 | [diff] [blame] | 309 | TIPC_MAX_SUBSCRIPTIONS); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 310 | subscr_terminate(subscriber); |
Allan Stephens | 28353e7 | 2008-05-19 13:29:47 -0700 | [diff] [blame] | 311 | return NULL; |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 312 | } |
| 313 | |
| 314 | /* Allocate subscription object */ |
Allan Stephens | 28353e7 | 2008-05-19 13:29:47 -0700 | [diff] [blame] | 315 | sub = kmalloc(sizeof(*sub), GFP_ATOMIC); |
Allan Stephens | a10bd92 | 2006-06-25 23:52:17 -0700 | [diff] [blame] | 316 | if (!sub) { |
Erik Hugne | 2cf8aa1 | 2012-06-29 00:16:37 -0400 | [diff] [blame] | 317 | pr_warn("Subscription rejected, no memory\n"); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 318 | subscr_terminate(subscriber); |
Allan Stephens | 28353e7 | 2008-05-19 13:29:47 -0700 | [diff] [blame] | 319 | return NULL; |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 320 | } |
| 321 | |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 322 | /* Initialize subscription object */ |
Neil Horman | db5a753 | 2010-10-21 01:06:16 +0000 | [diff] [blame] | 323 | sub->seq.type = htohl(s->seq.type, swap); |
| 324 | sub->seq.lower = htohl(s->seq.lower, swap); |
| 325 | sub->seq.upper = htohl(s->seq.upper, swap); |
| 326 | sub->timeout = htohl(s->timeout, swap); |
| 327 | sub->filter = htohl(s->filter, swap); |
Neil Horman | 8c97443 | 2010-10-21 01:06:15 +0000 | [diff] [blame] | 328 | if ((!(sub->filter & TIPC_SUB_PORTS) == |
| 329 | !(sub->filter & TIPC_SUB_SERVICE)) || |
Joe Perches | f64f9e7 | 2009-11-29 16:55:45 -0800 | [diff] [blame] | 330 | (sub->seq.lower > sub->seq.upper)) { |
Erik Hugne | 2cf8aa1 | 2012-06-29 00:16:37 -0400 | [diff] [blame] | 331 | pr_warn("Subscription rejected, illegal request\n"); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 332 | kfree(sub); |
| 333 | subscr_terminate(subscriber); |
Allan Stephens | 28353e7 | 2008-05-19 13:29:47 -0700 | [diff] [blame] | 334 | return NULL; |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 335 | } |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 336 | INIT_LIST_HEAD(&sub->nameseq_list); |
| 337 | list_add(&sub->subscription_list, &subscriber->subscription_list); |
Allan Stephens | 28353e7 | 2008-05-19 13:29:47 -0700 | [diff] [blame] | 338 | sub->server_ref = subscriber->port_ref; |
Neil Horman | db5a753 | 2010-10-21 01:06:16 +0000 | [diff] [blame] | 339 | sub->swap = swap; |
Allan Stephens | 28353e7 | 2008-05-19 13:29:47 -0700 | [diff] [blame] | 340 | memcpy(&sub->evt.s, s, sizeof(struct tipc_subscr)); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 341 | atomic_inc(&topsrv.subscription_count); |
| 342 | if (sub->timeout != TIPC_WAIT_FOREVER) { |
| 343 | k_init_timer(&sub->timer, |
| 344 | (Handler)subscr_timeout, (unsigned long)sub); |
| 345 | k_start_timer(&sub->timer, sub->timeout); |
| 346 | } |
Allan Stephens | 28353e7 | 2008-05-19 13:29:47 -0700 | [diff] [blame] | 347 | |
| 348 | return sub; |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 349 | } |
| 350 | |
| 351 | /** |
| 352 | * subscr_conn_shutdown_event - handle termination request from subscriber |
Allan Stephens | 28353e7 | 2008-05-19 13:29:47 -0700 | [diff] [blame] | 353 | * |
| 354 | * Called with subscriber's server port unlocked. |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 355 | */ |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 356 | static void subscr_conn_shutdown_event(void *usr_handle, |
Allan Stephens | 28353e7 | 2008-05-19 13:29:47 -0700 | [diff] [blame] | 357 | u32 port_ref, |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 358 | struct sk_buff **buf, |
| 359 | unsigned char const *data, |
| 360 | unsigned int size, |
| 361 | int reason) |
| 362 | { |
Paul Gortmaker | 11f9990 | 2011-12-29 20:49:39 -0500 | [diff] [blame] | 363 | struct tipc_subscriber *subscriber = usr_handle; |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 364 | spinlock_t *subscriber_lock; |
| 365 | |
Allan Stephens | 28353e7 | 2008-05-19 13:29:47 -0700 | [diff] [blame] | 366 | if (tipc_port_lock(port_ref) == NULL) |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 367 | return; |
| 368 | |
| 369 | subscriber_lock = subscriber->lock; |
| 370 | subscr_terminate(subscriber); |
| 371 | spin_unlock_bh(subscriber_lock); |
| 372 | } |
| 373 | |
| 374 | /** |
| 375 | * subscr_conn_msg_event - handle new subscription request from subscriber |
Allan Stephens | 28353e7 | 2008-05-19 13:29:47 -0700 | [diff] [blame] | 376 | * |
| 377 | * Called with subscriber's server port unlocked. |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 378 | */ |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 379 | static void subscr_conn_msg_event(void *usr_handle, |
| 380 | u32 port_ref, |
| 381 | struct sk_buff **buf, |
| 382 | const unchar *data, |
| 383 | u32 size) |
| 384 | { |
Paul Gortmaker | 11f9990 | 2011-12-29 20:49:39 -0500 | [diff] [blame] | 385 | struct tipc_subscriber *subscriber = usr_handle; |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 386 | spinlock_t *subscriber_lock; |
Paul Gortmaker | fead390 | 2011-12-29 20:43:44 -0500 | [diff] [blame] | 387 | struct tipc_subscription *sub; |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 388 | |
Allan Stephens | 28353e7 | 2008-05-19 13:29:47 -0700 | [diff] [blame] | 389 | /* |
| 390 | * Lock subscriber's server port (& make a local copy of lock pointer, |
| 391 | * in case subscriber is deleted while processing subscription request) |
| 392 | */ |
Allan Stephens | 28353e7 | 2008-05-19 13:29:47 -0700 | [diff] [blame] | 393 | if (tipc_port_lock(port_ref) == NULL) |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 394 | return; |
| 395 | |
| 396 | subscriber_lock = subscriber->lock; |
YOSHIFUJI Hideaki | c430728 | 2007-02-09 23:25:21 +0900 | [diff] [blame] | 397 | |
Allan Stephens | 28353e7 | 2008-05-19 13:29:47 -0700 | [diff] [blame] | 398 | if (size != sizeof(struct tipc_subscr)) { |
| 399 | subscr_terminate(subscriber); |
| 400 | spin_unlock_bh(subscriber_lock); |
| 401 | } else { |
| 402 | sub = subscr_subscribe((struct tipc_subscr *)data, subscriber); |
| 403 | spin_unlock_bh(subscriber_lock); |
| 404 | if (sub != NULL) { |
| 405 | |
| 406 | /* |
| 407 | * We must release the server port lock before adding a |
| 408 | * subscription to the name table since TIPC needs to be |
| 409 | * able to (re)acquire the port lock if an event message |
| 410 | * issued by the subscription process is rejected and |
| 411 | * returned. The subscription cannot be deleted while |
| 412 | * it is being added to the name table because: |
| 413 | * a) the single-threading of the native API port code |
| 414 | * ensures the subscription cannot be cancelled and |
| 415 | * the subscriber connection cannot be broken, and |
| 416 | * b) the name table lock ensures the subscription |
| 417 | * timeout code cannot delete the subscription, |
| 418 | * so the subscription object is still protected. |
| 419 | */ |
Allan Stephens | 28353e7 | 2008-05-19 13:29:47 -0700 | [diff] [blame] | 420 | tipc_nametbl_subscribe(sub); |
| 421 | } |
| 422 | } |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 423 | } |
| 424 | |
| 425 | /** |
| 426 | * subscr_named_msg_event - handle request to establish a new subscriber |
| 427 | */ |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 428 | static void subscr_named_msg_event(void *usr_handle, |
| 429 | u32 port_ref, |
| 430 | struct sk_buff **buf, |
| 431 | const unchar *data, |
| 432 | u32 size, |
YOSHIFUJI Hideaki | c430728 | 2007-02-09 23:25:21 +0900 | [diff] [blame] | 433 | u32 importance, |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 434 | struct tipc_portid const *orig, |
| 435 | struct tipc_name_seq const *dest) |
| 436 | { |
Paul Gortmaker | 11f9990 | 2011-12-29 20:49:39 -0500 | [diff] [blame] | 437 | struct tipc_subscriber *subscriber; |
Allan Stephens | 28353e7 | 2008-05-19 13:29:47 -0700 | [diff] [blame] | 438 | u32 server_port_ref; |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 439 | |
| 440 | /* Create subscriber object */ |
Paul Gortmaker | 11f9990 | 2011-12-29 20:49:39 -0500 | [diff] [blame] | 441 | subscriber = kzalloc(sizeof(struct tipc_subscriber), GFP_ATOMIC); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 442 | if (subscriber == NULL) { |
Erik Hugne | 2cf8aa1 | 2012-06-29 00:16:37 -0400 | [diff] [blame] | 443 | pr_warn("Subscriber rejected, no memory\n"); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 444 | return; |
| 445 | } |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 446 | INIT_LIST_HEAD(&subscriber->subscription_list); |
| 447 | INIT_LIST_HEAD(&subscriber->subscriber_list); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 448 | |
Allan Stephens | 28353e7 | 2008-05-19 13:29:47 -0700 | [diff] [blame] | 449 | /* Create server port & establish connection to subscriber */ |
Allan Stephens | b0c1e92 | 2010-12-31 18:59:22 +0000 | [diff] [blame] | 450 | tipc_createport(subscriber, |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 451 | importance, |
Sam Ravnborg | 1fc54d8 | 2006-03-20 22:36:47 -0800 | [diff] [blame] | 452 | NULL, |
| 453 | NULL, |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 454 | subscr_conn_shutdown_event, |
Sam Ravnborg | 1fc54d8 | 2006-03-20 22:36:47 -0800 | [diff] [blame] | 455 | NULL, |
| 456 | NULL, |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 457 | subscr_conn_msg_event, |
Sam Ravnborg | 1fc54d8 | 2006-03-20 22:36:47 -0800 | [diff] [blame] | 458 | NULL, |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 459 | &subscriber->port_ref); |
| 460 | if (subscriber->port_ref == 0) { |
Erik Hugne | 2cf8aa1 | 2012-06-29 00:16:37 -0400 | [diff] [blame] | 461 | pr_warn("Subscriber rejected, unable to create port\n"); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 462 | kfree(subscriber); |
| 463 | return; |
| 464 | } |
Paul Gortmaker | bc87911 | 2012-11-29 13:48:40 -0500 | [diff] [blame] | 465 | tipc_connect(subscriber->port_ref, orig); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 466 | |
Allan Stephens | 28353e7 | 2008-05-19 13:29:47 -0700 | [diff] [blame] | 467 | /* Lock server port (& save lock address for future use) */ |
Allan Stephens | 23dd4cc | 2011-01-07 11:43:40 -0500 | [diff] [blame] | 468 | subscriber->lock = tipc_port_lock(subscriber->port_ref)->lock; |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 469 | |
| 470 | /* Add subscriber to topology server's subscriber list */ |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 471 | spin_lock_bh(&topsrv.lock); |
| 472 | list_add(&subscriber->subscriber_list, &topsrv.subscriber_list); |
| 473 | spin_unlock_bh(&topsrv.lock); |
| 474 | |
Allan Stephens | 28353e7 | 2008-05-19 13:29:47 -0700 | [diff] [blame] | 475 | /* Unlock server port */ |
Allan Stephens | 28353e7 | 2008-05-19 13:29:47 -0700 | [diff] [blame] | 476 | server_port_ref = subscriber->port_ref; |
| 477 | spin_unlock_bh(subscriber->lock); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 478 | |
Allan Stephens | 28353e7 | 2008-05-19 13:29:47 -0700 | [diff] [blame] | 479 | /* Send an ACK- to complete connection handshaking */ |
Allan Stephens | 2689690 | 2011-04-21 10:42:07 -0500 | [diff] [blame] | 480 | tipc_send(server_port_ref, 0, NULL, 0); |
Allan Stephens | 28353e7 | 2008-05-19 13:29:47 -0700 | [diff] [blame] | 481 | |
| 482 | /* Handle optional subscription request */ |
Allan Stephens | 28353e7 | 2008-05-19 13:29:47 -0700 | [diff] [blame] | 483 | if (size != 0) { |
| 484 | subscr_conn_msg_event(subscriber, server_port_ref, |
| 485 | buf, data, size); |
| 486 | } |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 487 | } |
| 488 | |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 489 | int tipc_subscr_start(void) |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 490 | { |
| 491 | struct tipc_name_seq seq = {TIPC_TOP_SRV, TIPC_TOP_SRV, TIPC_TOP_SRV}; |
Allan Stephens | 52fe7b7 | 2010-11-30 12:01:00 +0000 | [diff] [blame] | 492 | int res; |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 493 | |
Ingo Molnar | 34af946 | 2006-06-27 02:53:55 -0700 | [diff] [blame] | 494 | spin_lock_init(&topsrv.lock); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 495 | INIT_LIST_HEAD(&topsrv.subscriber_list); |
| 496 | |
Allan Stephens | b0c1e92 | 2010-12-31 18:59:22 +0000 | [diff] [blame] | 497 | res = tipc_createport(NULL, |
YOSHIFUJI Hideaki | c430728 | 2007-02-09 23:25:21 +0900 | [diff] [blame] | 498 | TIPC_CRITICAL_IMPORTANCE, |
| 499 | NULL, |
| 500 | NULL, |
| 501 | NULL, |
| 502 | NULL, |
| 503 | subscr_named_msg_event, |
| 504 | NULL, |
| 505 | NULL, |
| 506 | &topsrv.setup_port); |
| 507 | if (res) |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 508 | goto failed; |
| 509 | |
Allan Stephens | c422f1b | 2011-11-02 15:49:40 -0400 | [diff] [blame] | 510 | res = tipc_publish(topsrv.setup_port, TIPC_NODE_SCOPE, &seq); |
Allan Stephens | aa70200 | 2010-12-31 18:59:21 +0000 | [diff] [blame] | 511 | if (res) { |
| 512 | tipc_deleteport(topsrv.setup_port); |
| 513 | topsrv.setup_port = 0; |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 514 | goto failed; |
Allan Stephens | aa70200 | 2010-12-31 18:59:21 +0000 | [diff] [blame] | 515 | } |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 516 | |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 517 | return 0; |
| 518 | |
| 519 | failed: |
Erik Hugne | 2cf8aa1 | 2012-06-29 00:16:37 -0400 | [diff] [blame] | 520 | pr_err("Failed to create subscription service\n"); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 521 | return res; |
| 522 | } |
| 523 | |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 524 | void tipc_subscr_stop(void) |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 525 | { |
Paul Gortmaker | 11f9990 | 2011-12-29 20:49:39 -0500 | [diff] [blame] | 526 | struct tipc_subscriber *subscriber; |
| 527 | struct tipc_subscriber *subscriber_temp; |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 528 | spinlock_t *subscriber_lock; |
| 529 | |
Allan Stephens | aa70200 | 2010-12-31 18:59:21 +0000 | [diff] [blame] | 530 | if (topsrv.setup_port) { |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 531 | tipc_deleteport(topsrv.setup_port); |
Allan Stephens | aa70200 | 2010-12-31 18:59:21 +0000 | [diff] [blame] | 532 | topsrv.setup_port = 0; |
| 533 | |
YOSHIFUJI Hideaki | c430728 | 2007-02-09 23:25:21 +0900 | [diff] [blame] | 534 | list_for_each_entry_safe(subscriber, subscriber_temp, |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 535 | &topsrv.subscriber_list, |
| 536 | subscriber_list) { |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 537 | subscriber_lock = subscriber->lock; |
Allan Stephens | 28353e7 | 2008-05-19 13:29:47 -0700 | [diff] [blame] | 538 | spin_lock_bh(subscriber_lock); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 539 | subscr_terminate(subscriber); |
| 540 | spin_unlock_bh(subscriber_lock); |
| 541 | } |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 542 | } |
| 543 | } |