@@ -142,6 +142,8 @@ struct tipc_node *tipc_node_create(struct net *net, u32 addr)
142
142
list_add_tail_rcu (& n_ptr -> list , & temp_node -> list );
143
143
n_ptr -> action_flags = TIPC_WAIT_PEER_LINKS_DOWN ;
144
144
n_ptr -> signature = INVALID_NODE_SIG ;
145
+ n_ptr -> active_links [0 ] = INVALID_BEARER_ID ;
146
+ n_ptr -> active_links [1 ] = INVALID_BEARER_ID ;
145
147
tipc_node_get (n_ptr );
146
148
exit :
147
149
spin_unlock_bh (& tn -> node_list_lock );
@@ -227,12 +229,13 @@ void tipc_node_remove_conn(struct net *net, u32 dnode, u32 port)
227
229
*/
228
230
void tipc_node_link_up (struct tipc_node * n , int bearer_id )
229
231
{
230
- struct tipc_link_entry * * actv = & n -> active_links [0 ];
231
- struct tipc_link_entry * le = & n -> links [bearer_id ];
232
- struct tipc_link * l = le -> link ;
232
+ int * slot0 = & n -> active_links [0 ];
233
+ int * slot1 = & n -> active_links [1 ];
234
+ struct tipc_link_entry * links = n -> links ;
235
+ struct tipc_link * l = n -> links [bearer_id ].link ;
233
236
234
237
/* Leave room for tunnel header when returning 'mtu' to users: */
235
- n -> links [bearer_id ].mtu = l -> mtu - INT_H_SIZE ;
238
+ links [bearer_id ].mtu = l -> mtu - INT_H_SIZE ;
236
239
237
240
n -> working_links ++ ;
238
241
n -> action_flags |= TIPC_NOTIFY_LINK_UP ;
@@ -242,88 +245,67 @@ void tipc_node_link_up(struct tipc_node *n, int bearer_id)
242
245
l -> name , l -> net_plane );
243
246
244
247
/* No active links ? => take both active slots */
245
- if (! actv [ 0 ] ) {
246
- actv [ 0 ] = le ;
247
- actv [ 1 ] = le ;
248
+ if (* slot0 < 0 ) {
249
+ * slot0 = bearer_id ;
250
+ * slot1 = bearer_id ;
248
251
node_established_contact (n );
249
252
return ;
250
253
}
251
- if (l -> priority < actv [0 ]-> link -> priority ) {
254
+
255
+ /* Lower prio than current active ? => no slot */
256
+ if (l -> priority < links [* slot0 ].link -> priority ) {
252
257
pr_debug ("New link <%s> becomes standby\n" , l -> name );
253
258
return ;
254
259
}
255
- tipc_link_dup_queue_xmit (actv [ 0 ] -> link , l );
260
+ tipc_link_dup_queue_xmit (links [ * slot0 ]. link , l );
256
261
257
- /* Take one active slot if applicable */
258
- if (l -> priority == actv [ 0 ] -> link -> priority ) {
259
- actv [ 0 ] = le ;
262
+ /* Same prio as current active ? => take one slot */
263
+ if (l -> priority == links [ * slot0 ]. link -> priority ) {
264
+ * slot0 = bearer_id ;
260
265
return ;
261
266
}
262
- /* Higher prio than current active? => take both active slots */
263
- pr_debug ("Old l <%s> becomes standby\n" , actv [0 ]-> link -> name );
264
- if (actv [1 ] != actv [0 ])
265
- pr_debug ("Old link <%s> now standby\n" , actv [1 ]-> link -> name );
266
- actv [0 ] = le ;
267
- actv [1 ] = le ;
268
- }
269
-
270
- /**
271
- * node_select_active_links - select which working links should be active
272
- */
273
- static void node_select_active_links (struct tipc_node * n )
274
- {
275
- struct tipc_link_entry * * actv = & n -> active_links [0 ];
276
- struct tipc_link * l ;
277
- u32 b , highest = 0 ;
278
267
279
- actv [0 ] = NULL ;
280
- actv [1 ] = NULL ;
281
-
282
- for (b = 0 ; b < MAX_BEARERS ; b ++ ) {
283
- l = n -> links [b ].link ;
284
- if (!l || !tipc_link_is_up (l ) || (l -> priority < highest ))
285
- continue ;
286
- if (l -> priority > highest ) {
287
- highest = l -> priority ;
288
- actv [0 ] = & n -> links [b ];
289
- actv [1 ] = & n -> links [b ];
290
- continue ;
291
- }
292
- actv [1 ] = & n -> links [b ];
293
- }
268
+ /* Higher prio than current active => take both active slots */
269
+ pr_debug ("Old link <%s> now standby\n" , links [* slot0 ].link -> name );
270
+ * slot0 = bearer_id ;
271
+ * slot1 = bearer_id ;
294
272
}
295
273
296
274
/**
297
275
* tipc_node_link_down - handle loss of link
298
276
*/
299
277
void tipc_node_link_down (struct tipc_node * n , int bearer_id )
300
278
{
301
- struct tipc_link_entry * * actv = & n -> active_links [0 ];
302
- struct tipc_link_entry * le = & n -> links [bearer_id ];
303
- struct tipc_link * l = le -> link ;
279
+ int * slot0 = & n -> active_links [0 ];
280
+ int * slot1 = & n -> active_links [1 ];
281
+ int i , highest = 0 ;
282
+ struct tipc_link * l , * _l ;
304
283
284
+ l = n -> links [bearer_id ].link ;
305
285
n -> working_links -- ;
306
286
n -> action_flags |= TIPC_NOTIFY_LINK_DOWN ;
307
287
n -> link_id = l -> peer_bearer_id << 16 | l -> bearer_id ;
308
288
309
- if (!tipc_link_is_active (l )) {
310
- pr_debug ("Lost standby link <%s> on network plane %c\n" ,
311
- l -> name , l -> net_plane );
312
- return ;
313
- }
314
289
pr_debug ("Lost link <%s> on network plane %c\n" ,
315
290
l -> name , l -> net_plane );
316
291
317
- /* Resdistribute active slots if applicable */
318
- if (actv [0 ] == le )
319
- actv [0 ] = actv [1 ];
320
- if (actv [1 ] == le )
321
- actv [1 ] = actv [0 ];
322
-
323
- /* Last link of this priority? => select other ones if available */
324
- if (actv [0 ] == le )
325
- node_select_active_links (n );
326
-
292
+ /* Select new active link if any available */
293
+ * slot0 = INVALID_BEARER_ID ;
294
+ * slot1 = INVALID_BEARER_ID ;
295
+ for (i = 0 ; i < MAX_BEARERS ; i ++ ) {
296
+ _l = n -> links [i ].link ;
297
+ if (!_l || !tipc_link_is_up (_l ))
298
+ continue ;
299
+ if (_l -> priority < highest )
300
+ continue ;
301
+ if (_l -> priority > highest ) {
302
+ highest = _l -> priority ;
303
+ * slot0 = i ;
304
+ * slot1 = i ;
305
+ continue ;
306
+ }
307
+ * slot1 = i ;
308
+ }
327
309
if (tipc_node_is_up (n ))
328
310
tipc_link_failover_send_queue (l );
329
311
else
@@ -332,7 +314,7 @@ void tipc_node_link_down(struct tipc_node *n, int bearer_id)
332
314
333
315
bool tipc_node_is_up (struct tipc_node * n )
334
316
{
335
- return n -> active_links [0 ];
317
+ return n -> active_links [0 ] != INVALID_BEARER_ID ;
336
318
}
337
319
338
320
void tipc_node_check_dest (struct tipc_node * n , struct tipc_bearer * b ,
0 commit comments