tipc: buffer overflow handling in listener socket
Default socket receive buffer size for a listener socket is 2Mb. For each arriving empty SYN, the linux kernel allocates a 768 bytes buffer. This means that a listener socket can serve maximum 2700 simultaneous empty connection setup requests before it hits a receive buffer overflow, and much fewer if the SYN is carrying any significant amount of data. When this happens the setup request is rejected, and the client receives an ECONNREFUSED error. This commit mitigates this problem by letting the client socket try to retransmit the SYN message multiple times when it sees it rejected with the code TIPC_ERR_OVERLOAD. Retransmission is done at random intervals in the range of [100 ms, setup_timeout / 4], as many times as there is room for within the setup timeout limit. Signed-off-by: Tung Nguyen <tung.q.nguyen@dektech.com.au> Acked-by: Ying Xue <ying.xue@windriver.com> Signed-off-by: Jon Maloy <jon.maloy@ericsson.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
25b9221b95
commit
6787927475
@@ -525,6 +525,10 @@ bool tipc_msg_reverse(u32 own_node, struct sk_buff **skb, int err)
|
||||
if (hlen == SHORT_H_SIZE)
|
||||
hlen = BASIC_H_SIZE;
|
||||
|
||||
/* Don't return data along with SYN+, - sender has a clone */
|
||||
if (msg_is_syn(_hdr) && err == TIPC_ERR_OVERLOAD)
|
||||
dlen = 0;
|
||||
|
||||
/* Allocate new buffer to return */
|
||||
*skb = tipc_buf_acquire(hlen + dlen, GFP_ATOMIC);
|
||||
if (!*skb)
|
||||
@@ -552,6 +556,22 @@ exit:
|
||||
return false;
|
||||
}
|
||||
|
||||
bool tipc_msg_skb_clone(struct sk_buff_head *msg, struct sk_buff_head *cpy)
|
||||
{
|
||||
struct sk_buff *skb, *_skb;
|
||||
|
||||
skb_queue_walk(msg, skb) {
|
||||
_skb = skb_clone(skb, GFP_ATOMIC);
|
||||
if (!_skb) {
|
||||
__skb_queue_purge(cpy);
|
||||
pr_err_ratelimited("Failed to clone buffer chain\n");
|
||||
return false;
|
||||
}
|
||||
__skb_queue_tail(cpy, _skb);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* tipc_msg_lookup_dest(): try to find new destination for named message
|
||||
* @skb: the buffer containing the message.
|
||||
|
||||
Reference in New Issue
Block a user