@@ -134,58 +134,36 @@ void tipc_subscrp_get(struct tipc_subscription *subscription)
134
134
kref_get (& subscription -> kref );
135
135
}
136
136
137
- static struct tipc_subscription * tipc_subscrp_create (struct tipc_server * srv ,
138
- struct tipc_subscr * s ,
139
- int conid )
137
+ struct tipc_subscription * tipc_sub_subscribe (struct tipc_server * srv ,
138
+ struct tipc_subscr * s ,
139
+ int conid )
140
140
{
141
141
struct tipc_net * tn = tipc_net (srv -> net );
142
142
struct tipc_subscription * sub ;
143
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_SUBSCRIPTIONS ) {
147
- pr_warn ("Subscription rejected, limit reached (%u)\n" ,
148
- TIPC_MAX_SUBSCRIPTIONS );
146
+ if (atomic_read (& tn -> subscription_count ) >= TIPC_MAX_SUBSCR ) {
147
+ pr_warn ("Subscription rejected, max (%u)\n" , TIPC_MAX_SUBSCR );
148
+ return NULL ;
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
153
return NULL ;
150
154
}
151
-
152
- /* Allocate subscription object */
153
155
sub = kmalloc (sizeof (* sub ), GFP_ATOMIC );
154
156
if (!sub ) {
155
157
pr_warn ("Subscription rejected, no memory\n" );
156
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
160
sub -> server = srv ;
165
161
sub -> conid = conid ;
166
162
sub -> inactive = false;
167
163
memcpy (& sub -> evt .s , s , sizeof (* s ));
168
164
spin_lock_init (& sub -> lock );
169
165
atomic_inc (& tn -> subscription_count );
170
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
167
tipc_nametbl_subscribe (sub );
190
168
timer_setup (& sub -> timer , tipc_subscrp_timeout , 0 );
191
169
timeout = tipc_sub_read (& sub -> evt .s , timeout );
@@ -194,7 +172,7 @@ struct tipc_subscription *tipc_subscrp_subscribe(struct tipc_server *srv,
194
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
177
tipc_nametbl_unsubscribe (sub );
200
178
if (sub -> evt .s .timeout != TIPC_WAIT_FOREVER )
0 commit comments