Skip to content

Commit 31c4f4c

Browse files
LUU Duc Canhdavem330
authored andcommitted
tipc: improve broadcast retransmission algorithm
Currently, the broadcast retransmission algorithm is using the 'prev_retr' field in struct tipc_link to time stamp the latest broadcast retransmission occasion. This helps to restrict retransmission of individual broadcast packets to max once per 10 milliseconds, even though all other criteria for retransmission are met. We now move this time stamp to the control block of each individual packet, and remove other limiting criteria. This simplifies the retransmission algorithm, and eliminates any risk of logical errors in selecting which packets can be retransmitted. Acked-by: Ying Xue <ying.xue@windriver.com> Signed-off-by: LUU Duc Canh <canh.d.luu@dektech.com.au> Signed-off-by: Jon Maloy <jon.maloy@ericsson.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent bb5e6a8 commit 31c4f4c

File tree

2 files changed

+14
-46
lines changed

2 files changed

+14
-46
lines changed

net/tipc/link.c

Lines changed: 13 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ struct tipc_stats {
105105
* @transmitq: queue for sent, non-acked messages
106106
* @backlogq: queue for messages waiting to be sent
107107
* @snt_nxt: next sequence number to use for outbound messages
108-
* @last_retransmitted: sequence number of most recently retransmitted message
108+
* @prev_from: sequence number of most previous retransmission request
109109
* @stale_cnt: counter for number of identical retransmit attempts
110110
* @stale_limit: time when repeated identical retransmits must force link reset
111111
* @ackers: # of peers that needs to ack each packet before it can be released
@@ -163,7 +163,7 @@ struct tipc_link {
163163
u16 limit;
164164
} backlog[5];
165165
u16 snd_nxt;
166-
u16 last_retransm;
166+
u16 prev_from;
167167
u16 window;
168168
u16 stale_cnt;
169169
unsigned long stale_limit;
@@ -186,9 +186,6 @@ struct tipc_link {
186186
u16 acked;
187187
struct tipc_link *bc_rcvlink;
188188
struct tipc_link *bc_sndlink;
189-
unsigned long prev_retr;
190-
u16 prev_from;
191-
u16 prev_to;
192189
u8 nack_state;
193190
bool bc_peer_is_up;
194191

@@ -210,7 +207,7 @@ enum {
210207
BC_NACK_SND_SUPPRESS,
211208
};
212209

213-
#define TIPC_BC_RETR_LIMIT 10 /* [ms] */
210+
#define TIPC_BC_RETR_LIM msecs_to_jiffies(10) /* [ms] */
214211

215212
/*
216213
* Interval between NACKs when packets arrive out of order
@@ -1036,10 +1033,12 @@ static int tipc_link_retrans(struct tipc_link *l, struct tipc_link *r,
10361033

10371034
if (!skb)
10381035
return 0;
1036+
if (less(to, from))
1037+
return 0;
10391038

10401039
/* Detect repeated retransmit failures on same packet */
1041-
if (r->last_retransm != buf_seqno(skb)) {
1042-
r->last_retransm = buf_seqno(skb);
1040+
if (r->prev_from != from) {
1041+
r->prev_from = from;
10431042
r->stale_limit = jiffies + msecs_to_jiffies(r->tolerance);
10441043
r->stale_cnt = 0;
10451044
} else if (++r->stale_cnt > 99 && time_after(jiffies, r->stale_limit)) {
@@ -1055,6 +1054,11 @@ static int tipc_link_retrans(struct tipc_link *l, struct tipc_link *r,
10551054
continue;
10561055
if (more(msg_seqno(hdr), to))
10571056
break;
1057+
if (link_is_bc_sndlink(l)) {
1058+
if (time_before(jiffies, TIPC_SKB_CB(skb)->nxt_retr))
1059+
continue;
1060+
TIPC_SKB_CB(skb)->nxt_retr = jiffies + TIPC_BC_RETR_LIM;
1061+
}
10581062
_skb = __pskb_copy(skb, MIN_H_SIZE, GFP_ATOMIC);
10591063
if (!_skb)
10601064
return 0;
@@ -1734,42 +1738,6 @@ void tipc_link_bc_init_rcv(struct tipc_link *l, struct tipc_msg *hdr)
17341738
l->rcv_nxt = peers_snd_nxt;
17351739
}
17361740

1737-
/* link_bc_retr eval()- check if the indicated range can be retransmitted now
1738-
* - Adjust permitted range if there is overlap with previous retransmission
1739-
*/
1740-
static bool link_bc_retr_eval(struct tipc_link *l, u16 *from, u16 *to)
1741-
{
1742-
unsigned long elapsed = jiffies_to_msecs(jiffies - l->prev_retr);
1743-
1744-
if (less(*to, *from))
1745-
return false;
1746-
1747-
/* New retransmission request */
1748-
if ((elapsed > TIPC_BC_RETR_LIMIT) ||
1749-
less(*to, l->prev_from) || more(*from, l->prev_to)) {
1750-
l->prev_from = *from;
1751-
l->prev_to = *to;
1752-
l->prev_retr = jiffies;
1753-
return true;
1754-
}
1755-
1756-
/* Inside range of previous retransmit */
1757-
if (!less(*from, l->prev_from) && !more(*to, l->prev_to))
1758-
return false;
1759-
1760-
/* Fully or partially outside previous range => exclude overlap */
1761-
if (less(*from, l->prev_from)) {
1762-
*to = l->prev_from - 1;
1763-
l->prev_from = *from;
1764-
}
1765-
if (more(*to, l->prev_to)) {
1766-
*from = l->prev_to + 1;
1767-
l->prev_to = *to;
1768-
}
1769-
l->prev_retr = jiffies;
1770-
return true;
1771-
}
1772-
17731741
/* tipc_link_bc_sync_rcv - update rcv link according to peer's send state
17741742
*/
17751743
int tipc_link_bc_sync_rcv(struct tipc_link *l, struct tipc_msg *hdr,
@@ -1800,8 +1768,7 @@ int tipc_link_bc_sync_rcv(struct tipc_link *l, struct tipc_msg *hdr,
18001768
if (more(peers_snd_nxt, l->rcv_nxt + l->window))
18011769
return rc;
18021770

1803-
if (link_bc_retr_eval(snd_l, &from, &to))
1804-
rc = tipc_link_retrans(snd_l, l, from, to, xmitq);
1771+
rc = tipc_link_retrans(snd_l, l, from, to, xmitq);
18051772

18061773
l->snd_nxt = peers_snd_nxt;
18071774
if (link_bc_rcv_gap(l))

net/tipc/msg.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ struct tipc_skb_cb {
105105
u32 bytes_read;
106106
u32 orig_member;
107107
struct sk_buff *tail;
108+
unsigned long nxt_retr;
108109
bool validated;
109110
u16 chain_imp;
110111
u16 ackers;

0 commit comments

Comments
 (0)