1
1
/*
2
2
* net/tipc/link.c: TIPC link code
3
3
*
4
- * Copyright (c) 1996-2007, 2012, Ericsson AB
4
+ * Copyright (c) 1996-2007, 2012-2014 , Ericsson AB
5
5
* Copyright (c) 2004-2007, 2010-2013, Wind River Systems
6
6
* All rights reserved.
7
7
*
@@ -78,16 +78,15 @@ static const char *link_unk_evt = "Unknown link event ";
78
78
static void link_handle_out_of_seq_msg (struct tipc_link * l_ptr ,
79
79
struct sk_buff * buf );
80
80
static void link_recv_proto_msg (struct tipc_link * l_ptr , struct sk_buff * buf );
81
- static int link_recv_changeover_msg (struct tipc_link * * l_ptr ,
82
- struct sk_buff * * buf );
81
+ static int tipc_link_tunnel_rcv (struct tipc_link * * l_ptr ,
82
+ struct sk_buff * * buf );
83
83
static void link_set_supervision_props (struct tipc_link * l_ptr , u32 tolerance );
84
84
static int link_send_sections_long (struct tipc_port * sender ,
85
85
struct iovec const * msg_sect ,
86
86
unsigned int len , u32 destnode );
87
87
static void link_state_event (struct tipc_link * l_ptr , u32 event );
88
88
static void link_reset_statistics (struct tipc_link * l_ptr );
89
89
static void link_print (struct tipc_link * l_ptr , const char * str );
90
- static void link_start (struct tipc_link * l_ptr );
91
90
static int link_send_long_buf (struct tipc_link * l_ptr , struct sk_buff * buf );
92
91
static void tipc_link_send_sync (struct tipc_link * l );
93
92
static void tipc_link_recv_sync (struct tipc_node * n , struct sk_buff * buf );
@@ -278,9 +277,11 @@ struct tipc_link *tipc_link_create(struct tipc_node *n_ptr,
278
277
279
278
tipc_node_attach_link (n_ptr , l_ptr );
280
279
281
- k_init_timer (& l_ptr -> timer , (Handler )link_timeout , (unsigned long )l_ptr );
280
+ k_init_timer (& l_ptr -> timer , (Handler )link_timeout ,
281
+ (unsigned long )l_ptr );
282
282
list_add_tail (& l_ptr -> link_list , & b_ptr -> links );
283
- tipc_k_signal ((Handler )link_start , (unsigned long )l_ptr );
283
+
284
+ link_state_event (l_ptr , STARTING_EVT );
284
285
285
286
return l_ptr ;
286
287
}
@@ -305,19 +306,13 @@ void tipc_link_delete(struct tipc_link *l_ptr)
305
306
tipc_node_lock (l_ptr -> owner );
306
307
tipc_link_reset (l_ptr );
307
308
tipc_node_detach_link (l_ptr -> owner , l_ptr );
308
- tipc_link_stop (l_ptr );
309
+ tipc_link_purge_queues (l_ptr );
309
310
list_del_init (& l_ptr -> link_list );
310
311
tipc_node_unlock (l_ptr -> owner );
311
312
k_term_timer (& l_ptr -> timer );
312
313
kfree (l_ptr );
313
314
}
314
315
315
- static void link_start (struct tipc_link * l_ptr )
316
- {
317
- tipc_node_lock (l_ptr -> owner );
318
- link_state_event (l_ptr , STARTING_EVT );
319
- tipc_node_unlock (l_ptr -> owner );
320
- }
321
316
322
317
/**
323
318
* link_schedule_port - schedule port for deferred sending
@@ -403,10 +398,10 @@ void tipc_link_reset_fragments(struct tipc_link *l_ptr)
403
398
}
404
399
405
400
/**
406
- * tipc_link_stop - purge all inbound and outbound messages associated with link
401
+ * tipc_link_purge_queues - purge all pkt queues associated with link
407
402
* @l_ptr: pointer to link
408
403
*/
409
- void tipc_link_stop (struct tipc_link * l_ptr )
404
+ void tipc_link_purge_queues (struct tipc_link * l_ptr )
410
405
{
411
406
kfree_skb_list (l_ptr -> oldest_deferred_in );
412
407
kfree_skb_list (l_ptr -> first_out );
@@ -437,8 +432,7 @@ void tipc_link_reset(struct tipc_link *l_ptr)
437
432
tipc_node_link_down (l_ptr -> owner , l_ptr );
438
433
tipc_bearer_remove_dest (l_ptr -> b_ptr , l_ptr -> addr );
439
434
440
- if (was_active_link && tipc_node_active_links (l_ptr -> owner ) &&
441
- l_ptr -> owner -> permit_changeover ) {
435
+ if (was_active_link && tipc_node_active_links (l_ptr -> owner )) {
442
436
l_ptr -> reset_checkpoint = checkpoint ;
443
437
l_ptr -> exp_msg_count = START_CHANGEOVER ;
444
438
}
@@ -1422,14 +1416,14 @@ static int link_recv_buf_validate(struct sk_buff *buf)
1422
1416
}
1423
1417
1424
1418
/**
1425
- * tipc_recv_msg - process TIPC messages arriving from off-node
1419
+ * tipc_rcv - process TIPC packets/ messages arriving from off-node
1426
1420
* @head: pointer to message buffer chain
1427
1421
* @tb_ptr: pointer to bearer message arrived on
1428
1422
*
1429
1423
* Invoked with no locks held. Bearer pointer must point to a valid bearer
1430
1424
* structure (i.e. cannot be NULL), but bearer can be inactive.
1431
1425
*/
1432
- void tipc_recv_msg (struct sk_buff * head , struct tipc_bearer * b_ptr )
1426
+ void tipc_rcv (struct sk_buff * head , struct tipc_bearer * b_ptr )
1433
1427
{
1434
1428
read_lock_bh (& tipc_net_lock );
1435
1429
while (head ) {
@@ -1603,7 +1597,7 @@ void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *b_ptr)
1603
1597
continue ;
1604
1598
case CHANGEOVER_PROTOCOL :
1605
1599
type = msg_type (msg );
1606
- if (link_recv_changeover_msg (& l_ptr , & buf )) {
1600
+ if (tipc_link_tunnel_rcv (& l_ptr , & buf )) {
1607
1601
msg = buf_msg (buf );
1608
1602
seq_no = msg_seqno (msg );
1609
1603
if (type == ORIGINAL_MSG )
@@ -1837,8 +1831,6 @@ static void link_recv_proto_msg(struct tipc_link *l_ptr, struct sk_buff *buf)
1837
1831
if (tipc_own_addr > msg_prevnode (msg ))
1838
1832
l_ptr -> b_ptr -> net_plane = msg_net_plane (msg );
1839
1833
1840
- l_ptr -> owner -> permit_changeover = msg_redundant_link (msg );
1841
-
1842
1834
switch (msg_type (msg )) {
1843
1835
1844
1836
case RESET_MSG :
@@ -1954,13 +1946,13 @@ static void link_recv_proto_msg(struct tipc_link *l_ptr, struct sk_buff *buf)
1954
1946
}
1955
1947
1956
1948
1957
- /*
1958
- * tipc_link_tunnel(): Send one message via a link belonging to
1959
- * another bearer. Owner node is locked.
1949
+ /* tipc_link_tunnel_xmit(): Tunnel one packet via a link belonging to
1950
+ * a different bearer. Owner node is locked.
1960
1951
*/
1961
- static void tipc_link_tunnel (struct tipc_link * l_ptr ,
1962
- struct tipc_msg * tunnel_hdr , struct tipc_msg * msg ,
1963
- u32 selector )
1952
+ static void tipc_link_tunnel_xmit (struct tipc_link * l_ptr ,
1953
+ struct tipc_msg * tunnel_hdr ,
1954
+ struct tipc_msg * msg ,
1955
+ u32 selector )
1964
1956
{
1965
1957
struct tipc_link * tunnel ;
1966
1958
struct sk_buff * buf ;
@@ -1983,12 +1975,13 @@ static void tipc_link_tunnel(struct tipc_link *l_ptr,
1983
1975
}
1984
1976
1985
1977
1986
-
1987
- /*
1988
- * changeover(): Send whole message queue via the remaining link
1989
- * Owner node is locked.
1978
+ /* tipc_link_failover_send_queue(): A link has gone down, but a second
1979
+ * link is still active. We can do failover. Tunnel the failing link's
1980
+ * whole send queue via the remaining link. This way, we don't lose
1981
+ * any packets, and sequence order is preserved for subsequent traffic
1982
+ * sent over the remaining link. Owner node is locked.
1990
1983
*/
1991
- void tipc_link_changeover (struct tipc_link * l_ptr )
1984
+ void tipc_link_failover_send_queue (struct tipc_link * l_ptr )
1992
1985
{
1993
1986
u32 msgcount = l_ptr -> out_queue_size ;
1994
1987
struct sk_buff * crs = l_ptr -> first_out ;
@@ -1999,11 +1992,6 @@ void tipc_link_changeover(struct tipc_link *l_ptr)
1999
1992
if (!tunnel )
2000
1993
return ;
2001
1994
2002
- if (!l_ptr -> owner -> permit_changeover ) {
2003
- pr_warn ("%speer did not permit changeover\n" , link_co_err );
2004
- return ;
2005
- }
2006
-
2007
1995
tipc_msg_init (& tunnel_hdr , CHANGEOVER_PROTOCOL ,
2008
1996
ORIGINAL_MSG , INT_H_SIZE , l_ptr -> addr );
2009
1997
msg_set_bearer_id (& tunnel_hdr , l_ptr -> peer_bearer_id );
@@ -2037,20 +2025,30 @@ void tipc_link_changeover(struct tipc_link *l_ptr)
2037
2025
msgcount = msg_msgcnt (msg );
2038
2026
while (msgcount -- ) {
2039
2027
msg_set_seqno (m , msg_seqno (msg ));
2040
- tipc_link_tunnel (l_ptr , & tunnel_hdr , m ,
2041
- msg_link_selector (m ));
2028
+ tipc_link_tunnel_xmit (l_ptr , & tunnel_hdr , m ,
2029
+ msg_link_selector (m ));
2042
2030
pos += align (msg_size (m ));
2043
2031
m = (struct tipc_msg * )pos ;
2044
2032
}
2045
2033
} else {
2046
- tipc_link_tunnel (l_ptr , & tunnel_hdr , msg ,
2047
- msg_link_selector (msg ));
2034
+ tipc_link_tunnel_xmit (l_ptr , & tunnel_hdr , msg ,
2035
+ msg_link_selector (msg ));
2048
2036
}
2049
2037
crs = crs -> next ;
2050
2038
}
2051
2039
}
2052
2040
2053
- void tipc_link_send_duplicate (struct tipc_link * l_ptr , struct tipc_link * tunnel )
2041
+ /* tipc_link_dup_send_queue(): A second link has become active. Tunnel a
2042
+ * duplicate of the first link's send queue via the new link. This way, we
2043
+ * are guaranteed that currently queued packets from a socket are delivered
2044
+ * before future traffic from the same socket, even if this is using the
2045
+ * new link. The last arriving copy of each duplicate packet is dropped at
2046
+ * the receiving end by the regular protocol check, so packet cardinality
2047
+ * and sequence order is preserved per sender/receiver socket pair.
2048
+ * Owner node is locked.
2049
+ */
2050
+ void tipc_link_dup_send_queue (struct tipc_link * l_ptr ,
2051
+ struct tipc_link * tunnel )
2054
2052
{
2055
2053
struct sk_buff * iter ;
2056
2054
struct tipc_msg tunnel_hdr ;
@@ -2106,12 +2104,14 @@ static struct sk_buff *buf_extract(struct sk_buff *skb, u32 from_pos)
2106
2104
return eb ;
2107
2105
}
2108
2106
2109
- /*
2110
- * link_recv_changeover_msg(): Receive tunneled packet sent
2111
- * via other link. Node is locked. Return extracted buffer.
2107
+ /* tipc_link_tunnel_rcv(): Receive a tunneled packet, sent
2108
+ * via other link as result of a failover (ORIGINAL_MSG) or
2109
+ * a new active link (DUPLICATE_MSG). Failover packets are
2110
+ * returned to the active link for delivery upwards.
2111
+ * Owner node is locked.
2112
2112
*/
2113
- static int link_recv_changeover_msg (struct tipc_link * * l_ptr ,
2114
- struct sk_buff * * buf )
2113
+ static int tipc_link_tunnel_rcv (struct tipc_link * * l_ptr ,
2114
+ struct sk_buff * * buf )
2115
2115
{
2116
2116
struct sk_buff * tunnel_buf = * buf ;
2117
2117
struct tipc_link * dest_link ;
0 commit comments