net/sctp/transport.c

Source file repositories/reference/linux-study-clean/net/sctp/transport.c

File Facts

System
Linux kernel
Corpus path
net/sctp/transport.c
Extension
.c
Size
26421 bytes
Lines
853
Domain
Networking Core
Bucket
Sockets, Protocols, Packet Path, And Network Policy
Inferred role
Networking Core: implementation source
Status
source implementation candidate

Why This File Exists

Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.

Dependency Surface

Detected Declarations

Annotated Snippet

if (t->pl.probe_size == SCTP_BASE_PLPMTU) { /* BASE_PLPMTU Confirmation Failed */
			t->pl.state = SCTP_PL_ERROR; /* Base -> Error */

			t->pl.pmtu = SCTP_BASE_PLPMTU;
			t->pathmtu = t->pl.pmtu + sctp_transport_pl_hlen(t);
			sctp_assoc_sync_pmtu(t->asoc);
		}
	} else if (t->pl.state == SCTP_PL_SEARCH) {
		if (t->pl.pmtu == t->pl.probe_size) { /* Black Hole Detected */
			t->pl.state = SCTP_PL_BASE;  /* Search -> Base */
			t->pl.probe_size = SCTP_BASE_PLPMTU;
			t->pl.probe_high = 0;

			t->pl.pmtu = SCTP_BASE_PLPMTU;
			t->pathmtu = t->pl.pmtu + sctp_transport_pl_hlen(t);
			sctp_assoc_sync_pmtu(t->asoc);
		} else { /* Normal probe failure. */
			t->pl.probe_high = t->pl.probe_size;
			t->pl.probe_size = t->pl.pmtu;
		}
	} else if (t->pl.state == SCTP_PL_COMPLETE) {
		if (t->pl.pmtu == t->pl.probe_size) { /* Black Hole Detected */
			t->pl.state = SCTP_PL_BASE;  /* Search Complete -> Base */
			t->pl.probe_size = SCTP_BASE_PLPMTU;

			t->pl.pmtu = SCTP_BASE_PLPMTU;
			t->pathmtu = t->pl.pmtu + sctp_transport_pl_hlen(t);
			sctp_assoc_sync_pmtu(t->asoc);
		}
	}

out:
	pr_debug("%s: PLPMTUD: transport: %p, state: %d, pmtu: %d, size: %d, high: %d\n",
		 __func__, t, t->pl.state, t->pl.pmtu, t->pl.probe_size, t->pl.probe_high);
	t->pl.probe_count++;
}

bool sctp_transport_pl_recv(struct sctp_transport *t)
{
	pr_debug("%s: PLPMTUD: transport: %p, state: %d, pmtu: %d, size: %d, high: %d\n",
		 __func__, t, t->pl.state, t->pl.pmtu, t->pl.probe_size, t->pl.probe_high);

	t->pl.pmtu = t->pl.probe_size;
	t->pl.probe_count = 0;
	if (t->pl.state == SCTP_PL_BASE) {
		t->pl.state = SCTP_PL_SEARCH; /* Base -> Search */
		t->pl.probe_size += SCTP_PL_BIG_STEP;
	} else if (t->pl.state == SCTP_PL_ERROR) {
		t->pl.state = SCTP_PL_SEARCH; /* Error -> Search */

		t->pl.pmtu = t->pl.probe_size;
		t->pathmtu = t->pl.pmtu + sctp_transport_pl_hlen(t);
		sctp_assoc_sync_pmtu(t->asoc);
		t->pl.probe_size += SCTP_PL_BIG_STEP;
	} else if (t->pl.state == SCTP_PL_SEARCH) {
		if (!t->pl.probe_high) {
			if (t->pl.probe_size < SCTP_MAX_PLPMTU) {
				t->pl.probe_size = min(t->pl.probe_size + SCTP_PL_BIG_STEP,
						       SCTP_MAX_PLPMTU);
				return false;
			}
			t->pl.probe_high = SCTP_MAX_PLPMTU;
		}
		t->pl.probe_size += SCTP_PL_MIN_STEP;
		if (t->pl.probe_size >= t->pl.probe_high) {
			t->pl.probe_high = 0;
			t->pl.state = SCTP_PL_COMPLETE; /* Search -> Search Complete */

			t->pl.probe_size = t->pl.pmtu;
			t->pathmtu = t->pl.pmtu + sctp_transport_pl_hlen(t);
			sctp_assoc_sync_pmtu(t->asoc);
			sctp_transport_reset_raise_timer(t);
		}
	} else if (t->pl.state == SCTP_PL_COMPLETE) {
		/* Raise probe_size again after 30 * interval in Search Complete */
		t->pl.state = SCTP_PL_SEARCH; /* Search Complete -> Search */
		t->pl.probe_size = min(t->pl.probe_size + SCTP_PL_MIN_STEP, SCTP_MAX_PLPMTU);
	}

	return t->pl.state == SCTP_PL_COMPLETE;
}

static bool sctp_transport_pl_toobig(struct sctp_transport *t, u32 pmtu)
{
	pr_debug("%s: PLPMTUD: transport: %p, state: %d, pmtu: %d, size: %d, ptb: %d\n",
		 __func__, t, t->pl.state, t->pl.pmtu, t->pl.probe_size, pmtu);

	if (pmtu < SCTP_MIN_PLPMTU || pmtu >= t->pl.probe_size)
		return false;

Annotation

Implementation Notes