MCPcopy Create free account
hub / github.com/F-Stack/f-stack / sctp_cookie_timer

Function sctp_cookie_timer

freebsd/netinet/sctp_timer.c:1052–1115  ·  view source on GitHub ↗

* For cookie and asconf we actually need to find and mark for resend, then * increment the resend counter (after all the threshold management stuff of * course). */

Source from the content-addressed store, hash-verified

1050 * course).
1051 */
1052int
1053sctp_cookie_timer(struct sctp_inpcb *inp,
1054 struct sctp_tcb *stcb,
1055 struct sctp_nets *net SCTP_UNUSED)
1056{
1057 struct sctp_nets *alt;
1058 struct sctp_tmit_chunk *cookie;
1059
1060 /* first before all else we must find the cookie */
1061 TAILQ_FOREACH(cookie, &stcb->asoc.control_send_queue, sctp_next) {
1062 if (cookie->rec.chunk_id.id == SCTP_COOKIE_ECHO) {
1063 break;
1064 }
1065 }
1066 if (cookie == NULL) {
1067 if (SCTP_GET_STATE(stcb) == SCTP_STATE_COOKIE_ECHOED) {
1068 /* FOOBAR! */
1069 struct mbuf *op_err;
1070
1071 op_err = sctp_generate_cause(SCTP_BASE_SYSCTL(sctp_diag_info_code),
1072 "Cookie timer expired, but no cookie");
1073 inp->last_abort_code = SCTP_FROM_SCTP_TIMER + SCTP_LOC_3;
1074 sctp_abort_an_association(inp, stcb, op_err, SCTP_SO_NOT_LOCKED);
1075 } else {
1076#ifdef INVARIANTS
1077 panic("Cookie timer expires in wrong state?");
1078#else
1079 SCTP_PRINTF("Strange in state %d not cookie-echoed yet c-e timer expires?\n", SCTP_GET_STATE(stcb));
1080 return (0);
1081#endif
1082 }
1083 return (0);
1084 }
1085 /* Ok we found the cookie, threshold management next */
1086 if (sctp_threshold_management(inp, stcb, cookie->whoTo,
1087 stcb->asoc.max_init_times)) {
1088 /* Assoc is over */
1089 return (1);
1090 }
1091 /*
1092 * Cleared threshold management, now lets backoff the address and
1093 * select an alternate
1094 */
1095 stcb->asoc.dropped_special_cnt = 0;
1096 sctp_backoff_on_timeout(stcb, cookie->whoTo, 1, 0, 0);
1097 alt = sctp_find_alternate_net(stcb, cookie->whoTo, 0);
1098 if (alt != cookie->whoTo) {
1099 sctp_free_remote_addr(cookie->whoTo);
1100 cookie->whoTo = alt;
1101 atomic_add_int(&alt->ref_count, 1);
1102 }
1103 /* Now mark the retran info */
1104 if (cookie->sent != SCTP_DATAGRAM_RESEND) {
1105 sctp_ucount_incr(stcb->asoc.sent_queue_retran_cnt);
1106 }
1107 cookie->sent = SCTP_DATAGRAM_RESEND;
1108 cookie->flags |= CHUNK_FLAGS_FRAGMENT_OK;
1109 /*

Callers 1

sctp_timeout_handlerFunction · 0.85

Calls 6

sctp_generate_causeFunction · 0.85
sctp_backoff_on_timeoutFunction · 0.85
sctp_find_alternate_netFunction · 0.85
panicFunction · 0.50

Tested by

no test coverage detected