47
47
#include "netlink.h"
48
48
#include "group.h"
49
49
50
- #define CONN_TIMEOUT_DEFAULT 8000 /* default connect timeout = 8s */
50
+ #define CONN_TIMEOUT_DEFAULT 8000 /* default connect timeout = 8s */
51
51
#define CONN_PROBING_INTV msecs_to_jiffies(3600000) /* [ms] => 1 h */
52
52
#define TIPC_FWD_MSG 1
53
53
#define TIPC_MAX_PORT 0xffffffff
@@ -80,7 +80,6 @@ struct sockaddr_pair {
80
80
* @publications: list of publications for port
81
81
* @blocking_link: address of the congested link we are currently sleeping on
82
82
* @pub_count: total # of publications port has made during its lifetime
83
- * @probing_state:
84
83
* @conn_timeout: the time we can wait for an unresponded setup request
85
84
* @dupl_rcvcnt: number of bytes counted twice, in both backlog and rcv queue
86
85
* @cong_link_cnt: number of congested links
@@ -102,8 +101,8 @@ struct tipc_sock {
102
101
struct list_head cong_links ;
103
102
struct list_head publications ;
104
103
u32 pub_count ;
105
- uint conn_timeout ;
106
104
atomic_t dupl_rcvcnt ;
105
+ u16 conn_timeout ;
107
106
bool probe_unacked ;
108
107
u16 cong_link_cnt ;
109
108
u16 snt_unacked ;
@@ -507,6 +506,9 @@ static void __tipc_shutdown(struct socket *sock, int error)
507
506
tipc_wait_for_cond (sock , & timeout , (!tsk -> cong_link_cnt &&
508
507
!tsk_conn_cong (tsk )));
509
508
509
+ /* Remove any pending SYN message */
510
+ __skb_queue_purge (& sk -> sk_write_queue );
511
+
510
512
/* Reject all unreceived messages, except on an active connection
511
513
* (which disconnects locally & sends a 'FIN+' to peer).
512
514
*/
@@ -1362,6 +1364,8 @@ static int __tipc_sendmsg(struct socket *sock, struct msghdr *m, size_t dlen)
1362
1364
rc = tipc_msg_build (hdr , m , 0 , dlen , mtu , & pkts );
1363
1365
if (unlikely (rc != dlen ))
1364
1366
return rc ;
1367
+ if (unlikely (syn && !tipc_msg_skb_clone (& pkts , & sk -> sk_write_queue )))
1368
+ return - ENOMEM ;
1365
1369
1366
1370
rc = tipc_node_xmit (net , & pkts , dnode , tsk -> portid );
1367
1371
if (unlikely (rc == - ELINKCONG )) {
@@ -1491,6 +1495,7 @@ static void tipc_sk_finish_conn(struct tipc_sock *tsk, u32 peer_port,
1491
1495
tipc_node_add_conn (net , peer_node , tsk -> portid , peer_port );
1492
1496
tsk -> max_pkt = tipc_node_get_mtu (net , peer_node , tsk -> portid );
1493
1497
tsk -> peer_caps = tipc_node_get_capabilities (net , peer_node );
1498
+ __skb_queue_purge (& sk -> sk_write_queue );
1494
1499
if (tsk -> peer_caps & TIPC_BLOCK_FLOWCTL )
1495
1500
return ;
1496
1501
@@ -1977,6 +1982,7 @@ static bool tipc_sk_filter_connect(struct tipc_sock *tsk, struct sk_buff *skb)
1977
1982
u32 oport = msg_origport (hdr );
1978
1983
u32 onode = msg_orignode (hdr );
1979
1984
int err = msg_errcode (hdr );
1985
+ unsigned long delay ;
1980
1986
1981
1987
if (unlikely (msg_mcast (hdr )))
1982
1988
return false;
@@ -2001,8 +2007,18 @@ static bool tipc_sk_filter_connect(struct tipc_sock *tsk, struct sk_buff *skb)
2001
2007
if (oport != pport || onode != pnode )
2002
2008
return false;
2003
2009
2004
- /* Rejected SYN - abort */
2005
- break ;
2010
+ /* Rejected SYN */
2011
+ if (err != TIPC_ERR_OVERLOAD )
2012
+ break ;
2013
+
2014
+ /* Prepare for new setup attempt if we have a SYN clone */
2015
+ if (skb_queue_empty (& sk -> sk_write_queue ))
2016
+ break ;
2017
+ get_random_bytes (& delay , 2 );
2018
+ delay %= (tsk -> conn_timeout / 4 );
2019
+ delay = msecs_to_jiffies (delay + 100 );
2020
+ sk_reset_timer (sk , & sk -> sk_timer , jiffies + delay );
2021
+ return false;
2006
2022
case TIPC_OPEN :
2007
2023
case TIPC_DISCONNECTING :
2008
2024
return false;
@@ -2561,12 +2577,26 @@ static void tipc_sk_check_probing_state(struct sock *sk,
2561
2577
sk_reset_timer (sk , & sk -> sk_timer , jiffies + CONN_PROBING_INTV );
2562
2578
}
2563
2579
2580
+ static void tipc_sk_retry_connect (struct sock * sk , struct sk_buff_head * list )
2581
+ {
2582
+ struct tipc_sock * tsk = tipc_sk (sk );
2583
+
2584
+ /* Try again later if dest link is congested */
2585
+ if (tsk -> cong_link_cnt ) {
2586
+ sk_reset_timer (sk , & sk -> sk_timer , msecs_to_jiffies (100 ));
2587
+ return ;
2588
+ }
2589
+ /* Prepare SYN for retransmit */
2590
+ tipc_msg_skb_clone (& sk -> sk_write_queue , list );
2591
+ }
2592
+
2564
2593
static void tipc_sk_timeout (struct timer_list * t )
2565
2594
{
2566
2595
struct sock * sk = from_timer (sk , t , sk_timer );
2567
2596
struct tipc_sock * tsk = tipc_sk (sk );
2568
2597
u32 pnode = tsk_peer_node (tsk );
2569
2598
struct sk_buff_head list ;
2599
+ int rc = 0 ;
2570
2600
2571
2601
skb_queue_head_init (& list );
2572
2602
bh_lock_sock (sk );
@@ -2580,12 +2610,19 @@ static void tipc_sk_timeout(struct timer_list *t)
2580
2610
2581
2611
if (sk -> sk_state == TIPC_ESTABLISHED )
2582
2612
tipc_sk_check_probing_state (sk , & list );
2613
+ else if (sk -> sk_state == TIPC_CONNECTING )
2614
+ tipc_sk_retry_connect (sk , & list );
2583
2615
2584
2616
bh_unlock_sock (sk );
2585
2617
2586
2618
if (!skb_queue_empty (& list ))
2587
- tipc_node_xmit (sock_net (sk ), & list , pnode , tsk -> portid );
2619
+ rc = tipc_node_xmit (sock_net (sk ), & list , pnode , tsk -> portid );
2588
2620
2621
+ /* SYN messages may cause link congestion */
2622
+ if (rc == - ELINKCONG ) {
2623
+ tipc_dest_push (& tsk -> cong_links , pnode , 0 );
2624
+ tsk -> cong_link_cnt = 1 ;
2625
+ }
2589
2626
sock_put (sk );
2590
2627
}
2591
2628
0 commit comments