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

Function sctp_handle_nat_colliding_state

freebsd/netinet/sctp_input.c:703–759  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

701}
702
703static int
704sctp_handle_nat_colliding_state(struct sctp_tcb *stcb)
705{
706 /*
707 * Return 0 means we want you to proceed with the abort non-zero
708 * means no abort processing.
709 */
710 uint32_t new_vtag;
711 struct sctpasochead *head;
712
713 if ((SCTP_GET_STATE(stcb) == SCTP_STATE_COOKIE_WAIT) ||
714 (SCTP_GET_STATE(stcb) == SCTP_STATE_COOKIE_ECHOED)) {
715 new_vtag = sctp_select_a_tag(stcb->sctp_ep, stcb->sctp_ep->sctp_lport, stcb->rport, 1);
716 atomic_add_int(&stcb->asoc.refcnt, 1);
717 SCTP_TCB_UNLOCK(stcb);
718 SCTP_INP_INFO_WLOCK();
719 SCTP_TCB_LOCK(stcb);
720 atomic_subtract_int(&stcb->asoc.refcnt, 1);
721 } else {
722 return (0);
723 }
724 if (SCTP_GET_STATE(stcb) == SCTP_STATE_COOKIE_WAIT) {
725 /* generate a new vtag and send init */
726 LIST_REMOVE(stcb, sctp_asocs);
727 stcb->asoc.my_vtag = new_vtag;
728 head = &SCTP_BASE_INFO(sctp_asochash)[SCTP_PCBHASH_ASOC(stcb->asoc.my_vtag, SCTP_BASE_INFO(hashasocmark))];
729 /*
730 * put it in the bucket in the vtag hash of assoc's for the
731 * system
732 */
733 LIST_INSERT_HEAD(head, stcb, sctp_asocs);
734 SCTP_INP_INFO_WUNLOCK();
735 sctp_send_initiate(stcb->sctp_ep, stcb, SCTP_SO_NOT_LOCKED);
736 return (1);
737 } else {
738 /*
739 * treat like a case where the cookie expired i.e.: - dump
740 * current cookie. - generate a new vtag. - resend init.
741 */
742 /* generate a new vtag and send init */
743 LIST_REMOVE(stcb, sctp_asocs);
744 SCTP_SET_STATE(stcb, SCTP_STATE_COOKIE_WAIT);
745 sctp_stop_all_cookie_timers(stcb);
746 sctp_toss_old_cookies(stcb, &stcb->asoc);
747 stcb->asoc.my_vtag = new_vtag;
748 head = &SCTP_BASE_INFO(sctp_asochash)[SCTP_PCBHASH_ASOC(stcb->asoc.my_vtag, SCTP_BASE_INFO(hashasocmark))];
749 /*
750 * put it in the bucket in the vtag hash of assoc's for the
751 * system
752 */
753 LIST_INSERT_HEAD(head, stcb, sctp_asocs);
754 SCTP_INP_INFO_WUNLOCK();
755 sctp_send_initiate(stcb->sctp_ep, stcb, SCTP_SO_NOT_LOCKED);
756 return (1);
757 }
758 return (0);
759}
760

Callers 2

sctp_handle_abortFunction · 0.85
sctp_handle_errorFunction · 0.85

Calls 4

sctp_select_a_tagFunction · 0.85
sctp_send_initiateFunction · 0.85
sctp_toss_old_cookiesFunction · 0.85

Tested by

no test coverage detected