Skip to content

Commit 1dc68c1

Browse files
lxindavem330
authored andcommitted
sctp: do state transition when PROBE_COUNT == MAX_PROBES on HB send path
The state transition is described in rfc8899#section-5.2, PROBE_COUNT == MAX_PROBES means the probe fails for MAX times, and the state transition includes: - Base -> Error, occurs when BASE_PLPMTU Confirmation Fails, pl.pmtu is set to SCTP_MIN_PLPMTU, probe_size is still SCTP_BASE_PLPMTU; - Search -> Base, occurs when Black Hole Detected, pl.pmtu is set to SCTP_BASE_PLPMTU, probe_size is set back to SCTP_BASE_PLPMTU; - Search Complete -> Base, occurs when Black Hole Detected pl.pmtu is set to SCTP_BASE_PLPMTU, probe_size is set back to SCTP_BASE_PLPMTU; Note a black hole is encountered when a sender is unaware that packets are not being delivered to the destination endpoint. So it includes the probe failures with equal probe_size to pl.pmtu, and definitely not include that with greater probe_size than pl.pmtu. The later one is the normal probe failure where probe_size should decrease back to pl.pmtu and pl.probe_high is set. pl.probe_high would be used on HB ACK recv path in the next patch. Signed-off-by: Xin Long <lucien.xin@gmail.com> Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent fe59379 commit 1dc68c1

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

include/net/sctp/structs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,6 +1023,7 @@ bool sctp_transport_update_pmtu(struct sctp_transport *t, u32 pmtu);
10231023
void sctp_transport_immediate_rtx(struct sctp_transport *);
10241024
void sctp_transport_dst_release(struct sctp_transport *t);
10251025
void sctp_transport_dst_confirm(struct sctp_transport *t);
1026+
void sctp_transport_pl_send(struct sctp_transport *t);
10261027

10271028

10281029
/* This is the structure we use to queue packets as they come into

net/sctp/sm_statefuns.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,6 +1109,8 @@ enum sctp_disposition sctp_sf_send_probe(struct net *net,
11091109
if (!sctp_transport_pl_enabled(transport))
11101110
return SCTP_DISPOSITION_CONSUME;
11111111

1112+
sctp_transport_pl_send(transport);
1113+
11121114
reply = sctp_make_heartbeat(asoc, transport, transport->pl.probe_size);
11131115
if (!reply)
11141116
return SCTP_DISPOSITION_NOMEM;

net/sctp/transport.c

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,50 @@ void sctp_transport_pmtu(struct sctp_transport *transport, struct sock *sk)
261261
transport->pathmtu = SCTP_DEFAULT_MAXSEGMENT;
262262
}
263263

264+
void sctp_transport_pl_send(struct sctp_transport *t)
265+
{
266+
pr_debug("%s: PLPMTUD: transport: %p, state: %d, pmtu: %d, size: %d, high: %d\n",
267+
__func__, t, t->pl.state, t->pl.pmtu, t->pl.probe_size, t->pl.probe_high);
268+
269+
if (t->pl.probe_count < SCTP_MAX_PROBES) {
270+
t->pl.probe_count++;
271+
return;
272+
}
273+
274+
if (t->pl.state == SCTP_PL_BASE) {
275+
if (t->pl.probe_size == SCTP_BASE_PLPMTU) { /* BASE_PLPMTU Confirmation Failed */
276+
t->pl.state = SCTP_PL_ERROR; /* Base -> Error */
277+
278+
t->pl.pmtu = SCTP_MIN_PLPMTU;
279+
t->pathmtu = t->pl.pmtu + sctp_transport_pl_hlen(t);
280+
sctp_assoc_sync_pmtu(t->asoc);
281+
}
282+
} else if (t->pl.state == SCTP_PL_SEARCH) {
283+
if (t->pl.pmtu == t->pl.probe_size) { /* Black Hole Detected */
284+
t->pl.state = SCTP_PL_BASE; /* Search -> Base */
285+
t->pl.probe_size = SCTP_BASE_PLPMTU;
286+
t->pl.probe_high = 0;
287+
288+
t->pl.pmtu = SCTP_BASE_PLPMTU;
289+
t->pathmtu = t->pl.pmtu + sctp_transport_pl_hlen(t);
290+
sctp_assoc_sync_pmtu(t->asoc);
291+
} else { /* Normal probe failure. */
292+
t->pl.probe_high = t->pl.probe_size;
293+
t->pl.probe_size = t->pl.pmtu;
294+
}
295+
} else if (t->pl.state == SCTP_PL_COMPLETE) {
296+
if (t->pl.pmtu == t->pl.probe_size) { /* Black Hole Detected */
297+
t->pl.state = SCTP_PL_BASE; /* Search Complete -> Base */
298+
t->pl.probe_size = SCTP_BASE_PLPMTU;
299+
300+
t->pl.pmtu = SCTP_BASE_PLPMTU;
301+
t->pathmtu = t->pl.pmtu + sctp_transport_pl_hlen(t);
302+
sctp_assoc_sync_pmtu(t->asoc);
303+
}
304+
}
305+
t->pl.probe_count = 1;
306+
}
307+
264308
bool sctp_transport_update_pmtu(struct sctp_transport *t, u32 pmtu)
265309
{
266310
struct dst_entry *dst = sctp_transport_dst_check(t);

0 commit comments

Comments
 (0)