Two major items here:

- All printf that was surrounded by #ifdef SCTP_DEBUG moves to
  a macro that does all of this. This removes all printfs from
  the code and makes the code more portable and easier to
  read.
- Static Analysis (cisco) - found a few bugs, but mostly we
  add checks for NULL pointers and such to make the tool
  happy. We now pass the Cisco SA tools checks except for
  where it does not understand tailq/lists. We still need
  to look at the coverity tools output too (this is like
  the cisco SA tool) and see if it wants us to fix any other
  items. Hopefully this will be the last major churn in the
  code other than bug fixes.
This commit is contained in:
Randall Stewart 2007-05-09 13:30:06 +00:00
parent a39259958d
commit ad81507eed
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=169420
14 changed files with 1137 additions and 1816 deletions

View File

@ -50,7 +50,7 @@ __FBSDID("$FreeBSD$");
#endif /* SCTP_DEBUG */
static int
static void
sctp_asconf_get_source_ip(struct mbuf *m, struct sockaddr *sa)
{
struct ip *iph;
@ -70,7 +70,7 @@ sctp_asconf_get_source_ip(struct mbuf *m, struct sockaddr *sa)
sin->sin_len = sizeof(struct sockaddr_in);
sin->sin_port = 0;
sin->sin_addr.s_addr = iph->ip_src.s_addr;
return 0;
return;
}
#ifdef INET6
else if (iph->ip_v == (IPV6_VERSION >> 4)) {
@ -84,11 +84,11 @@ sctp_asconf_get_source_ip(struct mbuf *m, struct sockaddr *sa)
sin6->sin6_port = 0;
ip6 = mtod(m, struct ip6_hdr *);
sin6->sin6_addr = ip6->ip6_src;
return 0;
return;
}
#endif /* INET6 */
else
return -1;
return;
}
/*
@ -124,11 +124,8 @@ sctp_asconf_success_response(uint32_t id)
m_reply = sctp_get_mbuf_for_msg(sizeof(struct sctp_asconf_paramhdr),
0, M_DONTWAIT, 1, MT_DATA);
if (m_reply == NULL) {
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_ASCONF1) {
printf("asconf_success_response: couldn't get mbuf!\n");
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_ASCONF1,
"asconf_success_response: couldn't get mbuf!\n");
return NULL;
}
aph = mtod(m_reply, struct sctp_asconf_paramhdr *);
@ -155,11 +152,8 @@ sctp_asconf_error_response(uint32_t id, uint16_t cause, uint8_t * error_tlv,
sizeof(struct sctp_error_cause)),
0, M_DONTWAIT, 1, MT_DATA);
if (m_reply == NULL) {
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_ASCONF1) {
printf("asconf_error_response: couldn't get mbuf!\n");
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_ASCONF1,
"asconf_error_response: couldn't get mbuf!\n");
return NULL;
}
aph = mtod(m_reply, struct sctp_asconf_paramhdr *);
@ -173,12 +167,9 @@ sctp_asconf_error_response(uint32_t id, uint16_t cause, uint8_t * error_tlv,
sizeof(struct sctp_asconf_paramhdr);
if (aph->ph.param_length > MLEN) {
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_ASCONF1) {
printf("asconf_error_response: tlv_length (%xh) too big\n",
tlv_length);
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_ASCONF1,
"asconf_error_response: tlv_length (%xh) too big\n",
tlv_length);
sctp_m_freem(m_reply); /* discard */
return NULL;
}
@ -234,12 +225,8 @@ sctp_process_asconf_add_ip(struct mbuf *m, struct sctp_asconf_paramhdr *aph,
sin->sin_addr.s_addr = v4addr->addr;
if (sin->sin_addr.s_addr == INADDR_ANY)
zero_address = 1;
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_ASCONF1) {
printf("process_asconf_add_ip: adding ");
sctp_print_address(sa);
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_ASCONF1, "process_asconf_add_ip: adding ");
SCTPDBG_ADDR(SCTP_DEBUG_ASCONF1, sa);
break;
case SCTP_IPV6_ADDRESS:
#ifdef INET6
@ -256,25 +243,18 @@ sctp_process_asconf_add_ip(struct mbuf *m, struct sctp_asconf_paramhdr *aph,
sizeof(struct in6_addr));
if (IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr))
zero_address = 1;
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_ASCONF1) {
printf("process_asconf_add_ip: adding ");
sctp_print_address(sa);
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_ASCONF1, "process_asconf_add_ip: adding ");
SCTPDBG_ADDR(SCTP_DEBUG_ASCONF1, sa);
#else
/* IPv6 not enabled! */
/* FIX ME: currently sends back an invalid param error */
m_reply = sctp_asconf_error_response(aph->correlation_id,
SCTP_CAUSE_INVALID_PARAM, (uint8_t *) aph, aparam_length);
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_ASCONF1) {
printf("process_asconf_add_ip: v6 disabled- skipping ");
sctp_print_address(sa);
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_ASCONF1,
"process_asconf_add_ip: v6 disabled- skipping ");
SCTPDBG_ADDR(SCTP_DEBUG_ASCONF1, sa);
return m_reply;
#endif /* INET6 */
#endif
break;
default:
m_reply = sctp_asconf_error_response(aph->correlation_id,
@ -287,21 +267,15 @@ sctp_process_asconf_add_ip(struct mbuf *m, struct sctp_asconf_paramhdr *aph,
if (zero_address && sctp_nat_friendly) {
sa = (struct sockaddr *)&sa_source;
sctp_asconf_get_source_ip(m, sa);
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_ASCONF1) {
printf("process_asconf_add_ip: using source addr ");
sctp_print_address(sa);
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_ASCONF1,
"process_asconf_add_ip: using source addr ");
SCTPDBG_ADDR(SCTP_DEBUG_ASCONF1, sa);
}
/* add the address */
if (sctp_add_remote_addr(stcb, sa, SCTP_DONOT_SETSCOPE,
SCTP_ADDR_DYNAMIC_ADDED) != 0) {
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_ASCONF1) {
printf("process_asconf_add_ip: error adding address\n");
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_ASCONF1,
"process_asconf_add_ip: error adding address\n");
m_reply = sctp_asconf_error_response(aph->correlation_id,
SCTP_CAUSE_RESOURCE_SHORTAGE, (uint8_t *) aph,
aparam_length);
@ -336,12 +310,10 @@ sctp_asconf_del_remote_addrs_except(struct sctp_tcb *stcb,
if (net != src_net) {
/* delete this address */
sctp_remove_net(stcb, net);
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_ASCONF1) {
printf("asconf_del_remote_addrs_except: deleting ");
sctp_print_address((struct sockaddr *)&net->ro._l_addr);
}
#endif
SCTPDBG(SCTP_DEBUG_ASCONF1,
"asconf_del_remote_addrs_except: deleting ");
SCTPDBG_ADDR(SCTP_DEBUG_ASCONF1,
(struct sockaddr *)&net->ro._l_addr);
/* notify upper layer */
sctp_ulp_notify(SCTP_NOTIFY_ASCONF_DELETE_IP, stcb, 0,
(struct sockaddr *)&net->ro._l_addr);
@ -395,12 +367,9 @@ sctp_process_asconf_delete_ip(struct mbuf *m, struct sctp_asconf_paramhdr *aph,
sin->sin_addr.s_addr = v4addr->addr;
if (sin->sin_addr.s_addr == INADDR_ANY)
zero_address = 1;
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_ASCONF1) {
printf("process_asconf_delete_ip: deleting ");
sctp_print_address(sa);
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_ASCONF1,
"process_asconf_delete_ip: deleting ");
SCTPDBG_ADDR(SCTP_DEBUG_ASCONF1, sa);
break;
case SCTP_IPV6_ADDRESS:
if (param_length != sizeof(struct sctp_ipv6addr_param)) {
@ -417,23 +386,17 @@ sctp_process_asconf_delete_ip(struct mbuf *m, struct sctp_asconf_paramhdr *aph,
sizeof(struct in6_addr));
if (IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr))
zero_address = 1;
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_ASCONF1) {
printf("process_asconf_delete_ip: deleting ");
sctp_print_address(sa);
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_ASCONF1,
"process_asconf_delete_ip: deleting ");
SCTPDBG_ADDR(SCTP_DEBUG_ASCONF1, sa);
#else
/* IPv6 not enabled! No "action" needed; just ack it */
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_ASCONF1) {
printf("process_asconf_delete_ip: v6 disabled- ignoring: ");
sctp_print_address(sa);
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_ASCONF1,
"process_asconf_delete_ip: v6 disabled- ignoring: ");
SCTPDBG_ADDR(SCTP_DEBUG_ASCONF1, sa);
/* just respond with a "success" ASCONF-ACK */
return NULL;
#endif /* INET6 */
#endif
break;
default:
m_reply = sctp_asconf_error_response(aph->correlation_id,
@ -445,11 +408,7 @@ sctp_process_asconf_delete_ip(struct mbuf *m, struct sctp_asconf_paramhdr *aph,
/* make sure the source address is not being deleted */
if (sctp_cmpaddr(sa, (struct sockaddr *)&sa_source)) {
/* trying to delete the source address! */
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_ASCONF1) {
printf("process_asconf_delete_ip: tried to delete source addr\n");
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_ASCONF1, "process_asconf_delete_ip: tried to delete source addr\n");
m_reply = sctp_asconf_error_response(aph->correlation_id,
SCTP_CAUSE_DELETING_SRC_ADDR, (uint8_t *) aph,
aparam_length);
@ -462,11 +421,7 @@ sctp_process_asconf_delete_ip(struct mbuf *m, struct sctp_asconf_paramhdr *aph,
if (result) {
/* src address did not exist? */
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_ASCONF1) {
printf("process_asconf_delete_ip: src addr does not exist?\n");
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_ASCONF1, "process_asconf_delete_ip: src addr does not exist?\n");
/* what error to reply with?? */
m_reply =
sctp_asconf_error_response(aph->correlation_id,
@ -487,11 +442,7 @@ sctp_process_asconf_delete_ip(struct mbuf *m, struct sctp_asconf_paramhdr *aph,
*/
if (result == -1) {
/* only one address in the asoc */
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_ASCONF1) {
printf("process_asconf_delete_ip: tried to delete last IP addr!\n");
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_ASCONF1, "process_asconf_delete_ip: tried to delete last IP addr!\n");
m_reply = sctp_asconf_error_response(aph->correlation_id,
SCTP_CAUSE_DELETING_LAST_ADDR, (uint8_t *) aph,
aparam_length);
@ -546,12 +497,8 @@ sctp_process_asconf_set_primary(struct mbuf *m,
sin->sin_addr.s_addr = v4addr->addr;
if (sin->sin_addr.s_addr == INADDR_ANY)
zero_address = 1;
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_ASCONF1) {
printf("process_asconf_set_primary: ");
sctp_print_address(sa);
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_ASCONF1, "process_asconf_set_primary: ");
SCTPDBG_ADDR(SCTP_DEBUG_ASCONF1, sa);
break;
case SCTP_IPV6_ADDRESS:
if (param_length != sizeof(struct sctp_ipv6addr_param)) {
@ -567,23 +514,16 @@ sctp_process_asconf_set_primary(struct mbuf *m,
sizeof(struct in6_addr));
if (IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr))
zero_address = 1;
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_ASCONF1) {
printf("process_asconf_set_primary: ");
sctp_print_address(sa);
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_ASCONF1, "process_asconf_set_primary: ");
SCTPDBG_ADDR(SCTP_DEBUG_ASCONF1, sa);
#else
/* IPv6 not enabled! No "action" needed; just ack it */
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_ASCONF1) {
printf("process_asconf_set_primary: v6 disabled- ignoring: ");
sctp_print_address(sa);
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_ASCONF1,
"process_asconf_set_primary: v6 disabled- ignoring: ");
SCTPDBG_ADDR(SCTP_DEBUG_ASCONF1, sa);
/* just respond with a "success" ASCONF-ACK */
return NULL;
#endif /* INET6 */
#endif
break;
default:
m_reply = sctp_asconf_error_response(aph->correlation_id,
@ -596,20 +536,14 @@ sctp_process_asconf_set_primary(struct mbuf *m,
if (zero_address && sctp_nat_friendly) {
sa = (struct sockaddr *)&sa_source;
sctp_asconf_get_source_ip(m, sa);
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_ASCONF1) {
printf("process_asconf_set_primary: using source addr ");
sctp_print_address(sa);
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_ASCONF1,
"process_asconf_set_primary: using source addr ");
SCTPDBG_ADDR(SCTP_DEBUG_ASCONF1, sa);
}
/* set the primary address */
if (sctp_set_primary_addr(stcb, sa, NULL) == 0) {
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_ASCONF1) {
printf("process_asconf_set_primary: primary address set\n");
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_ASCONF1,
"process_asconf_set_primary: primary address set\n");
/* notify upper layer */
sctp_ulp_notify(SCTP_NOTIFY_ASCONF_SET_PRIMARY, stcb, 0, sa);
@ -618,11 +552,8 @@ sctp_process_asconf_set_primary(struct mbuf *m,
}
} else {
/* couldn't set the requested primary address! */
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_ASCONF1) {
printf("process_asconf_set_primary: set primary failed!\n");
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_ASCONF1,
"process_asconf_set_primary: set primary failed!\n");
/* must have been an invalid address, so report */
m_reply = sctp_asconf_error_response(aph->correlation_id,
SCTP_CAUSE_UNRESOLVABLE_ADDR, (uint8_t *) aph,
@ -654,12 +585,9 @@ sctp_handle_asconf(struct mbuf *m, unsigned int offset,
/* verify minimum length */
if (ntohs(cp->ch.chunk_length) < sizeof(struct sctp_asconf_chunk)) {
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_ASCONF1) {
printf("handle_asconf: chunk too small = %xh\n",
ntohs(cp->ch.chunk_length));
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_ASCONF1,
"handle_asconf: chunk too small = %xh\n",
ntohs(cp->ch.chunk_length));
return;
}
asoc = &stcb->asoc;
@ -667,34 +595,24 @@ sctp_handle_asconf(struct mbuf *m, unsigned int offset,
if (serial_num == asoc->asconf_seq_in) {
/* got a duplicate ASCONF */
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_ASCONF1) {
printf("handle_asconf: got duplicate serial number = %xh\n",
serial_num);
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_ASCONF1,
"handle_asconf: got duplicate serial number = %xh\n",
serial_num);
/* resend last ASCONF-ACK... */
sctp_send_asconf_ack(stcb, 1);
return;
} else if (serial_num != (asoc->asconf_seq_in + 1)) {
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_ASCONF1) {
printf("handle_asconf: incorrect serial number = %xh (expected next = %xh)\n",
serial_num, asoc->asconf_seq_in + 1);
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_ASCONF1, "handle_asconf: incorrect serial number = %xh (expected next = %xh)\n",
serial_num, asoc->asconf_seq_in + 1);
return;
}
/* it's the expected "next" sequence number, so process it */
asoc->asconf_seq_in = serial_num; /* update sequence */
/* get length of all the param's in the ASCONF */
asconf_limit = offset + ntohs(cp->ch.chunk_length);
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_ASCONF1) {
printf("handle_asconf: asconf_limit=%u, sequence=%xh\n",
asconf_limit, serial_num);
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_ASCONF1,
"handle_asconf: asconf_limit=%u, sequence=%xh\n",
asconf_limit, serial_num);
if (asoc->last_asconf_ack_sent != NULL) {
/* free last ASCONF-ACK message sent */
sctp_m_freem(asoc->last_asconf_ack_sent);
@ -703,11 +621,8 @@ sctp_handle_asconf(struct mbuf *m, unsigned int offset,
m_ack = sctp_get_mbuf_for_msg(sizeof(struct sctp_asconf_ack_chunk), 0,
M_DONTWAIT, 1, MT_DATA);
if (m_ack == NULL) {
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_ASCONF1) {
printf("handle_asconf: couldn't get mbuf!\n");
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_ASCONF1,
"handle_asconf: couldn't get mbuf!\n");
return;
}
m_tail = m_ack; /* current reply chain's tail */
@ -725,12 +640,8 @@ sctp_handle_asconf(struct mbuf *m, unsigned int offset,
offset += sizeof(struct sctp_asconf_chunk);
p_addr = (struct sctp_ipv6addr_param *)sctp_m_getptr(m, offset, sizeof(struct sctp_paramhdr), (uint8_t *) & aparam_buf);
if (p_addr == NULL) {
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_ASCONF1) {
printf("handle_asconf: couldn't get lookup addr!\n");
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_ASCONF1,
"handle_asconf: couldn't get lookup addr!\n");
/* respond with a missing/invalid mandatory parameter error */
return;
}
@ -740,17 +651,13 @@ sctp_handle_asconf(struct mbuf *m, unsigned int offset,
/* get pointer to first asconf param in ASCONF-ACK */
ack_aph = (struct sctp_asconf_paramhdr *)(mtod(m_ack, caddr_t)+sizeof(struct sctp_asconf_ack_chunk));
if (ack_aph == NULL) {
#ifdef SCTP_DEBUG
printf("Gak in asconf2\n");
#endif
SCTPDBG(SCTP_DEBUG_ASCONF1, "Gak in asconf2\n");
return;
}
/* get pointer to first asconf param in ASCONF */
aph = (struct sctp_asconf_paramhdr *)sctp_m_getptr(m, offset, sizeof(struct sctp_asconf_paramhdr), (uint8_t *) & aparam_buf);
if (aph == NULL) {
#ifdef SCTP_DEBUG
printf("Empty ASCONF received?\n");
#endif
SCTPDBG(SCTP_DEBUG_ASCONF1, "Empty ASCONF received?\n");
goto send_reply;
}
/* process through all parameters */
@ -767,28 +674,18 @@ sctp_handle_asconf(struct mbuf *m, unsigned int offset,
m_result = NULL;
if (param_length > sizeof(aparam_buf)) {
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_ASCONF1) {
printf("handle_asconf: param length (%u) larger than buffer size!\n", param_length);
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_ASCONF1, "handle_asconf: param length (%u) larger than buffer size!\n", param_length);
sctp_m_freem(m_ack);
return;
}
if (param_length <= sizeof(struct sctp_paramhdr)) {
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_ASCONF1) {
printf("handle_asconf: param length (%u) too short\n", param_length);
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_ASCONF1, "handle_asconf: param length (%u) too short\n", param_length);
sctp_m_freem(m_ack);
}
/* get the entire parameter */
aph = (struct sctp_asconf_paramhdr *)sctp_m_getptr(m, offset, param_length, aparam_buf);
if (aph == NULL) {
#ifdef SCTP_DEBUG
printf("Gag\n");
#endif
SCTPDBG(SCTP_DEBUG_ASCONF1, "handle_asconf: couldn't get entire param\n");
sctp_m_freem(m_ack);
return;
}
@ -856,14 +753,10 @@ sctp_handle_asconf(struct mbuf *m, unsigned int offset,
(uint8_t *) & aparam_buf);
if (aph == NULL) {
/* can't get an asconf paramhdr */
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_ASCONF1) {
printf("handle_asconf: can't get asconf param hdr!\n");
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_ASCONF1, "handle_asconf: can't get asconf param hdr!\n");
/* FIX ME - add error here... */
}
} /* while */
}
send_reply:
ack_cp->ch.chunk_length = htons(ack_cp->ch.chunk_length);
@ -881,10 +774,7 @@ sctp_handle_asconf(struct mbuf *m, unsigned int offset,
struct sockaddr_storage from_store;
struct sockaddr *from = (struct sockaddr *)&from_store;
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_ASCONF1)
printf("handle_asconf: looking up net for IP source address\n");
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_ASCONF1, "handle_asconf: looking up net for IP source address\n");
/* pullup already done, IP options already stripped */
iph = mtod(m, struct ip *);
sh = (struct sctphdr *)((caddr_t)iph + sizeof(*iph));
@ -917,19 +807,14 @@ sctp_handle_asconf(struct mbuf *m, unsigned int offset,
from = NULL;
}
if (from != NULL) {
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_ASCONF1) {
printf("Looking for IP source: ");
sctp_print_address(from);
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_ASCONF1, "Looking for IP source: ");
SCTPDBG_ADDR(SCTP_DEBUG_ASCONF1, from);
/* look up the from address */
stcb->asoc.last_control_chunk_from = sctp_findnet(stcb, from);
#ifdef SCTP_DEBUG
if ((stcb->asoc.last_control_chunk_from == NULL) &&
(sctp_debug_on & SCTP_DEBUG_ASCONF1))
printf("handle_asconf: IP source address not found?!\n");
#endif /* SCTP_DEBUG */
if (stcb->asoc.last_control_chunk_from == NULL)
SCTPDBG(SCTP_DEBUG_ASCONF1, "handle_asconf: IP source address not found?!\n");
#endif
}
}
/* and send it (a new one) out... */
@ -1063,11 +948,8 @@ sctp_asconf_queue_add(struct sctp_tcb *stcb, struct sctp_ifa *ifa, uint16_t type
SCTP_MALLOC(aa, struct sctp_asconf_addr *, sizeof(*aa), "AsconfAddr");
if (aa == NULL) {
/* didn't get memory */
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_ASCONF1) {
printf("asconf_queue_add: failed to get memory!\n");
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_ASCONF1,
"asconf_queue_add: failed to get memory!\n");
return (-1);
}
/* fill in asconf address parameter fields */
@ -1103,6 +985,7 @@ sctp_asconf_queue_add(struct sctp_tcb *stcb, struct sctp_ifa *ifa, uint16_t type
sizeof(struct in_addr));
} else {
/* invalid family! */
SCTP_FREE(aa);
return (-1);
}
aa->sent = 0; /* clear sent flag */
@ -1114,26 +997,23 @@ sctp_asconf_queue_add(struct sctp_tcb *stcb, struct sctp_ifa *ifa, uint16_t type
if (type == SCTP_ADD_IP_ADDRESS) {
/* add goes to the front of the queue */
TAILQ_INSERT_HEAD(&stcb->asoc.asconf_queue, aa, next);
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_ASCONF2) {
printf("asconf_queue_add: appended asconf ADD_IP_ADDRESS: ");
sctp_print_address(sa);
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_ASCONF2,
"asconf_queue_add: appended asconf ADD_IP_ADDRESS: ");
SCTPDBG_ADDR(SCTP_DEBUG_ASCONF2, sa);
} else {
/* delete and set primary goes to the back of the queue */
TAILQ_INSERT_TAIL(&stcb->asoc.asconf_queue, aa, next);
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_ASCONF2) {
if (sctp_debug_on && SCTP_DEBUG_ASCONF2) {
if (type == SCTP_DEL_IP_ADDRESS) {
printf("asconf_queue_add: inserted asconf DEL_IP_ADDRESS: ");
sctp_print_address(sa);
SCTP_PRINTF("asconf_queue_add: inserted asconf DEL_IP_ADDRESS: ");
SCTPDBG_ADDR(SCTP_DEBUG_ASCONF2, sa);
} else {
printf("asconf_queue_add: inserted asconf SET_PRIM_ADDR: ");
sctp_print_address(sa);
SCTP_PRINTF("asconf_queue_add: inserted asconf SET_PRIM_ADDR: ");
SCTPDBG_ADDR(SCTP_DEBUG_ASCONF2, sa);
}
}
#endif /* SCTP_DEBUG */
#endif
}
return (0);
@ -1155,6 +1035,9 @@ sctp_asconf_queue_add_sa(struct sctp_tcb *stcb, struct sockaddr *sa,
struct sctp_asconf_addr *aa, *aa_next;
uint32_t vrf_id;
if (stcb == NULL) {
return (-1);
}
/* see if peer supports ASCONF */
if (stcb->asoc.peer_supports_asconf == 0) {
return (-1);
@ -1212,11 +1095,8 @@ sctp_asconf_queue_add_sa(struct sctp_tcb *stcb, struct sockaddr *sa,
SCTP_MALLOC(aa, struct sctp_asconf_addr *, sizeof(*aa), "AsconfAddr");
if (aa == NULL) {
/* didn't get memory */
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_ASCONF1) {
printf("asconf_queue_add_sa: failed to get memory!\n");
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_ASCONF1,
"asconf_queue_add_sa: failed to get memory!\n");
return (-1);
}
/* fill in asconf address parameter fields */
@ -1304,21 +1184,15 @@ sctp_asconf_process_error(struct sctp_tcb *stcb,
if (htons(eh->length) + sizeof(struct sctp_error_cause) >
htons(aph->ph.param_length)) {
/* invalid error cause length */
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_ASCONF1) {
printf("asconf_process_error: cause element too long\n");
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_ASCONF1,
"asconf_process_error: cause element too long\n");
return;
}
if (htons(ph->param_length) + sizeof(struct sctp_paramhdr) >
htons(eh->length)) {
/* invalid included TLV length */
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_ASCONF1) {
printf("asconf_process_error: included TLV too long\n");
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_ASCONF1,
"asconf_process_error: included TLV too long\n");
return;
}
/* which error code ? */
@ -1359,19 +1233,13 @@ sctp_asconf_process_param_ack(struct sctp_tcb *stcb,
param_type = aparam->ap.aph.ph.param_type;
switch (param_type) {
case SCTP_ADD_IP_ADDRESS:
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_ASCONF1) {
printf("process_param_ack: added IP address\n");
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_ASCONF1,
"process_param_ack: added IP address\n");
sctp_asconf_addr_mgmt_ack(stcb, aparam->ifa, param_type, flag);
break;
case SCTP_DEL_IP_ADDRESS:
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_ASCONF1) {
printf("process_param_ack: deleted IP address\n");
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_ASCONF1,
"process_param_ack: deleted IP address\n");
/* nothing really to do... lists already updated */
break;
case SCTP_SET_PRIM_ADDR:
@ -1420,12 +1288,9 @@ sctp_handle_asconf_ack(struct mbuf *m, int offset,
/* verify minimum length */
if (ntohs(cp->ch.chunk_length) < sizeof(struct sctp_asconf_ack_chunk)) {
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_ASCONF1) {
printf("handle_asconf_ack: chunk too small = %xh\n",
ntohs(cp->ch.chunk_length));
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_ASCONF1,
"handle_asconf_ack: chunk too small = %xh\n",
ntohs(cp->ch.chunk_length));
return;
}
asoc = &stcb->asoc;
@ -1444,31 +1309,21 @@ sctp_handle_asconf_ack(struct mbuf *m, int offset,
* abort the asoc, since someone probably just hijacked us...
*/
if (serial_num == (asoc->asconf_seq_out + 1)) {
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_ASCONF1) {
printf("handle_asconf_ack: got unexpected next serial number! Aborting asoc!\n");
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_ASCONF1, "handle_asconf_ack: got unexpected next serial number! Aborting asoc!\n");
sctp_abort_an_association(stcb->sctp_ep, stcb,
SCTP_CAUSE_ILLEGAL_ASCONF_ACK, NULL);
return;
}
if (serial_num != asoc->asconf_seq_out) {
/* got a duplicate/unexpected ASCONF-ACK */
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_ASCONF1) {
printf("handle_asconf_ack: got duplicate/unexpected serial number = %xh (expected = %xh)\n", serial_num, asoc->asconf_seq_out);
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_ASCONF1, "handle_asconf_ack: got duplicate/unexpected serial number = %xh (expected = %xh)\n",
serial_num, asoc->asconf_seq_out);
return;
}
if (stcb->asoc.asconf_sent == 0) {
/* got a unexpected ASCONF-ACK for serial not in flight */
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_ASCONF1) {
printf("handle_asconf_ack: got serial number = %xh but not in flight\n", serial_num);
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_ASCONF1, "handle_asconf_ack: got serial number = %xh but not in flight\n",
serial_num);
/* nothing to do... duplicate ACK received */
return;
}
@ -1503,11 +1358,8 @@ sctp_handle_asconf_ack(struct mbuf *m, int offset,
}
/* get the complete parameter... */
if (param_length > sizeof(aparam_buf)) {
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_ASCONF1) {
printf("param length (%u) larger than buffer size!\n", param_length);
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_ASCONF1,
"param length (%u) larger than buffer size!\n", param_length);
sctp_asconf_ack_clear(stcb);
return;
}
@ -2028,21 +1880,14 @@ sctp_set_primary_ip_address_sa(struct sctp_tcb *stcb, struct sockaddr *sa)
stcb->sctp_ep, stcb,
stcb->asoc.primary_destination);
}
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_ASCONF1) {
printf("set_primary_ip_address_sa: queued on tcb=%p, ",
stcb);
sctp_print_address(sa);
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_ASCONF1,
"set_primary_ip_address_sa: queued on tcb=%p, ",
stcb);
SCTPDBG_ADDR(SCTP_DEBUG_ASCONF1, sa);
} else {
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_ASCONF1) {
printf("set_primary_ip_address_sa: failed to add to queue on tcb=%p, ",
stcb);
sctp_print_address(sa);
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_ASCONF1, "set_primary_ip_address_sa: failed to add to queue on tcb=%p, ",
stcb);
SCTPDBG_ADDR(SCTP_DEBUG_ASCONF1, sa);
return (-1);
}
return (0);
@ -2069,13 +1914,9 @@ sctp_set_primary_ip_address(struct sctp_ifa *ifa)
stcb->sctp_ep, stcb,
stcb->asoc.primary_destination);
}
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_ASCONF1) {
printf("set_primary_ip_address: queued on stcb=%p, ",
stcb);
sctp_print_address(&ifa->address.sa);
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_ASCONF1, "set_primary_ip_address: queued on stcb=%p, ",
stcb);
SCTPDBG_ADDR(SCTP_DEBUG_ASCONF1, &ifa->address.sa);
}
} /* for each stcb */
} /* for each inp */
@ -2089,6 +1930,9 @@ sctp_find_valid_localaddr(struct sctp_tcb *stcb)
struct sctp_ifa *sctp_ifa;
vrf = sctp_find_vrf(stcb->asoc.vrf_id);
if (vrf == NULL) {
return (NULL);
}
LIST_FOREACH(sctp_ifn, &vrf->ifnlist, next_ifn) {
if (stcb->asoc.loopback_scope == 0 &&
SCTP_IFN_IS_IFT_LOOP(sctp_ifn)) {
@ -2193,19 +2037,15 @@ sctp_compose_asconf(struct sctp_tcb *stcb, int *retlen)
m_asconf_chk = sctp_get_mbuf_for_msg(sizeof(struct sctp_asconf_chunk), 0, M_DONTWAIT, 1, MT_DATA);
if (m_asconf_chk == NULL) {
/* no mbuf's */
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_ASCONF1)
printf("compose_asconf: couldn't get chunk mbuf!\n");
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_ASCONF1,
"compose_asconf: couldn't get chunk mbuf!\n");
return (NULL);
}
m_asconf = sctp_get_mbuf_for_msg(MCLBYTES, 0, M_DONTWAIT, 1, MT_DATA);
if (m_asconf == NULL) {
/* no mbuf's */
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_ASCONF1)
printf("compose_asconf: couldn't get mbuf!\n");
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_ASCONF1,
"compose_asconf: couldn't get mbuf!\n");
sctp_m_freem(m_asconf_chk);
return (NULL);
}
@ -2323,10 +2163,8 @@ sctp_compose_asconf(struct sctp_tcb *stcb, int *retlen)
lookup_used = 1;
} else {
/* uh oh... don't have any address?? */
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_ASCONF1)
printf("compose_asconf: no lookup addr!\n");
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_ASCONF1,
"compose_asconf: no lookup addr!\n");
/* for now, we send a IPv4 address of 0.0.0.0 */
lookup->ph.param_type = htons(SCTP_IPV4_ADDRESS);
lookup->ph.param_length = htons(SCTP_SIZE32(sizeof(struct sctp_ipv4addr_param)));
@ -2366,11 +2204,9 @@ sctp_process_initack_addresses(struct sctp_tcb *stcb, struct mbuf *m,
struct sockaddr *sa;
uint32_t vrf_id;
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_ASCONF2) {
printf("processing init-ack addresses\n");
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_ASCONF2, "processing init-ack addresses\n");
if (stcb == NULL) /* Un-needed check for SA */
return;
/* convert to upper bound */
length += offset;
@ -2465,10 +2301,8 @@ sctp_process_initack_addresses(struct sctp_tcb *stcb, struct mbuf *m,
* we'll be stuck in this loop for a long time...
*/
if (SCTP_SIZE32(plen) == 0) {
#ifdef SCTP_DEBUG
printf("process_initack_addrs: bad len (%d) type=%xh\n",
SCTP_PRINTF("process_initack_addrs: bad len (%d) type=%xh\n",
plen, ptype);
#endif
return;
}
/* get next parameter */
@ -2509,21 +2343,14 @@ sctp_addr_in_initack(struct sctp_tcb *stcb, struct mbuf *m, uint32_t offset,
(sa->sa_family != AF_INET))
return (0);
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_ASCONF2) {
printf("find_initack_addr: starting search for ");
sctp_print_address(sa);
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_ASCONF2, "find_initack_addr: starting search for ");
SCTPDBG_ADDR(SCTP_DEBUG_ASCONF2, sa);
/* convert to upper bound */
length += offset;
if ((offset + sizeof(struct sctp_paramhdr)) > length) {
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_ASCONF1) {
printf("find_initack_addr: invalid offset?\n");
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_ASCONF1,
"find_initack_addr: invalid offset?\n");
return (0);
}
/* go through the addresses in the init-ack */
@ -2540,7 +2367,8 @@ sctp_addr_in_initack(struct sctp_tcb *stcb, struct mbuf *m, uint32_t offset,
sizeof(struct sctp_ipv6addr_param),
(uint8_t *) & addr_store);
if (plen != sizeof(struct sctp_ipv6addr_param) ||
ph == NULL) {
(ph == NULL) ||
(a6p == NULL)) {
return (0);
}
sin6 = (struct sockaddr_in6 *)sa;
@ -2566,7 +2394,8 @@ sctp_addr_in_initack(struct sctp_tcb *stcb, struct mbuf *m, uint32_t offset,
offset, sizeof(struct sctp_ipv4addr_param),
(uint8_t *) & addr_store);
if (plen != sizeof(struct sctp_ipv4addr_param) ||
ph == NULL) {
(ph == NULL) ||
(a4p == NULL)) {
return (0);
}
sin = (struct sockaddr_in *)sa;
@ -2602,19 +2431,12 @@ sctp_check_address_list_ep(struct sctp_tcb *stcb, struct mbuf *m, int offset,
LIST_FOREACH(laddr, &stcb->sctp_ep->sctp_addr_list, sctp_nxt_addr) {
/* be paranoid and validate the laddr */
if (laddr->ifa == NULL) {
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_ASCONF1) {
printf("check_addr_list_ep: laddr->ifa is NULL");
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_ASCONF1,
"check_addr_list_ep: laddr->ifa is NULL");
continue;
}
if (laddr->ifa == NULL) {
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_ASCONF1) {
printf("check_addr_list_ep: laddr->ifa->ifa_addr is NULL");
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_ASCONF1, "check_addr_list_ep: laddr->ifa->ifa_addr is NULL");
continue;
}
/* do i have it implicitly? */
@ -2649,7 +2471,7 @@ sctp_check_address_list_all(struct sctp_tcb *stcb, struct mbuf *m, int offset,
if (stcb) {
vrf_id = stcb->asoc.vrf_id;
} else {
vrf_id = SCTP_DEFAULT_VRFID;
return;
}
vrf = sctp_find_vrf(vrf_id);
if (vrf == NULL) {
@ -2765,7 +2587,7 @@ sctp_addr_mgmt_ep_sa(struct sctp_inpcb *inp, struct sockaddr *sa, uint32_t type,
wi->action = type;
atomic_add_int(&ifa->refcount, 1);
LIST_INSERT_HEAD(&asc->list_of_work, wi, sctp_nxt_addr);
sctp_initiate_iterator(sctp_iterator_ep,
(void)sctp_initiate_iterator(sctp_iterator_ep,
sctp_iterator_stcb,
sctp_iterator_ep_end,
SCTP_PCB_ANY_FLAGS,

View File

@ -63,11 +63,7 @@ sctp_alloc_chunklist(void)
SCTP_MALLOC(chklist, sctp_auth_chklist_t *, sizeof(*chklist),
"AUTH chklist");
if (chklist == NULL) {
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_AUTH_DEBUG) {
printf("sctp_alloc_chunklist: failed to get memory!\n");
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_AUTH1, "sctp_alloc_chunklist: failed to get memory!\n");
} else {
sctp_clear_chunklist(chklist);
}
@ -119,11 +115,9 @@ sctp_auth_add_chunk(uint8_t chunk, sctp_auth_chklist_t * list)
if (list->chunks[chunk] == 0) {
list->chunks[chunk] = 1;
list->num_chunks++;
#ifdef SCTP_DEBUG
if (SCTP_AUTH_DEBUG)
printf("SCTP: added chunk %u (0x%02x) to Auth list\n",
chunk, chunk);
#endif
SCTPDBG(SCTP_DEBUG_AUTH1,
"SCTP: added chunk %u (0x%02x) to Auth list\n",
chunk, chunk);
}
return (0);
}
@ -145,11 +139,9 @@ sctp_auth_delete_chunk(uint8_t chunk, sctp_auth_chklist_t * list)
if (list->chunks[chunk] == 1) {
list->chunks[chunk] = 0;
list->num_chunks--;
#ifdef SCTP_DEBUG
if (SCTP_AUTH_DEBUG)
printf("SCTP: deleted chunk %u (0x%02x) from Auth list\n",
chunk, chunk);
#endif
SCTPDBG(SCTP_DEBUG_AUTH1,
"SCTP: deleted chunk %u (0x%02x) from Auth list\n",
chunk, chunk);
}
return (0);
}
@ -554,10 +546,9 @@ sctp_insert_sharedkey(struct sctp_keyhead *shared_keys,
return;
} else if (new_skey->keyid == skey->keyid) {
/* replace the existing key */
#ifdef SCTP_DEBUG
if (SCTP_AUTH_DEBUG)
printf("replacing shared key id %u\n", new_skey->keyid);
#endif
SCTPDBG(SCTP_DEBUG_AUTH1,
"replacing shared key id %u\n",
new_skey->keyid);
LIST_INSERT_BEFORE(skey, new_skey, next);
LIST_REMOVE(skey, next);
sctp_free_sharedkey(skey);
@ -641,10 +632,8 @@ sctp_auth_add_hmacid(sctp_hmaclist_t * list, uint16_t hmac_id)
if (list == NULL)
return (-1);
if (list->num_algo == list->max_algo) {
#ifdef SCTP_DEBUG
if (SCTP_AUTH_DEBUG)
printf("SCTP: HMAC id list full, ignoring add %u\n", hmac_id);
#endif
SCTPDBG(SCTP_DEBUG_AUTH1,
"SCTP: HMAC id list full, ignoring add %u\n", hmac_id);
return (-1);
}
if ((hmac_id != SCTP_AUTH_HMAC_ID_SHA1) &&
@ -659,10 +648,7 @@ sctp_auth_add_hmacid(sctp_hmaclist_t * list, uint16_t hmac_id)
(hmac_id != SCTP_AUTH_HMAC_ID_MD5)) {
return (-1);
}
#ifdef SCTP_DEBUG
if (SCTP_AUTH_DEBUG)
printf("SCTP: add HMAC id %u to list\n", hmac_id);
#endif
SCTPDBG(SCTP_DEBUG_AUTH1, "SCTP: add HMAC id %u to list\n", hmac_id);
list->hmac[list->num_algo++] = hmac_id;
return (0);
}
@ -722,10 +708,9 @@ sctp_negotiate_hmacid(sctp_hmaclist_t * peer, sctp_hmaclist_t * local)
#endif
/* found the "best" one */
#ifdef SCTP_DEBUG
if (SCTP_AUTH_DEBUG)
printf("SCTP: negotiated peer HMAC id %u\n", peer->hmac[i]);
#endif
SCTPDBG(SCTP_DEBUG_AUTH1,
"SCTP: negotiated peer HMAC id %u\n",
peer->hmac[i]);
return (peer->hmac[i]);
}
}
@ -1360,8 +1345,9 @@ sctp_auth_setactivekey(struct sctp_tcb *stcb, uint16_t keyid)
}
if (skey == NULL) {
/* that key doesn't exist */
if (using_ep_key)
if (using_ep_key) {
SCTP_INP_RUNLOCK(stcb->sctp_ep);
}
return (-1);
}
/* get the shared key text */
@ -1380,8 +1366,9 @@ sctp_auth_setactivekey(struct sctp_tcb *stcb, uint16_t keyid)
sctp_print_key(stcb->asoc.authinfo.assoc_key, "Assoc Key");
#endif
if (using_ep_key)
if (using_ep_key) {
SCTP_INP_RUNLOCK(stcb->sctp_ep);
}
return (0);
}
@ -1583,12 +1570,12 @@ sctp_fill_hmac_digest_m(struct mbuf *m, uint32_t auth_offset,
stcb->asoc.authinfo.assoc_key =
sctp_compute_hashkey(stcb->asoc.authinfo.random,
stcb->asoc.authinfo.peer_random, key);
SCTPDBG(SCTP_DEBUG_AUTH1, "caching key id %u\n",
stcb->asoc.authinfo.assoc_keyid);
#ifdef SCTP_DEBUG
if (SCTP_AUTH_DEBUG) {
printf("caching key id %u\n",
stcb->asoc.authinfo.assoc_keyid);
sctp_print_key(stcb->asoc.authinfo.assoc_key, "Assoc Key");
}
if (SCTP_AUTH_DEBUG)
sctp_print_key(stcb->asoc.authinfo.assoc_key,
"Assoc Key");
#endif
}
/* set in the active key id */
@ -1660,11 +1647,9 @@ sctp_handle_auth(struct sctp_tcb *stcb, struct sctp_auth_chunk *auth,
/* get the auth params */
shared_key_id = ntohs(auth->shared_key_id);
hmac_id = ntohs(auth->hmac_id);
#ifdef SCTP_DEBUG
if (SCTP_AUTH_DEBUG)
printf("SCTP AUTH Chunk: shared key %u, HMAC id %u\n",
shared_key_id, hmac_id);
#endif
SCTPDBG(SCTP_DEBUG_AUTH1,
"SCTP AUTH Chunk: shared key %u, HMAC id %u\n",
shared_key_id, hmac_id);
/* is the indicated HMAC supported? */
if (!sctp_auth_is_supported_hmac(stcb->asoc.local_hmacs, hmac_id)) {
@ -1672,15 +1657,15 @@ sctp_handle_auth(struct sctp_tcb *stcb, struct sctp_auth_chunk *auth,
struct sctp_auth_invalid_hmac *err;
SCTP_STAT_INCR(sctps_recvivalhmacid);
#ifdef SCTP_DEBUG
if (SCTP_AUTH_DEBUG)
printf("SCTP Auth: unsupported HMAC id %u\n", hmac_id);
#endif
SCTPDBG(SCTP_DEBUG_AUTH1,
"SCTP Auth: unsupported HMAC id %u\n",
hmac_id);
/*
* report this in an Error Chunk: Unsupported HMAC
* Identifier
*/
m_err = sctp_get_mbuf_for_msg(sizeof(*err), 0, M_DONTWAIT, 1, MT_HEADER);
m_err = sctp_get_mbuf_for_msg(sizeof(*err), 0, M_DONTWAIT,
1, MT_HEADER);
if (m_err != NULL) {
/* pre-reserve some space */
SCTP_BUF_RESV_UF(m_err, sizeof(struct sctp_chunkhdr));
@ -1709,11 +1694,9 @@ sctp_handle_auth(struct sctp_tcb *stcb, struct sctp_auth_chunk *auth,
/* if the shared key isn't found, discard the chunk */
if (skey == NULL) {
SCTP_STAT_INCR(sctps_recvivalkeyid);
#ifdef SCTP_DEBUG
if (SCTP_AUTH_DEBUG)
printf("SCTP Auth: unknown key id %u\n",
shared_key_id);
#endif
SCTPDBG(SCTP_DEBUG_AUTH1,
"SCTP Auth: unknown key id %u\n",
shared_key_id);
return (-1);
}
/* generate a notification if this is a new key id */
@ -1742,10 +1725,8 @@ sctp_handle_auth(struct sctp_tcb *stcb, struct sctp_auth_chunk *auth,
if (chunklen < (sizeof(*auth) + digestlen)) {
/* invalid digest length */
SCTP_STAT_INCR(sctps_recvauthfailed);
#ifdef SCTP_DEBUG
if (SCTP_AUTH_DEBUG)
printf("SCTP Auth: chunk too short for HMAC\n");
#endif
SCTPDBG(SCTP_DEBUG_AUTH1,
"SCTP Auth: chunk too short for HMAC\n");
return (-1);
}
/* save a copy of the digest, zero the pseudo header, and validate */
@ -1757,10 +1738,8 @@ sctp_handle_auth(struct sctp_tcb *stcb, struct sctp_auth_chunk *auth,
/* compare the computed digest with the one in the AUTH chunk */
if (memcmp(digest, computed_digest, digestlen) != 0) {
SCTP_STAT_INCR(sctps_recvauthfailed);
#ifdef SCTP_DEBUG
if (SCTP_AUTH_DEBUG)
printf("SCTP Auth: HMAC digest check failed\n");
#endif
SCTPDBG(SCTP_DEBUG_AUTH1,
"SCTP Auth: HMAC digest check failed\n");
return (-1);
}
return (0);
@ -1875,10 +1854,8 @@ sctp_validate_init_auth_params(struct mbuf *m, int offset, int limit)
/* enforce the random length */
if (plen != (sizeof(struct sctp_auth_random) +
SCTP_AUTH_RANDOM_SIZE_REQUIRED)) {
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_AUTH1)
printf("SCTP: invalid RANDOM len\n");
#endif
SCTPDBG(SCTP_DEBUG_AUTH1,
"SCTP: invalid RANDOM len\n");
return (-1);
}
} else if (ptype == SCTP_HMAC_LIST) {
@ -1897,10 +1874,8 @@ sctp_validate_init_auth_params(struct mbuf *m, int offset, int limit)
sizeof(hmacs->hmac_ids[0]);
/* validate the hmac list */
if (sctp_verify_hmac_param(hmacs, num_hmacs)) {
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_AUTH1)
printf("SCTP: invalid HMAC param\n");
#endif
SCTPDBG(SCTP_DEBUG_AUTH1,
"SCTP: invalid HMAC param\n");
return (-1);
}
got_hmacs = 1;
@ -1923,18 +1898,14 @@ sctp_validate_init_auth_params(struct mbuf *m, int offset, int limit)
peer_supports_auth = 0;
}
if (!peer_supports_auth && got_chklist) {
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_AUTH1)
printf("SCTP: peer sent chunk list w/o AUTH\n");
#endif
SCTPDBG(SCTP_DEBUG_AUTH1,
"SCTP: peer sent chunk list w/o AUTH\n");
return (-1);
}
if (!sctp_asconf_auth_nochk && peer_supports_asconf &&
!peer_supports_auth) {
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_AUTH1)
printf("SCTP: peer supports ASCONF but not AUTH\n");
#endif
SCTPDBG(SCTP_DEBUG_AUTH1,
"SCTP: peer supports ASCONF but not AUTH\n");
return (-1);
}
return (0);
@ -2012,7 +1983,7 @@ sctp_initialize_auth_params(struct sctp_inpcb *inp, struct sctp_tcb *stcb)
plen = sizeof(*ph) + hmacs_len;
ph->param_length = htons(plen);
keylen += sizeof(*ph);
sctp_serialize_hmaclist(stcb->asoc.local_hmacs,
(void)sctp_serialize_hmaclist(stcb->asoc.local_hmacs,
new_key->key + keylen);
}
#endif

View File

@ -365,10 +365,12 @@ sctp_service_reassembly(struct sctp_tcb *stcb, struct sctp_association *asoc)
int cntDel;
struct sctp_queued_to_read *control, *ctl, *ctlat;
if (stcb == NULL)
return;
cntDel = stream_no = 0;
if (stcb &&
((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) ||
(stcb->asoc.state & SCTP_STATE_CLOSED_SOCKET))) {
if ((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) ||
(stcb->asoc.state & SCTP_STATE_CLOSED_SOCKET)) {
/* socket above is long gone */
asoc->fragmented_delivery_inprogress = 0;
chk = TAILQ_FIRST(&asoc->reasmqueue);
@ -442,14 +444,12 @@ sctp_service_reassembly(struct sctp_tcb *stcb, struct sctp_association *asoc)
* is corrupt, or there is a EOM already on
* the mbuf chain.
*/
if (stcb->asoc.control_pdapi == NULL) {
if ((stcb->asoc.control_pdapi == NULL) || (stcb->asoc.control_pdapi->tail_mbuf == NULL)) {
panic("This should not happen control_pdapi NULL?");
}
if (stcb->asoc.control_pdapi->tail_mbuf == NULL) {
panic("This should not happen, tail_mbuf not being maintained?");
}
/* if we did not panic, it was a EOM */
panic("Bad chunking ??");
return;
}
cntDel++;
}
@ -561,24 +561,17 @@ sctp_queue_data_to_stream(struct sctp_tcb *stcb, struct sctp_association *asoc,
#ifdef SCTP_STR_LOGGING
sctp_log_strm_del(control, NULL, SCTP_STR_LOG_FROM_INTO_STRD);
#endif
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_INDATA1) {
printf("queue to stream called for ssn:%u lastdel:%u nxt:%u\n",
(uint32_t) control->sinfo_stream,
(uint32_t) strm->last_sequence_delivered, (uint32_t) nxt_todel);
}
#endif
SCTPDBG(SCTP_DEBUG_INDATA1,
"queue to stream called for ssn:%u lastdel:%u nxt:%u\n",
(uint32_t) control->sinfo_stream,
(uint32_t) strm->last_sequence_delivered,
(uint32_t) nxt_todel);
if (compare_with_wrap(strm->last_sequence_delivered,
control->sinfo_ssn, MAX_SEQ) ||
(strm->last_sequence_delivered == control->sinfo_ssn)) {
/* The incoming sseq is behind where we last delivered? */
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_INDATA1) {
printf("Duplicate S-SEQ:%d delivered:%d from peer, Abort association\n",
control->sinfo_ssn,
strm->last_sequence_delivered);
}
#endif
SCTPDBG(SCTP_DEBUG_INDATA1, "Duplicate S-SEQ:%d delivered:%d from peer, Abort association\n",
control->sinfo_ssn, strm->last_sequence_delivered);
/*
* throw it in the stream so it gets cleaned up in
* association destruction
@ -852,11 +845,7 @@ sctp_queue_data_for_reasm(struct sctp_tcb *stcb, struct sctp_association *asoc,
* we hit the next one and it does NOT have
* a FIRST fragment mark.
*/
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_INDATA1) {
printf("Gak, Evil plot, its not first, no fragmented delivery in progress\n");
}
#endif
SCTPDBG(SCTP_DEBUG_INDATA1, "Gak, Evil plot, its not first, no fragmented delivery in progress\n");
oper = sctp_get_mbuf_for_msg((sizeof(struct sctp_paramhdr) + 3 * sizeof(uint32_t)),
0, M_DONTWAIT, 1, MT_DATA);
@ -890,11 +879,7 @@ sctp_queue_data_for_reasm(struct sctp_tcb *stcb, struct sctp_association *asoc,
* NEXT chunk MUST be either the LAST or
* MIDDLE fragment NOT a FIRST
*/
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_INDATA1) {
printf("Gak, Evil plot, it IS a first and fragmented delivery in progress\n");
}
#endif
SCTPDBG(SCTP_DEBUG_INDATA1, "Gak, Evil plot, it IS a first and fragmented delivery in progress\n");
oper = sctp_get_mbuf_for_msg((sizeof(struct sctp_paramhdr) + 3 * sizeof(uint32_t)),
0, M_DONTWAIT, 1, MT_DATA);
if (oper) {
@ -927,13 +912,9 @@ sctp_queue_data_for_reasm(struct sctp_tcb *stcb, struct sctp_association *asoc,
if (chk->rec.data.stream_number !=
asoc->str_of_pdapi) {
/* Got to be the right STR No */
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_INDATA1) {
printf("Gak, Evil plot, it IS not same stream number %d vs %d\n",
chk->rec.data.stream_number,
asoc->str_of_pdapi);
}
#endif
SCTPDBG(SCTP_DEBUG_INDATA1, "Gak, Evil plot, it IS not same stream number %d vs %d\n",
chk->rec.data.stream_number,
asoc->str_of_pdapi);
oper = sctp_get_mbuf_for_msg((sizeof(struct sctp_paramhdr) + 3 * sizeof(uint32_t)),
0, M_DONTWAIT, 1, MT_DATA);
if (oper) {
@ -965,13 +946,9 @@ sctp_queue_data_for_reasm(struct sctp_tcb *stcb, struct sctp_association *asoc,
chk->rec.data.stream_seq !=
asoc->ssn_of_pdapi) {
/* Got to be the right STR Seq */
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_INDATA1) {
printf("Gak, Evil plot, it IS not same stream seq %d vs %d\n",
chk->rec.data.stream_seq,
asoc->ssn_of_pdapi);
}
#endif
SCTPDBG(SCTP_DEBUG_INDATA1, "Gak, Evil plot, it IS not same stream seq %d vs %d\n",
chk->rec.data.stream_seq,
asoc->ssn_of_pdapi);
oper = sctp_get_mbuf_for_msg((sizeof(struct sctp_paramhdr) + 3 * sizeof(uint32_t)),
0, M_DONTWAIT, 1, MT_DATA);
if (oper) {
@ -1069,12 +1046,8 @@ sctp_queue_data_for_reasm(struct sctp_tcb *stcb, struct sctp_association *asoc,
*/
if ((chk->rec.data.rcv_flags & SCTP_DATA_FRAG_MASK) ==
SCTP_DATA_FIRST_FRAG) {
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_INDATA1) {
printf("Prev check - It can be a midlle or last but not a first\n");
printf("Gak, Evil plot, it's a FIRST!\n");
}
#endif
SCTPDBG(SCTP_DEBUG_INDATA1, "Prev check - It can be a midlle or last but not a first\n");
SCTPDBG(SCTP_DEBUG_INDATA1, "Gak, Evil plot, it's a FIRST!\n");
oper = sctp_get_mbuf_for_msg((sizeof(struct sctp_paramhdr) + 3 * sizeof(uint32_t)),
0, M_DONTWAIT, 1, MT_DATA);
if (oper) {
@ -1110,13 +1083,9 @@ sctp_queue_data_for_reasm(struct sctp_tcb *stcb, struct sctp_association *asoc,
* Huh, need the correct STR here,
* they must be the same.
*/
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_INDATA1) {
printf("Prev check - Gak, Evil plot, ssn:%d not the same as at:%d\n",
chk->rec.data.stream_number,
prev->rec.data.stream_number);
}
#endif
SCTP_PRINTF("Prev check - Gak, Evil plot, ssn:%d not the same as at:%d\n",
chk->rec.data.stream_number,
prev->rec.data.stream_number);
oper = sctp_get_mbuf_for_msg((sizeof(struct sctp_paramhdr) + 3 * sizeof(uint32_t)),
0, M_DONTWAIT, 1, MT_DATA);
if (oper) {
@ -1153,13 +1122,9 @@ sctp_queue_data_for_reasm(struct sctp_tcb *stcb, struct sctp_association *asoc,
* Huh, need the correct STR here,
* they must be the same.
*/
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_INDATA1) {
printf("Prev check - Gak, Evil plot, sseq:%d not the same as at:%d\n",
chk->rec.data.stream_seq,
prev->rec.data.stream_seq);
}
#endif
SCTPDBG(SCTP_DEBUG_INDATA1, "Prev check - Gak, Evil plot, sseq:%d not the same as at:%d\n",
chk->rec.data.stream_seq,
prev->rec.data.stream_seq);
oper = sctp_get_mbuf_for_msg((sizeof(struct sctp_paramhdr) + 3 * sizeof(uint32_t)),
0, M_DONTWAIT, 1, MT_DATA);
if (oper) {
@ -1194,11 +1159,7 @@ sctp_queue_data_for_reasm(struct sctp_tcb *stcb, struct sctp_association *asoc,
/* Insert chk MUST be a FIRST */
if ((chk->rec.data.rcv_flags & SCTP_DATA_FRAG_MASK) !=
SCTP_DATA_FIRST_FRAG) {
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_INDATA1) {
printf("Prev check - Gak, evil plot, its not FIRST and it must be!\n");
}
#endif
SCTPDBG(SCTP_DEBUG_INDATA1, "Prev check - Gak, evil plot, its not FIRST and it must be!\n");
oper = sctp_get_mbuf_for_msg((sizeof(struct sctp_paramhdr) + 3 * sizeof(uint32_t)),
0, M_DONTWAIT, 1, MT_DATA);
if (oper) {
@ -1243,12 +1204,8 @@ sctp_queue_data_for_reasm(struct sctp_tcb *stcb, struct sctp_association *asoc,
/* Insert chk MUST be a last fragment */
if ((chk->rec.data.rcv_flags & SCTP_DATA_FRAG_MASK)
!= SCTP_DATA_LAST_FRAG) {
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_INDATA1) {
printf("Next chk - Next is FIRST, we must be LAST\n");
printf("Gak, Evil plot, its not a last!\n");
}
#endif
SCTPDBG(SCTP_DEBUG_INDATA1, "Next chk - Next is FIRST, we must be LAST\n");
SCTPDBG(SCTP_DEBUG_INDATA1, "Gak, Evil plot, its not a last!\n");
oper = sctp_get_mbuf_for_msg((sizeof(struct sctp_paramhdr) + 3 * sizeof(uint32_t)),
0, M_DONTWAIT, 1, MT_DATA);
if (oper) {
@ -1288,12 +1245,8 @@ sctp_queue_data_for_reasm(struct sctp_tcb *stcb, struct sctp_association *asoc,
*/
if ((chk->rec.data.rcv_flags & SCTP_DATA_FRAG_MASK) ==
SCTP_DATA_LAST_FRAG) {
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_INDATA1) {
printf("Next chk - Next is a MIDDLE/LAST\n");
printf("Gak, Evil plot, new prev chunk is a LAST\n");
}
#endif
SCTPDBG(SCTP_DEBUG_INDATA1, "Next chk - Next is a MIDDLE/LAST\n");
SCTPDBG(SCTP_DEBUG_INDATA1, "Gak, Evil plot, new prev chunk is a LAST\n");
oper = sctp_get_mbuf_for_msg((sizeof(struct sctp_paramhdr) + 3 * sizeof(uint32_t)),
0, M_DONTWAIT, 1, MT_DATA);
if (oper) {
@ -1330,13 +1283,9 @@ sctp_queue_data_for_reasm(struct sctp_tcb *stcb, struct sctp_association *asoc,
* Huh, need the correct STR here,
* they must be the same.
*/
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_INDATA1) {
printf("Next chk - Gak, Evil plot, ssn:%d not the same as at:%d\n",
chk->rec.data.stream_number,
next->rec.data.stream_number);
}
#endif
SCTPDBG(SCTP_DEBUG_INDATA1, "Next chk - Gak, Evil plot, ssn:%d not the same as at:%d\n",
chk->rec.data.stream_number,
next->rec.data.stream_number);
oper = sctp_get_mbuf_for_msg((sizeof(struct sctp_paramhdr) + 3 * sizeof(uint32_t)),
0, M_DONTWAIT, 1, MT_DATA);
if (oper) {
@ -1374,13 +1323,9 @@ sctp_queue_data_for_reasm(struct sctp_tcb *stcb, struct sctp_association *asoc,
* Huh, need the correct STR here,
* they must be the same.
*/
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_INDATA1) {
printf("Next chk - Gak, Evil plot, sseq:%d not the same as at:%d\n",
chk->rec.data.stream_seq,
next->rec.data.stream_seq);
}
#endif
SCTPDBG(SCTP_DEBUG_INDATA1, "Next chk - Gak, Evil plot, sseq:%d not the same as at:%d\n",
chk->rec.data.stream_seq,
next->rec.data.stream_seq);
oper = sctp_get_mbuf_for_msg((sizeof(struct sctp_paramhdr) + 3 * sizeof(uint32_t)),
0, M_DONTWAIT, 1, MT_DATA);
if (oper) {
@ -1509,6 +1454,9 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc,
#ifdef SCTP_MAP_LOGGING
sctp_log_map(0, tsn, asoc->cumulative_tsn, SCTP_MAP_PREPARE_SLIDE);
#endif
if (stcb == NULL) {
return (0);
}
if (compare_with_wrap(asoc->cumulative_tsn, tsn, MAX_TSN) ||
asoc->cumulative_tsn == tsn) {
/* It is a duplicate */
@ -1554,7 +1502,7 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc,
* Check to see about the GONE flag, duplicates would cause a sack
* to be sent up above
*/
if (stcb && ((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) ||
if (((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) ||
(stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) ||
(stcb->asoc.state & SCTP_STATE_CLOSED_SOCKET))
) {
@ -1593,14 +1541,9 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc,
asoc->highest_tsn_inside_map, MAX_TSN)) {
/* Nope not in the valid range dump it */
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_INDATA1) {
printf("My rwnd overrun1:tsn:%lx rwnd %lu sbspace:%ld\n",
(u_long)tsn, (u_long)asoc->my_rwnd,
sctp_sbspace(&stcb->asoc, &stcb->sctp_socket->so_rcv));
}
#endif
SCTPDBG(SCTP_DEBUG_INDATA1, "My rwnd overrun1:tsn:%lx rwnd %lu sbspace:%ld\n",
(u_long)tsn, (u_long)asoc->my_rwnd,
sctp_sbspace(&stcb->asoc, &stcb->sctp_socket->so_rcv));
sctp_set_rwnd(stcb, asoc);
if ((asoc->cnt_on_all_streams +
asoc->cnt_on_reasm_queue +
@ -1683,13 +1626,8 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc,
strmseq, MAX_SEQ) ||
asoc->strmin[strmno].last_sequence_delivered == strmseq)) {
/* The incoming sseq is behind where we last delivered? */
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_INDATA1) {
printf("EVIL/Broken-Dup S-SEQ:%d delivered:%d from peer, Abort!\n",
strmseq,
asoc->strmin[strmno].last_sequence_delivered);
}
#endif
SCTPDBG(SCTP_DEBUG_INDATA1, "EVIL/Broken-Dup S-SEQ:%d delivered:%d from peer, Abort!\n",
strmseq, asoc->strmin[strmno].last_sequence_delivered);
oper = sctp_get_mbuf_for_msg((sizeof(struct sctp_paramhdr) + 3 * sizeof(uint32_t)),
0, M_DONTWAIT, 1, MT_DATA);
if (oper) {
@ -1839,7 +1777,7 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc,
if (sctp_append_to_readq(stcb->sctp_ep, stcb, control, dmbuf, end,
tsn,
&stcb->sctp_socket->so_rcv)) {
printf("Append fails end:%d\n", end);
SCTP_PRINTF("Append fails end:%d\n", end);
goto failed_pdapi_express_del;
}
SCTP_STAT_INCR(sctps_recvexpressm);
@ -2308,7 +2246,7 @@ sctp_sack_check(struct sctp_tcb *stcb, int ok_to_sack, int was_a_gap, int *abort
#ifdef INVARIANTS
panic("huh, cumack greater than high-tsn in map");
#else
printf("huh, cumack greater than high-tsn in map - should panic?\n");
SCTP_PRINTF("huh, cumack greater than high-tsn in map - should panic?\n");
asoc->highest_tsn_inside_map = asoc->cumulative_tsn;
#endif
}
@ -2465,7 +2403,7 @@ sctp_sack_check(struct sctp_tcb *stcb, int ok_to_sack, int was_a_gap, int *abort
* first packet OR there are gaps or
* duplicates.
*/
SCTP_OS_TIMER_STOP(&stcb->asoc.dack_timer.timer);
(void)SCTP_OS_TIMER_STOP(&stcb->asoc.dack_timer.timer);
sctp_send_sack(stcb);
}
} else {
@ -2809,7 +2747,7 @@ sctp_process_data(struct mbuf **mm, int iphlen, int *offset, int length,
(stcb->asoc.delayed_ack == 0) ||
(stcb->asoc.send_sack == 1)) {
if (SCTP_OS_TIMER_PENDING(&stcb->asoc.dack_timer.timer)) {
SCTP_OS_TIMER_STOP(&stcb->asoc.dack_timer.timer);
(void)SCTP_OS_TIMER_STOP(&stcb->asoc.dack_timer.timer);
}
sctp_send_sack(stcb);
} else {
@ -3265,7 +3203,7 @@ sctp_strike_gap_ack_chunks(struct sctp_tcb *stcb, struct sctp_association *asoc,
) {
/* Yes so drop it */
if (tp1->data != NULL) {
sctp_release_pr_sctp_chunk(stcb, tp1,
(void)sctp_release_pr_sctp_chunk(stcb, tp1,
(SCTP_RESPONSE_TO_USER_REQ | SCTP_NOTIFY_DATAGRAM_SENT),
&asoc->sent_queue);
}
@ -3278,7 +3216,7 @@ sctp_strike_gap_ack_chunks(struct sctp_tcb *stcb, struct sctp_association *asoc,
if (tp1->snd_count > tp1->rec.data.timetodrop.tv_sec) {
/* Yes, so drop it */
if (tp1->data != NULL) {
sctp_release_pr_sctp_chunk(stcb, tp1,
(void)sctp_release_pr_sctp_chunk(stcb, tp1,
(SCTP_RESPONSE_TO_USER_REQ | SCTP_NOTIFY_DATAGRAM_SENT),
&asoc->sent_queue);
}
@ -3301,7 +3239,7 @@ sctp_strike_gap_ack_chunks(struct sctp_tcb *stcb, struct sctp_association *asoc,
/*
* CMT : SFR algo (covers part of DAC and HTNA as well)
*/
if (tp1->whoTo->saw_newack == 0) {
if (tp1->whoTo && tp1->whoTo->saw_newack == 0) {
/*
* No new acks were receieved for data sent to this
* dest. Therefore, according to the SFR algo for
@ -3310,7 +3248,7 @@ sctp_strike_gap_ack_chunks(struct sctp_tcb *stcb, struct sctp_association *asoc,
*/
tp1 = TAILQ_NEXT(tp1, sctp_next);
continue;
} else if (compare_with_wrap(tp1->rec.data.TSN_seq,
} else if (tp1->whoTo && compare_with_wrap(tp1->rec.data.TSN_seq,
tp1->whoTo->this_sack_highest_newack, MAX_TSN)) {
/*
* CMT: New acks were receieved for data sent to
@ -3521,6 +3459,9 @@ sctp_strike_gap_ack_chunks(struct sctp_tcb *stcb, struct sctp_association *asoc,
tp1->no_fr_allowed = 1;
alt = tp1->whoTo;
alt = sctp_find_alternate_net(stcb, alt, 1);
if (alt == NULL) {
alt = tp1->whoTo;
}
/*
* CUCv2: If a different dest is picked for
* the retransmission, then new
@ -3528,10 +3469,10 @@ sctp_strike_gap_ack_chunks(struct sctp_tcb *stcb, struct sctp_association *asoc,
* for orig dest. Let CUCv2 track new (rtx-)
* pseudo-cumack always.
*/
tp1->whoTo->find_pseudo_cumack = 1;
tp1->whoTo->find_rtx_pseudo_cumack = 1;
if (tp1->whoTo) {
tp1->whoTo->find_pseudo_cumack = 1;
tp1->whoTo->find_rtx_pseudo_cumack = 1;
}
} else {/* CMT is OFF */
#ifdef SCTP_FR_TO_ALTERNATE
@ -3593,9 +3534,10 @@ sctp_strike_gap_ack_chunks(struct sctp_tcb *stcb, struct sctp_association *asoc,
(uintptr_t) tp1->whoTo,
tp1->rec.data.TSN_seq);
#endif
tp1->whoTo->net_ack++;
sctp_flight_size_decrease(tp1);
if (tp1->whoTo) {
tp1->whoTo->net_ack++;
sctp_flight_size_decrease(tp1);
}
#ifdef SCTP_LOG_RWND
sctp_log_rwnd(SCTP_INCREASE_PEER_RWND,
asoc->peers_rwnd, tp1->send_size, sctp_peer_chunk_oh);
@ -3672,7 +3614,7 @@ sctp_try_advance_peer_ack_point(struct sctp_tcb *stcb,
if (timevalcmp(&now, &tp1->rec.data.timetodrop, >)) {
/* Yes so drop it */
if (tp1->data) {
sctp_release_pr_sctp_chunk(stcb, tp1,
(void)sctp_release_pr_sctp_chunk(stcb, tp1,
(SCTP_RESPONSE_TO_USER_REQ | SCTP_NOTIFY_DATAGRAM_SENT),
&asoc->sent_queue);
}
@ -3987,7 +3929,7 @@ sctp_cwnd_update(struct sctp_tcb *stcb,
SCTP_RECEIVED_SACK, (void *)net);
/* now was it the primary? if so restore */
if (net->dest_state & SCTP_ADDR_WAS_PRIMARY) {
sctp_set_primary_addr(stcb, (struct sockaddr *)NULL, net);
(void)sctp_set_primary_addr(stcb, (struct sockaddr *)NULL, net);
}
}
}
@ -4149,7 +4091,7 @@ sctp_fs_audit(struct sctp_association *asoc)
#ifdef INVARIANTS
panic("Flight size-express incorrect? \n");
#else
printf("Flight size-express incorrect inflight:%d inbetween:%d\n",
SCTP_PRINTF("Flight size-express incorrect inflight:%d inbetween:%d\n",
inflight, inbetween);
#endif
}
@ -4518,7 +4460,7 @@ sctp_express_handle_sack(struct sctp_tcb *stcb, uint32_t cumack,
to_ticks = MSEC_TO_TICKS(net->RTO);
}
j++;
SCTP_OS_TIMER_START(&net->rxt_timer.timer, to_ticks,
(void)SCTP_OS_TIMER_START(&net->rxt_timer.timer, to_ticks,
sctp_timeout_handler, &net->rxt_timer);
} else {
if (SCTP_OS_TIMER_PENDING(&net->rxt_timer.timer)) {
@ -4744,7 +4686,7 @@ sctp_handle_sack(struct sctp_sack_chunk *ch, struct sctp_tcb *stcb,
}
} else {
printf("Size invalid offset to dups:%d number dups:%d sack_len:%d num gaps:%d\n",
SCTP_PRINTF("Size invalid offset to dups:%d number dups:%d sack_len:%d num gaps:%d\n",
off_to_dup, num_dup, sack_length, num_seg);
}
}
@ -5075,8 +5017,7 @@ sctp_handle_sack(struct sctp_sack_chunk *ch, struct sctp_tcb *stcb,
#ifdef INVARIANTS
panic("Warning flight size is postive and should be 0");
#else
printf("Warning flight size incorrect should be 0 is %d\n",
SCTP_PRINTF("Warning flight size incorrect should be 0 is %d\n",
asoc->total_flight);
#endif
asoc->total_flight = 0;
@ -5721,11 +5662,8 @@ sctp_handle_forward_tsn(struct sctp_tcb *stcb,
asoc = &stcb->asoc;
cnt_gone = 0;
if ((fwd_sz = ntohs(fwd->ch.chunk_length)) < sizeof(struct sctp_forward_tsn_chunk)) {
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_INDATA1) {
printf("Bad size too small/big fwd-tsn\n");
}
#endif
SCTPDBG(SCTP_DEBUG_INDATA1,
"Bad size too small/big fwd-tsn\n");
return;
}
m_size = (stcb->asoc.mapping_array_size << 3);

File diff suppressed because it is too large Load Diff

View File

@ -124,12 +124,20 @@ __FBSDID("$FreeBSD$");
} \
} while (0); \
}
#define SCTP_PRINTF(params...) printf(params)
#define SCTPDBG_PKT(level, iph, sh) \
{ \
do { \
if (sctp_debug_on & level) { \
sctp_print_address_pkt(iph, sh); \
} \
} while (0); \
}
#else
#define SCTPDBG(level, params...)
#define SCTPDBG_ADDR(level, addr)
#define SCTP_PRINTF(params...)
#define SCTPDBG_PKT(level, iph, sh)
#endif
#define SCTP_PRINTF(params...) printf(params)
/*
* Local address and interface list handling

File diff suppressed because it is too large Load Diff

View File

@ -445,11 +445,7 @@ sctp_add_addr_to_vrf(uint32_t vrf_id, void *ifn, uint32_t ifn_index,
* Gak, what can we do? We have lost an address
* change can you say HOSED?
*/
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_PCB1) {
printf("Lost and address change ???\n");
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_PCB1, "Lost and address change ???\n");
/* Opps, must decrement the count */
sctp_del_addr_from_vrf(vrf_id, addr, ifn_index);
return (NULL);
@ -487,9 +483,7 @@ sctp_del_addr_from_vrf(uint32_t vrf_id, struct sockaddr *addr,
vrf = sctp_find_vrf(vrf_id);
if (vrf == NULL) {
#ifdef SCTP_DEBUG
printf("Can't find vrf_id:%d\n", vrf_id);
#endif
SCTP_PRINTF("Can't find vrf_id:%d\n", vrf_id);
goto out_now;
}
sctp_ifap = sctp_find_ifa_by_addr(addr, vrf->vrf_id, 1);
@ -510,11 +504,12 @@ sctp_del_addr_from_vrf(uint32_t vrf_id, struct sockaddr *addr,
}
#ifdef SCTP_DEBUG
else {
printf("Del Addr-ifn:%d Could not find address:",
SCTPDBG(SCTP_DEBUG_PCB1, "Del Addr-ifn:%d Could not find address:",
ifn_index);
sctp_print_address(addr);
SCTPDBG_ADDR(SCTP_DEBUG_PCB1, addr);
}
#endif
out_now:
SCTP_IPI_ADDR_UNLOCK();
if (sctp_ifap) {
@ -526,11 +521,7 @@ sctp_del_addr_from_vrf(uint32_t vrf_id, struct sockaddr *addr,
* Gak, what can we do? We have lost an address
* change can you say HOSED?
*/
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_PCB1) {
printf("Lost and address change ???\n");
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_PCB1, "Lost and address change ???\n");
/* Opps, must decrement the count */
sctp_free_ifa(sctp_ifap);
@ -615,19 +606,11 @@ sctp_tcb_special_locate(struct sctp_inpcb **inp_p, struct sockaddr *from,
LIST_FOREACH(laddr, &inp->sctp_addr_list, sctp_nxt_addr) {
if (laddr->ifa == NULL) {
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_PCB1) {
printf("An ounce of prevention is worth a pound of cure\n");
}
#endif
SCTPDBG(SCTP_DEBUG_PCB1, "%s: NULL ifa\n", __FUNCTION__);
continue;
}
if (laddr->ifa->localifa_flags & SCTP_BEING_DELETED) {
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_PCB1) {
printf("ifa being deleted\n");
}
#endif
SCTPDBG(SCTP_DEBUG_PCB1, "ifa being deleted\n");
continue;
}
if (laddr->ifa->address.sa.sa_family ==
@ -1138,25 +1121,14 @@ sctp_endpoint_probe(struct sockaddr *nam, struct sctppcbhead *head,
}
LIST_FOREACH(laddr, &inp->sctp_addr_list, sctp_nxt_addr) {
if (laddr->ifa == NULL) {
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_PCB1) {
printf("An ounce of prevention is worth a pound of cure\n");
}
#endif
SCTPDBG(SCTP_DEBUG_PCB1, "%s: NULL ifa\n",
__FUNCTION__);
continue;
}
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_PCB1) {
printf("Ok laddr->ifa:%p is possible, ",
laddr->ifa);
}
#endif
SCTPDBG(SCTP_DEBUG_PCB1, "Ok laddr->ifa:%p is possible, ",
laddr->ifa);
if (laddr->ifa->localifa_flags & SCTP_BEING_DELETED) {
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_PCB1) {
printf("Huh IFA being deleted\n");
}
#endif
SCTPDBG(SCTP_DEBUG_PCB1, "Huh IFA being deleted\n");
continue;
}
if (laddr->ifa->address.sa.sa_family == nam->sa_family) {
@ -1189,7 +1161,8 @@ sctp_endpoint_probe(struct sockaddr *nam, struct sctppcbhead *head,
struct sctp_inpcb *
sctp_pcb_findep(struct sockaddr *nam, int find_tcp_pool, int have_lock, uint32_t vrf_id)
sctp_pcb_findep(struct sockaddr *nam, int find_tcp_pool, int have_lock,
uint32_t vrf_id)
{
/*
* First we check the hash table to see if someone has this port
@ -1442,7 +1415,8 @@ sctp_findassoc_by_vtag(struct sockaddr *from, uint32_t vtag,
}
if (skip_src_check) {
*netp = NULL; /* unknown */
*inp_p = stcb->sctp_ep;
if (inp_p)
*inp_p = stcb->sctp_ep;
SCTP_INP_INFO_RUNLOCK();
return (stcb);
}
@ -1567,11 +1541,7 @@ sctp_findassociation_addr(struct mbuf *m, int iphlen, int offset,
retval = sctp_findassociation_addr_sa(to, from, &inp, netp,
find_tcp_pool, vrf_id);
}
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_PCB1) {
printf("retval:%p inp:%p\n", retval, inp);
}
#endif
SCTPDBG(SCTP_DEBUG_PCB1, "retval:%p inp:%p\n", retval, inp);
if (retval == NULL && inp) {
/* Found a EP but not this address */
if ((ch->chunk_type == SCTP_INITIATION) ||
@ -1597,11 +1567,7 @@ sctp_findassociation_addr(struct mbuf *m, int iphlen, int offset,
}
}
}
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_PCB1) {
printf("retval is %p\n", retval);
}
#endif
SCTPDBG(SCTP_DEBUG_PCB1, "retval is %p\n", retval);
return (retval);
}
@ -1652,11 +1618,8 @@ sctp_findassociation_ep_asconf(struct mbuf *m, int iphlen, int offset,
phdr = sctp_get_next_param(m, offset + sizeof(struct sctp_asconf_chunk),
&parm_buf, sizeof(struct sctp_paramhdr));
if (phdr == NULL) {
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_INPUT3) {
printf("findassociation_ep_asconf: failed to get asconf lookup addr\n");
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_INPUT3, "%s: failed to get asconf lookup addr\n",
__FUNCTION__);
return NULL;
}
ptype = (int)((uint32_t) ntohs(phdr->param_type));
@ -1672,11 +1635,8 @@ sctp_findassociation_ep_asconf(struct mbuf *m, int iphlen, int offset,
offset + sizeof(struct sctp_asconf_chunk),
&p6_buf.ph, sizeof(*p6));
if (p6 == NULL) {
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_INPUT3) {
printf("findassociation_ep_asconf: failed to get asconf v6 lookup addr\n");
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_INPUT3, "%s: failed to get asconf v6 lookup addr\n",
__FUNCTION__);
return (NULL);
}
sin6 = (struct sockaddr_in6 *)&remote_store;
@ -1697,11 +1657,8 @@ sctp_findassociation_ep_asconf(struct mbuf *m, int iphlen, int offset,
offset + sizeof(struct sctp_asconf_chunk),
&p4_buf.ph, sizeof(*p4));
if (p4 == NULL) {
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_INPUT3) {
printf("findassociation_ep_asconf: failed to get asconf v4 lookup addr\n");
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_INPUT3, "%s: failed to get asconf v4 lookup addr\n",
__FUNCTION__);
return (NULL);
}
sin = (struct sockaddr_in *)&remote_store;
@ -1759,7 +1716,7 @@ sctp_inpcb_alloc(struct socket *so)
SCTP_INP_INFO_WLOCK();
inp = SCTP_ZONE_GET(sctppcbinfo.ipi_zone_ep, struct sctp_inpcb);
if (inp == NULL) {
printf("Out of SCTP-INPCB structures - no resources\n");
SCTP_PRINTF("Out of SCTP-INPCB structures - no resources\n");
SCTP_INP_INFO_WUNLOCK();
return (ENOBUFS);
}
@ -1819,7 +1776,7 @@ sctp_inpcb_alloc(struct socket *so)
inp->sctp_tcbhash = SCTP_HASH_INIT(sctp_pcbtblsize,
&inp->sctp_hashmark);
if (inp->sctp_tcbhash == NULL) {
printf("Out of SCTP-INPCB->hashinit - no resources\n");
SCTP_PRINTF("Out of SCTP-INPCB->hashinit - no resources\n");
SCTP_ZONE_FREE(sctppcbinfo.ipi_zone_ep, inp);
return (ENOBUFS);
}
@ -1995,11 +1952,7 @@ sctp_move_pcb_and_assoc(struct sctp_inpcb *old_inp, struct sctp_inpcb *new_inp,
* HOSED. We probably should send an abort
* here.
*/
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_PCB1) {
printf("Association hosed in TCP model, out of laddr memory\n");
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_PCB1, "Association hosed in TCP model, out of laddr memory\n");
continue;
}
SCTP_INCR_LADDR_COUNT();
@ -2103,15 +2056,13 @@ sctp_inpcb_bind(struct socket *so, struct sockaddr *addr, struct thread *p)
inp = (struct sctp_inpcb *)so->so_pcb;
ip_inp = (struct inpcb *)so->so_pcb;
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_PCB1) {
if (addr) {
printf("Bind called port:%d\n",
ntohs(((struct sockaddr_in *)addr)->sin_port));
printf("Addr :");
sctp_print_address(addr);
}
if (addr) {
SCTPDBG(SCTP_DEBUG_PCB1, "Bind called port:%d\n",
ntohs(((struct sockaddr_in *)addr)->sin_port));
SCTPDBG(SCTP_DEBUG_PCB1, "Addr :");
SCTPDBG_ADDR(SCTP_DEBUG_PCB1, addr);
}
#endif /* SCTP_DEBUG */
#endif
if ((inp->sctp_flags & SCTP_PCB_FLAGS_UNBOUND) == 0) {
/* already did a bind, subsequent binds NOT allowed ! */
return (EINVAL);
@ -2415,11 +2366,8 @@ sctp_inpcb_bind(struct socket *so, struct sockaddr *addr, struct thread *p)
sctppcbinfo.hashmark)];
/* put it in the bucket */
LIST_INSERT_HEAD(head, inp, sctp_hash);
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_PCB1) {
printf("Main hash to bind at head:%p, bound port:%d\n", head, ntohs(lport));
}
#endif
SCTPDBG(SCTP_DEBUG_PCB1, "Main hash to bind at head:%p, bound port:%d\n",
head, ntohs(lport));
/* set in the port */
inp->sctp_lport = lport;
@ -2519,7 +2467,7 @@ sctp_inpcb_free(struct sctp_inpcb *inp, int immediate, int from)
so = inp->sctp_socket;
if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) {
/* been here before.. eeks.. get out of here */
printf("This conflict in free SHOULD not be happening!\n");
SCTP_PRINTF("This conflict in free SHOULD not be happening!\n");
SCTP_ITERATOR_UNLOCK();
#ifdef SCTP_LOG_CLOSING
sctp_log_closing(inp, NULL, 1);
@ -2530,9 +2478,7 @@ sctp_inpcb_free(struct sctp_inpcb *inp, int immediate, int from)
SCTP_INP_INFO_WLOCK();
SCTP_INP_WLOCK(inp);
/*
* First time through we have the socket lock, after that no more.
*/
/* First time through we have the socket lock, after that no more. */
if (from == SCTP_CALLED_AFTER_CMPSET_OFCLOSE) {
/*
* Once we are in we can remove the flag from = 1 is only
@ -2651,7 +2597,7 @@ sctp_inpcb_free(struct sctp_inpcb *inp, int immediate, int from)
sp = TAILQ_LAST(&((asoc->asoc.locked_on_sending)->outqueue),
sctp_streamhead);
if (sp == NULL) {
printf("Error, sp is NULL, locked on sending is %p strm:%d\n",
SCTP_PRINTF("Error, sp is NULL, locked on sending is %p strm:%d\n",
asoc->asoc.locked_on_sending,
asoc->asoc.locked_on_sending->stream_no);
} else {
@ -2930,11 +2876,6 @@ sctp_findnet(struct sctp_tcb *stcb, struct sockaddr *addr)
}
/*
* add's a remote endpoint address, done with the INIT/INIT-ACK as well as
* when a ASCONF arrives that adds it. It will also initialize all the cwnd
* stats of stuff.
*/
int
sctp_is_address_on_local_host(struct sockaddr *addr, uint32_t vrf_id)
{
@ -2959,6 +2900,13 @@ sctp_set_initial_cc_param(struct sctp_tcb *stcb, struct sctp_nets *net)
net->ssthresh = stcb->asoc.peers_rwnd;
}
/*
* add's a remote endpoint address, done with the INIT/INIT-ACK as well as
* when a ASCONF arrives that adds it. It will also initialize all the cwnd
* stats of stuff.
*/
int
sctp_add_remote_addr(struct sctp_tcb *stcb, struct sockaddr *newaddr,
int set_scope, int from)
@ -2971,12 +2919,9 @@ sctp_add_remote_addr(struct sctp_tcb *stcb, struct sockaddr *newaddr,
struct sctp_nets *net, *netfirst;
int addr_inscope;
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_PCB1) {
printf("Adding an address (from:%d) to the peer: ", from);
sctp_print_address(newaddr);
}
#endif
SCTPDBG(SCTP_DEBUG_PCB1, "Adding an address (from:%d) to the peer: ",
from);
SCTPDBG_ADDR(SCTP_DEBUG_PCB1, newaddr);
netfirst = sctp_findnet(stcb, newaddr);
if (netfirst) {
@ -3162,7 +3107,7 @@ sctp_add_remote_addr(struct sctp_tcb *stcb, struct sockaddr *newaddr,
net->mtu = 0;
}
#ifdef SCTP_PRINT_FOR_B_AND_M
printf("We have found an interface mtu of %d\n", net->mtu);
SCTP_PRINTF("We have found an interface mtu of %d\n", net->mtu);
#endif
if (net->mtu == 0) {
/* Huh ?? */
@ -3172,7 +3117,7 @@ sctp_add_remote_addr(struct sctp_tcb *stcb, struct sockaddr *newaddr,
rmtu = SCTP_GATHER_MTU_FROM_ROUTE(net->ro._s_addr, &net->ro._l_addr.sa, net->ro.ro_rt);
#ifdef SCTP_PRINT_FOR_B_AND_M
printf("The route mtu is %d\n", rmtu);
SCTP_PRINTF("The route mtu is %d\n", rmtu);
#endif
if (rmtu == 0) {
/*
@ -3192,8 +3137,7 @@ sctp_add_remote_addr(struct sctp_tcb *stcb, struct sockaddr *newaddr,
}
if (from == SCTP_ALLOC_ASOC) {
#ifdef SCTP_PRINT_FOR_B_AND_M
printf("New assoc sets mtu to :%d\n",
net->mtu);
SCTP_PRINTF("New assoc sets mtu to :%d\n", net->mtu);
#endif
stcb->asoc.smallest_mtu = net->mtu;
}
@ -3202,7 +3146,7 @@ sctp_add_remote_addr(struct sctp_tcb *stcb, struct sockaddr *newaddr,
}
if (stcb->asoc.smallest_mtu > net->mtu) {
#ifdef SCTP_PRINT_FOR_B_AND_M
printf("new address mtu:%d smaller than smallest:%d\n",
SCTP_PRINTF("new address mtu:%d smaller than smallest:%d\n",
net->mtu, stcb->asoc.smallest_mtu);
#endif
stcb->asoc.smallest_mtu = net->mtu;
@ -3327,6 +3271,10 @@ sctp_aloc_assoc(struct sctp_inpcb *inp, struct sockaddr *firstaddr,
*error = ENOBUFS;
return (NULL);
}
if (firstaddr == NULL) {
*error = EINVAL;
return (NULL);
}
SCTP_INP_RLOCK(inp);
if (inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) {
/*
@ -3339,15 +3287,14 @@ sctp_aloc_assoc(struct sctp_inpcb *inp, struct sockaddr *firstaddr,
*error = EINVAL;
return (NULL);
}
SCTPDBG(SCTP_DEBUG_PCB3, "Allocate an association for peer:");
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_PCB3) {
printf("Allocate an association for peer:");
if (firstaddr) {
sctp_print_address(firstaddr);
printf("Port:%d\n",
ntohs(((struct sockaddr_in *)firstaddr)->sin_port));
} else
printf("None\n");
if (firstaddr) {
SCTPDBG_ADDR(SCTP_DEBUG_PCB3, firstaddr);
SCTPDBG(SCTP_DEBUG_PCB3, "Port:%d\n",
ntohs(((struct sockaddr_in *)firstaddr)->sin_port));
} else {
SCTPDBG(SCTP_DEBUG_PCB3, "None\n");
}
#endif /* SCTP_DEBUG */
if (firstaddr->sa_family == AF_INET) {
@ -3474,11 +3421,7 @@ sctp_aloc_assoc(struct sctp_inpcb *inp, struct sockaddr *firstaddr,
LIST_INSERT_HEAD(head, stcb, sctp_tcbhash);
}
SCTP_INP_WUNLOCK(inp);
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_PCB1) {
printf("Association %p now allocated\n", stcb);
}
#endif
SCTPDBG(SCTP_DEBUG_PCB1, "Association %p now allocated\n", stcb);
return (stcb);
}
@ -4275,11 +4218,8 @@ sctp_update_ep_vflag(struct sctp_inpcb *inp)
/* set the flag based on addresses on the ep list */
LIST_FOREACH(laddr, &inp->sctp_addr_list, sctp_nxt_addr) {
if (laddr->ifa == NULL) {
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_PCB1) {
printf("An ounce of prevention is worth a pound of cure\n");
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_PCB1, "%s: NULL ifa\n",
__FUNCTION__);
continue;
}
if (laddr->ifa->localifa_flags & SCTP_BEING_DELETED) {
@ -4297,22 +4237,22 @@ sctp_update_ep_vflag(struct sctp_inpcb *inp)
* Add the address to the endpoint local address list There is nothing to be
* done if we are bound to all addresses
*/
int
void
sctp_add_local_addr_ep(struct sctp_inpcb *inp, struct sctp_ifa *ifa, uint32_t action)
{
struct sctp_laddr *laddr;
int fnd, error;
int fnd, error = 0;
fnd = 0;
if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) {
/* You are already bound to all. You have it already */
return (0);
return;
}
if (ifa->address.sa.sa_family == AF_INET6) {
if (ifa->localifa_flags & SCTP_ADDR_IFA_UNUSEABLE) {
/* Can't bind a non-useable addr. */
return (-1);
return;
}
}
/* first, is it already present? */
@ -4327,7 +4267,7 @@ sctp_add_local_addr_ep(struct sctp_inpcb *inp, struct sctp_ifa *ifa, uint32_t ac
/* Not in the ep list */
error = sctp_insert_laddr(&inp->sctp_addr_list, ifa, action);
if (error != 0)
return (error);
return;
inp->laddr_count++;
/* update inp_vflag flags */
if (ifa->address.sa.sa_family == AF_INET6) {
@ -4336,7 +4276,7 @@ sctp_add_local_addr_ep(struct sctp_inpcb *inp, struct sctp_ifa *ifa, uint32_t ac
inp->ip_inp.inp.inp_vflag |= INP_IPV4;
}
}
return (0);
return;
}
@ -4368,7 +4308,7 @@ sctp_select_primary_destination(struct sctp_tcb *stcb)
* Delete the address from the endpoint local address list There is nothing
* to be done if we are bound to all addresses
*/
int
void
sctp_del_local_addr_ep(struct sctp_inpcb *inp, struct sctp_ifa *ifa)
{
struct sctp_laddr *laddr;
@ -4377,7 +4317,7 @@ sctp_del_local_addr_ep(struct sctp_inpcb *inp, struct sctp_ifa *ifa)
fnd = 0;
if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) {
/* You are already bound to all. You have it already */
return (EINVAL);
return;
}
LIST_FOREACH(laddr, &inp->sctp_addr_list, sctp_nxt_addr) {
if (laddr->ifa == ifa) {
@ -4387,7 +4327,7 @@ sctp_del_local_addr_ep(struct sctp_inpcb *inp, struct sctp_ifa *ifa)
}
if (fnd && (inp->laddr_count < 2)) {
/* can't delete unless there are at LEAST 2 addresses */
return (-1);
return;
}
if (fnd) {
/*
@ -4440,7 +4380,7 @@ sctp_del_local_addr_ep(struct sctp_inpcb *inp, struct sctp_ifa *ifa)
/* update inp_vflag flags */
sctp_update_ep_vflag(inp);
}
return (0);
return;
}
/*
@ -4449,13 +4389,12 @@ sctp_del_local_addr_ep(struct sctp_inpcb *inp, struct sctp_ifa *ifa)
* ASCONF-ACK response) For the subset binding, static case, this is a
* "valid" address list
*/
int
void
sctp_add_local_addr_assoc(struct sctp_tcb *stcb, struct sctp_ifa *ifa, int restricted_list)
{
struct sctp_inpcb *inp;
struct sctp_laddr *laddr;
struct sctpladdr *list;
int error;
/*
* Assumes TCB is locked.. and possibly the INP. May need to
@ -4467,21 +4406,19 @@ sctp_add_local_addr_assoc(struct sctp_tcb *stcb, struct sctp_ifa *ifa, int restr
if (ifa->address.sa.sa_family == AF_INET6) {
if (ifa->localifa_flags & SCTP_ADDR_IFA_UNUSEABLE) {
/* Can't bind a non-existent addr. */
return (-1);
return;
}
}
/* does the address already exist? */
LIST_FOREACH(laddr, list, sctp_nxt_addr) {
if (laddr->ifa == ifa) {
return (-1);
return;
}
}
/* add to the list */
error = sctp_insert_laddr(list, ifa, 0);
if (error != 0)
return (error);
return (0);
(void)sctp_insert_laddr(list, ifa, 0);
return;
}
/*
@ -4525,7 +4462,7 @@ sctp_remove_laddr(struct sctp_laddr *laddr)
/*
* Remove an address from the TCB local address list
*/
int
void
sctp_del_local_addr_assoc(struct sctp_tcb *stcb, struct sctp_ifa *ifa)
{
struct sctp_inpcb *inp;
@ -4547,7 +4484,7 @@ sctp_del_local_addr_assoc(struct sctp_tcb *stcb, struct sctp_ifa *ifa)
(sctp_is_feature_off(inp, SCTP_PCB_FLAGS_DO_ASCONF) == 0)) {
if (stcb->asoc.numnets < 2) {
/* can't delete last address */
return (-1);
return;
}
}
LIST_FOREACH(laddr, &stcb->asoc.sctp_restricted_addrs, sctp_nxt_addr) {
@ -4556,12 +4493,12 @@ sctp_del_local_addr_assoc(struct sctp_tcb *stcb, struct sctp_ifa *ifa)
continue;
if (laddr->ifa == ifa) {
sctp_remove_laddr(laddr);
return (0);
return;
}
}
/* address not found! */
return (-1);
return;
}
static char sctp_pcb_initialized = 0;
@ -5017,7 +4954,7 @@ sctp_load_addresses_from_init(struct sctp_tcb *stcb, struct mbuf *m,
if (lptype == SCTP_IPV4_ADDRESS) {
if (plen !=
sizeof(struct sctp_asconf_addrv4_param)) {
printf("Sizeof setprim in init/init ack not %d but %d - ignored\n",
SCTP_PRINTF("Sizeof setprim in init/init ack not %d but %d - ignored\n",
(int)sizeof(struct sctp_asconf_addrv4_param),
plen);
} else {
@ -5028,7 +4965,7 @@ sctp_load_addresses_from_init(struct sctp_tcb *stcb, struct mbuf *m,
} else if (lptype == SCTP_IPV6_ADDRESS) {
if (plen !=
sizeof(struct sctp_asconf_addr_param)) {
printf("Sizeof setprim (v6) in init/init ack not %d but %d - ignored\n",
SCTP_PRINTF("Sizeof setprim (v6) in init/init ack not %d but %d - ignored\n",
(int)sizeof(struct sctp_asconf_addr_param),
plen);
} else {
@ -5039,7 +4976,7 @@ sctp_load_addresses_from_init(struct sctp_tcb *stcb, struct mbuf *m,
}
}
if (lsa) {
sctp_set_primary_addr(stcb, sa, NULL);
(void)sctp_set_primary_addr(stcb, sa, NULL);
}
} else if (ptype == SCTP_PRSCTP_SUPPORTED) {
/* Peer supports pr-sctp */
@ -5106,10 +5043,7 @@ sctp_load_addresses_from_init(struct sctp_tcb *stcb, struct mbuf *m,
random_len = plen - sizeof(*p_random);
/* enforce the random length */
if (random_len != SCTP_AUTH_RANDOM_SIZE_REQUIRED) {
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_AUTH1)
printf("SCTP: invalid RANDOM len\n");
#endif
SCTPDBG(SCTP_DEBUG_AUTH1, "SCTP: invalid RANDOM len\n");
return (-27);
}
got_random = 1;
@ -5514,12 +5448,10 @@ sctp_drain_mbufs(struct sctp_inpcb *inp, struct sctp_tcb *stcb)
* if we see a possible attack underway just abort the association.
*/
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_PCB1) {
if (cnt) {
printf("Freed %d chunks from reneg harvest\n", cnt);
}
if (cnt) {
SCTPDBG(SCTP_DEBUG_PCB1, "Freed %d chunks from reneg harvest\n", cnt);
}
#endif /* SCTP_DEBUG */
#endif
if (cnt) {
/*
* Now do we need to find a new
@ -5538,7 +5470,7 @@ sctp_drain_mbufs(struct sctp_inpcb *inp, struct sctp_tcb *stcb)
* have found NO data... wierd... we will start at
* end of mapping array.
*/
printf("Gap was larger than array?? %d set to max:%d maparraymax:%x\n",
SCTP_PRINTF("Gap was larger than array?? %d set to max:%d maparraymax:%x\n",
(int)gap,
(int)(asoc->mapping_array_size << 3),
(int)asoc->highest_tsn_inside_map);
@ -5661,8 +5593,9 @@ sctp_initiate_iterator(inp_func inpf,
}
SCTP_IPI_ITERATOR_WQ_LOCK();
if (it->inp)
if (it->inp) {
SCTP_INP_INCR_REF(it->inp);
}
TAILQ_INSERT_TAIL(&sctppcbinfo.iteratorhead, it, sctp_nxt_itr);
#if defined(SCTP_USE_THREAD_BASED_ITERATOR)
if (sctppcbinfo.iterator_running == 0) {

View File

@ -486,13 +486,13 @@ int sctp_free_assoc(struct sctp_inpcb *, struct sctp_tcb *, int, int);
void
sctp_add_vtag_to_timewait(struct sctp_inpcb *, uint32_t, uint32_t);
int sctp_add_local_addr_ep(struct sctp_inpcb *, struct sctp_ifa *, uint32_t);
void sctp_add_local_addr_ep(struct sctp_inpcb *, struct sctp_ifa *, uint32_t);
int sctp_insert_laddr(struct sctpladdr *, struct sctp_ifa *, uint32_t);
void sctp_remove_laddr(struct sctp_laddr *);
int sctp_del_local_addr_ep(struct sctp_inpcb *, struct sctp_ifa *);
void sctp_del_local_addr_ep(struct sctp_inpcb *, struct sctp_ifa *);
void sctp_set_initial_cc_param(struct sctp_tcb *, struct sctp_nets *net);
@ -505,9 +505,9 @@ int sctp_del_remote_addr(struct sctp_tcb *, struct sockaddr *);
void sctp_pcb_init(void);
int sctp_add_local_addr_assoc(struct sctp_tcb *, struct sctp_ifa *, int);
void sctp_add_local_addr_assoc(struct sctp_tcb *, struct sctp_ifa *, int);
int sctp_del_local_addr_assoc(struct sctp_tcb *, struct sctp_ifa *);
void sctp_del_local_addr_assoc(struct sctp_tcb *, struct sctp_ifa *);
int
sctp_load_addresses_from_init(struct sctp_tcb *, struct mbuf *, int, int,

View File

@ -113,12 +113,7 @@ sctp_get_peeloff(struct socket *head, sctp_assoc_t assoc_id, int *error)
struct sctp_inpcb *inp, *n_inp;
struct sctp_tcb *stcb;
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_PEEL1) {
printf("SCTP peel-off called\n");
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_PEEL1, "SCTP peel-off called\n");
inp = (struct sctp_inpcb *)head->so_pcb;
if (inp == NULL) {
*error = EFAULT;
@ -132,11 +127,7 @@ sctp_get_peeloff(struct socket *head, sctp_assoc_t assoc_id, int *error)
newso = sonewconn(head, SS_ISCONNECTED
);
if (newso == NULL) {
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_PEEL1) {
printf("sctp_peeloff:sonewconn failed err\n");
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_PEEL1, "sctp_peeloff:sonewconn failed\n");
*error = ENOMEM;
SCTP_TCB_UNLOCK(stcb);
return (NULL);

View File

@ -171,13 +171,9 @@ sctp_audit_retranmission_queue(struct sctp_association *asoc)
{
struct sctp_tmit_chunk *chk;
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_TIMER4) {
printf("Audit invoked on send queue cnt:%d onqueue:%d\n",
asoc->sent_queue_retran_cnt,
asoc->sent_queue_cnt);
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_TIMER4, "Audit invoked on send queue cnt:%d onqueue:%d\n",
asoc->sent_queue_retran_cnt,
asoc->sent_queue_cnt);
asoc->sent_queue_retran_cnt = 0;
asoc->sent_queue_cnt = 0;
TAILQ_FOREACH(chk, &asoc->sent_queue, sctp_next) {
@ -191,13 +187,9 @@ sctp_audit_retranmission_queue(struct sctp_association *asoc)
sctp_ucount_incr(asoc->sent_queue_retran_cnt);
}
}
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_TIMER4) {
printf("Audit completes retran:%d onqueue:%d\n",
asoc->sent_queue_retran_cnt,
asoc->sent_queue_cnt);
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_TIMER4, "Audit completes retran:%d onqueue:%d\n",
asoc->sent_queue_retran_cnt,
asoc->sent_queue_cnt);
}
int
@ -206,13 +198,9 @@ sctp_threshold_management(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
{
if (net) {
net->error_count++;
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_TIMER4) {
printf("Error count for %p now %d thresh:%d\n",
net, net->error_count,
net->failure_threshold);
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_TIMER4, "Error count for %p now %d thresh:%d\n",
net, net->error_count,
net->failure_threshold);
if (net->error_count > net->failure_threshold) {
/* We had a threshold failure */
if (net->dest_state & SCTP_ADDR_REACHABLE) {
@ -245,15 +233,10 @@ sctp_threshold_management(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
} else {
stcb->asoc.overall_error_count++;
}
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_TIMER4) {
printf("Overall error count for %p now %d thresh:%u state:%x\n",
&stcb->asoc,
stcb->asoc.overall_error_count,
(uint32_t) threshold,
((net == NULL) ? (uint32_t) 0 : (uint32_t) net->dest_state));
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_TIMER4, "Overall error count for %p now %d thresh:%u state:%x\n",
&stcb->asoc, stcb->asoc.overall_error_count,
(uint32_t) threshold,
((net == NULL) ? (uint32_t) 0 : (uint32_t) net->dest_state));
/*
* We specifically do not do >= to give the assoc one more change
* before we fail it.
@ -528,7 +511,7 @@ sctp_mark_all_for_resend(struct sctp_tcb *stcb,
MAX_TSN)) ||
(stcb->asoc.last_acked_seq == chk->rec.data.TSN_seq)) {
/* Strange case our list got out of order? */
printf("Our list is out of order?\n");
SCTP_PRINTF("Our list is out of order?\n");
panic("Out of order list");
}
if ((chk->whoTo == net) && (chk->sent < SCTP_DATAGRAM_ACKED)) {
@ -587,7 +570,7 @@ sctp_mark_all_for_resend(struct sctp_tcb *stcb,
(now.tv_usec > chk->rec.data.timetodrop.tv_usec))) {
/* Yes so drop it */
if (chk->data) {
sctp_release_pr_sctp_chunk(stcb,
(void)sctp_release_pr_sctp_chunk(stcb,
chk,
(SCTP_RESPONSE_TO_USER_REQ | SCTP_NOTIFY_DATAGRAM_SENT),
&stcb->asoc.sent_queue);
@ -599,7 +582,7 @@ sctp_mark_all_for_resend(struct sctp_tcb *stcb,
/* Has it been retransmitted tv_sec times? */
if (chk->snd_count > chk->rec.data.timetodrop.tv_sec) {
if (chk->data) {
sctp_release_pr_sctp_chunk(stcb,
(void)sctp_release_pr_sctp_chunk(stcb,
chk,
(SCTP_RESPONSE_TO_USER_REQ | SCTP_NOTIFY_DATAGRAM_SENT),
&stcb->asoc.sent_queue);
@ -678,17 +661,16 @@ sctp_mark_all_for_resend(struct sctp_tcb *stcb,
sctp_log_fr(tsnfirst, tsnlast, num_mk, SCTP_FR_T3_TIMEOUT);
#endif
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_TIMER1) {
if (num_mk) {
printf("LAST TSN marked was %x\n", tsnlast);
printf("Num marked for retransmission was %d peer-rwd:%ld\n",
num_mk, (u_long)stcb->asoc.peers_rwnd);
printf("LAST TSN marked was %x\n", tsnlast);
printf("Num marked for retransmission was %d peer-rwd:%d\n",
num_mk,
(int)stcb->asoc.peers_rwnd
);
}
if (num_mk) {
SCTPDBG(SCTP_DEBUG_TIMER1, "LAST TSN marked was %x\n",
tsnlast);
SCTPDBG(SCTP_DEBUG_TIMER1, "Num marked for retransmission was %d peer-rwd:%ld\n",
num_mk, (u_long)stcb->asoc.peers_rwnd);
SCTPDBG(SCTP_DEBUG_TIMER1, "LAST TSN marked was %x\n",
tsnlast);
SCTPDBG(SCTP_DEBUG_TIMER1, "Num marked for retransmission was %d peer-rwd:%d\n",
num_mk,
(int)stcb->asoc.peers_rwnd);
}
#endif
*num_marked = num_mk;
@ -700,7 +682,7 @@ sctp_mark_all_for_resend(struct sctp_tcb *stcb,
}
if (stcb->asoc.sent_queue_retran_cnt != cnt_mk) {
#ifdef INVARIANTS
printf("Local Audit says there are %d for retran asoc cnt:%d\n",
SCTP_PRINTF("Local Audit says there are %d for retran asoc cnt:%d\n",
cnt_mk, stcb->asoc.sent_queue_retran_cnt);
#endif
#ifndef SCTP_AUDITING_ENABLED
@ -721,23 +703,17 @@ sctp_mark_all_for_resend(struct sctp_tcb *stcb,
}
}
if (audit_tf) {
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_TIMER4) {
printf("Audit total flight due to negative value net:%p\n",
net);
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_TIMER4,
"Audit total flight due to negative value net:%p\n",
net);
stcb->asoc.total_flight = 0;
stcb->asoc.total_flight_count = 0;
/* Clear all networks flight size */
TAILQ_FOREACH(lnets, &stcb->asoc.nets, sctp_next) {
lnets->flight_size = 0;
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_TIMER4) {
printf("Net:%p c-f cwnd:%d ssthresh:%d\n",
lnets, lnets->cwnd, lnets->ssthresh);
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_TIMER4,
"Net:%p c-f cwnd:%d ssthresh:%d\n",
lnets, lnets->cwnd, lnets->ssthresh);
}
TAILQ_FOREACH(chk, &stcb->asoc.sent_queue, sctp_next) {
if (chk->sent < SCTP_DATAGRAM_RESEND) {
@ -867,7 +843,7 @@ sctp_t3rxt_timer(struct sctp_inpcb *inp,
alt = sctp_find_alternate_net(stcb, net, 0);
}
sctp_mark_all_for_resend(stcb, net, alt, win_probe, &num_mk);
(void)sctp_mark_all_for_resend(stcb, net, alt, win_probe, &num_mk);
/* FR Loss recovery just ended with the T3. */
stcb->asoc.fast_retran_loss_recovery = 0;
@ -1082,7 +1058,7 @@ sctp_cookie_timer(struct sctp_inpcb *inp,
#ifdef INVARIANTS
panic("Cookie timer expires in wrong state?");
#else
printf("Strange in state %d not cookie-echoed yet c-e timer expires?\n", SCTP_GET_STATE(&stcb->asoc));
SCTP_PRINTF("Strange in state %d not cookie-echoed yet c-e timer expires?\n", SCTP_GET_STATE(&stcb->asoc));
return (0);
#endif
}
@ -1130,7 +1106,7 @@ sctp_strreset_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
return (0);
}
/* find the existing STRRESET, we use the seq number we sent out on */
sctp_find_stream_reset(stcb, stcb->asoc.str_reset_seq_out, &strrst);
(void)sctp_find_stream_reset(stcb, stcb->asoc.str_reset_seq_out, &strrst);
if (strrst == NULL) {
return (0);
}
@ -1222,11 +1198,7 @@ sctp_asconf_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
* properly handling the chunk type upper bits Mark
* this peer as ASCONF incapable and cleanup
*/
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_TIMER1) {
printf("asconf_timer: Peer has not responded to our repeated ASCONFs\n");
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_TIMER1, "asconf_timer: Peer has not responded to our repeated ASCONFs\n");
sctp_asconf_cleanup(stcb, net);
return (0);
}
@ -1339,7 +1311,7 @@ sctp_audit_stream_queues_for_size(struct sctp_inpcb *inp,
return;
if (stcb->asoc.sent_queue_retran_cnt) {
printf("Hmm, sent_queue_retran_cnt is non-zero %d\n",
SCTP_PRINTF("Hmm, sent_queue_retran_cnt is non-zero %d\n",
stcb->asoc.sent_queue_retran_cnt);
stcb->asoc.sent_queue_retran_cnt = 0;
}
@ -1356,7 +1328,7 @@ sctp_audit_stream_queues_for_size(struct sctp_inpcb *inp,
}
if (cnt) {
/* yep, we lost a spoke or two */
printf("Found an additional %d streams NOT on outwheel, corrected\n", cnt);
SCTP_PRINTF("Found an additional %d streams NOT on outwheel, corrected\n", cnt);
} else {
/* no spokes lost, */
stcb->asoc.total_output_queue_size = 0;
@ -1376,7 +1348,7 @@ sctp_audit_stream_queues_for_size(struct sctp_inpcb *inp,
}
}
if (chks_in_queue != stcb->asoc.stream_queue_cnt) {
printf("Hmm, stream queue cnt at %d I counted %d in stream out wheel\n",
SCTP_PRINTF("Hmm, stream queue cnt at %d I counted %d in stream out wheel\n",
stcb->asoc.stream_queue_cnt, chks_in_queue);
}
if (chks_in_queue) {
@ -1389,12 +1361,12 @@ sctp_audit_stream_queues_for_size(struct sctp_inpcb *inp,
* and add fragments allowed
*/
if (being_filled == 0) {
printf("Still nothing moved %d chunks are stuck\n",
SCTP_PRINTF("Still nothing moved %d chunks are stuck\n",
chks_in_queue);
}
}
} else {
printf("Found no chunks on any queue tot:%lu\n",
SCTP_PRINTF("Found no chunks on any queue tot:%lu\n",
(u_long)stcb->asoc.total_output_queue_size);
stcb->asoc.total_output_queue_size = 0;
}
@ -1544,15 +1516,16 @@ sctp_pathmtu_timer(struct sctp_inpcb *inp,
if ((net->src_addr_selected == 0) ||
(net->ro._s_addr == NULL) ||
(net->ro._s_addr->localifa_flags & SCTP_BEING_DELETED)) {
if ((net->ro._s_addr == NULL) && (net->ro._s_addr->localifa_flags & SCTP_BEING_DELETED)) {
if ((net->ro._s_addr != NULL) && (net->ro._s_addr->localifa_flags & SCTP_BEING_DELETED)) {
sctp_free_ifa(net->ro._s_addr);
net->ro._s_addr = NULL;
net->src_addr_selected = 0;
} else if (net->ro._s_addr == NULL) {
net->ro._s_addr = sctp_source_address_selection(inp,
stcb,
(sctp_route_t *) & net->ro,
net, 0, stcb->asoc.vrf_id);
}
net->ro._s_addr = sctp_source_address_selection(inp,
stcb,
(sctp_route_t *) & net->ro,
net, 0, stcb->asoc.vrf_id);
if (net->ro._s_addr)
net->src_addr_selected = 1;
}
@ -1688,7 +1661,7 @@ sctp_iterator_timer(struct sctp_iterator *it)
}
if ((it->inp->inp_starting_point_for_iterator != NULL) &&
(it->inp->inp_starting_point_for_iterator != it)) {
printf("Iterator collision, waiting for one at %p\n",
SCTP_PRINTF("Iterator collision, waiting for one at %p\n",
it->inp);
SCTP_INP_WUNLOCK(it->inp);
goto start_timer_return;

View File

@ -111,7 +111,7 @@ sctp_pathmtu_adjustment(struct sctp_inpcb *inp,
stcb->asoc.smallest_mtu = nxtsz;
/* now off to subtract IP_DF flag if needed */
#ifdef SCTP_PRINT_FOR_B_AND_M
printf("sctp_pathmtu_adjust called inp:%p stcb:%p net:%p nxtsz:%d\n",
SCTP_PRINTF("sctp_pathmtu_adjust called inp:%p stcb:%p net:%p nxtsz:%d\n",
inp, stcb, net, nxtsz);
#endif
TAILQ_FOREACH(chk, &stcb->asoc.send_queue, sctp_next) {
@ -160,8 +160,9 @@ sctp_notify_mbuf(struct sctp_inpcb *inp,
/* protection */
if ((inp == NULL) || (stcb == NULL) || (net == NULL) ||
(ip == NULL) || (sh == NULL)) {
if (stcb != NULL)
if (stcb != NULL) {
SCTP_TCB_UNLOCK(stcb);
}
return;
}
/* First job is to verify the vtag matches what I would send */
@ -205,7 +206,7 @@ sctp_notify_mbuf(struct sctp_inpcb *inp,
/* now what about the ep? */
if (stcb->asoc.smallest_mtu > nxtsz) {
#ifdef SCTP_PRINT_FOR_B_AND_M
printf("notify_mbuf (ICMP) calls sctp_pathmtu_adjust mtu:%d\n",
SCTP_PRINTF("notify_mbuf (ICMP) calls sctp_pathmtu_adjust mtu:%d\n",
nxtsz);
#endif
sctp_pathmtu_adjustment(inp, stcb, net, nxtsz);
@ -251,7 +252,7 @@ sctp_notify(struct sctp_inpcb *inp,
if ((error == EHOSTUNREACH) || (error == EHOSTDOWN)) {
if (net->dest_state & SCTP_ADDR_REACHABLE) {
/* Ok that destination is NOT reachable */
printf("ICMP (thresh %d/%d) takes interface %p down\n",
SCTP_PRINTF("ICMP (thresh %d/%d) takes interface %p down\n",
net->error_count,
net->failure_threshold,
net);
@ -263,8 +264,9 @@ sctp_notify(struct sctp_inpcb *inp,
stcb, SCTP_FAILED_THRESHOLD,
(void *)net);
}
if (stcb)
if (stcb) {
SCTP_TCB_UNLOCK(stcb);
}
} else {
/*
* Here the peer is either playing tricks on us,
@ -280,10 +282,9 @@ sctp_notify(struct sctp_inpcb *inp,
}
} else {
/* Send all others to the app */
if (stcb)
if (stcb) {
SCTP_TCB_UNLOCK(stcb);
}
if (inp->sctp_socket) {
#ifdef SCTP_LOCK_LOGGING
sctp_log_lock(inp, stcb, SCTP_LOG_LOCK_SOCK);
@ -665,7 +666,7 @@ sctp_sendm(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr,
/* now what about control */
if (control) {
if (inp->control) {
printf("huh? control set?\n");
SCTP_PRINTF("huh? control set?\n");
sctp_m_freem(inp->control);
inp->control = NULL;
}
@ -812,7 +813,7 @@ sctp_disconnect(struct socket *so)
sp = TAILQ_LAST(&asoc->locked_on_sending->outqueue, sctp_streamhead);
if (sp == NULL) {
printf("Error, sp is NULL, locked on sending is non-null strm:%d\n",
SCTP_PRINTF("Error, sp is NULL, locked on sending is non-null strm:%d\n",
asoc->locked_on_sending->stream_no);
} else {
if ((sp->length == 0) && (sp->msg_is_complete == 0))
@ -862,7 +863,6 @@ sctp_disconnect(struct socket *so)
return (0);
}
/* not reached */
printf("Not reached reached?\n");
} else {
/* UDP model does not support this */
SCTP_INP_RUNLOCK(inp);
@ -950,7 +950,7 @@ sctp_shutdown(struct socket *so)
sp = TAILQ_LAST(&asoc->locked_on_sending->outqueue, sctp_streamhead);
if (sp == NULL) {
printf("Error, sp is NULL, locked on sending is non-null strm:%d\n",
SCTP_PRINTF("Error, sp is NULL, locked on sending is non-null strm:%d\n",
asoc->locked_on_sending->stream_no);
} else {
if ((sp->length == 0) && (sp->msg_is_complete == 0)) {
@ -1258,11 +1258,7 @@ sctp_do_connect_x(struct socket *so, struct sctp_inpcb *inp, void *optval,
uint32_t vrf_id;
sctp_assoc_t *a_id;
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_PCB1) {
printf("Connectx called\n");
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_PCB1, "Connectx called\n");
if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) &&
(inp->sctp_flags & SCTP_PCB_FLAGS_CONNECTED)) {
@ -1374,7 +1370,7 @@ sctp_do_connect_x(struct socket *so, struct sctp_inpcb *inp, void *optval,
return error;
}
#define SCTP_FIND_STCB(inp, stcb, assoc_id) \
#define SCTP_FIND_STCB(inp, stcb, assoc_id) { \
if (inp->sctp_flags & SCTP_PCB_FLAGS_CONNECTED) { \
SCTP_INP_RLOCK(inp); \
stcb = LIST_FIRST(&inp->sctp_asoc_list); \
@ -1389,15 +1385,18 @@ sctp_do_connect_x(struct socket *so, struct sctp_inpcb *inp, void *optval,
} \
} else { \
stcb = NULL; \
}
} \
}
#define SCTP_CHECK_AND_CAST(destp, srcp, type, size) \
#define SCTP_CHECK_AND_CAST(destp, srcp, type, size) {\
if (size < sizeof(type)) { \
error = EINVAL; \
break; \
} else { \
destp = (type *)srcp; \
}
} \
}
static int
sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize,
@ -2284,7 +2283,7 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize,
error = EINVAL;
} else {
/* copy in the chunks */
sctp_serialize_auth_chunks(chklist, sac->gauth_chunks);
(void)sctp_serialize_auth_chunks(chklist, sac->gauth_chunks);
}
SCTP_TCB_UNLOCK(stcb);
} else {
@ -2297,7 +2296,7 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize,
error = EINVAL;
} else {
/* copy in the chunks */
sctp_serialize_auth_chunks(chklist, sac->gauth_chunks);
(void)sctp_serialize_auth_chunks(chklist, sac->gauth_chunks);
}
SCTP_INP_RUNLOCK(inp);
}
@ -2322,7 +2321,7 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize,
error = EINVAL;
} else {
/* copy in the chunks */
sctp_serialize_auth_chunks(chklist, sac->gauth_chunks);
(void)sctp_serialize_auth_chunks(chklist, sac->gauth_chunks);
}
SCTP_TCB_UNLOCK(stcb);
} else {
@ -2352,12 +2351,12 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
uint32_t vrf_id;
if (optval == NULL) {
printf("optval is NULL\n");
SCTP_PRINTF("optval is NULL\n");
return (EINVAL);
}
inp = (struct sctp_inpcb *)so->so_pcb;
if (inp == 0) {
printf("inp is NULL?\n");
SCTP_PRINTF("inp is NULL?\n");
return EINVAL;
}
vrf_id = inp->def_vrf_id;
@ -2552,8 +2551,8 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
size_t size;
SCTP_CHECK_AND_CAST(sca, optval, struct sctp_authkey, optsize);
SCTP_FIND_STCB(inp, stcb, sca->sca_assoc_id)
size = optsize - sizeof(*sca);
SCTP_FIND_STCB(inp, stcb, sca->sca_assoc_id);
size = optsize - sizeof(*sca);
if (stcb) {
/* set it on the assoc */
@ -3052,7 +3051,7 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
net->mtu = paddrp->spp_pathmtu;
if (net->mtu < stcb->asoc.smallest_mtu) {
#ifdef SCTP_PRINT_FOR_B_AND_M
printf("SCTP_PMTU_DISABLE calls sctp_pathmtu_adjustment:%d\n",
SCTP_PRINTF("SCTP_PMTU_DISABLE calls sctp_pathmtu_adjustment:%d\n",
net->mtu);
#endif
sctp_pathmtu_adjustment(inp, stcb, net, net->mtu);
@ -3420,7 +3419,7 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
*/
if (addrs->sget_assoc_id == 0) {
/* delete the address */
sctp_addr_mgmt_ep_sa(inp, addr_touse,
(void)sctp_addr_mgmt_ep_sa(inp, addr_touse,
SCTP_DEL_IP_ADDRESS, vrf_id);
} else {
/*
@ -3587,9 +3586,9 @@ sctp_connect(struct socket *so, struct sockaddr *addr, struct thread *p)
sctp_send_initiate(inp, stcb);
SCTP_TCB_UNLOCK(stcb);
out_now:
if (create_lock_on)
if (create_lock_on) {
SCTP_ASOC_CREATE_UNLOCK(inp);
}
SCTP_INP_DECR_REF(inp);
return error;
}
@ -3870,8 +3869,9 @@ sctp_peeraddr(struct socket *so, struct sockaddr **addr)
}
SCTP_INP_RLOCK(inp);
stcb = LIST_FIRST(&inp->sctp_asoc_list);
if (stcb)
if (stcb) {
SCTP_TCB_LOCK(stcb);
}
SCTP_INP_RUNLOCK(inp);
if (stcb == NULL) {
SCTP_FREE_SONAME(sin);

View File

@ -244,7 +244,7 @@ sctp_log_strm_del(struct sctp_queued_to_read *control, struct sctp_queued_to_rea
int sctp_cwnd_log_at;
if (control == NULL) {
printf("Gak log of NULL?\n");
SCTP_PRINTF("Gak log of NULL?\n");
return;
}
SCTP_STATLOG_GETREF(sctp_cwnd_log_at);
@ -583,41 +583,41 @@ sctp_print_audit_report(void)
if ((sctp_audit_data[i][0] == 0xe0) &&
(sctp_audit_data[i][1] == 0x01)) {
cnt = 0;
printf("\n");
SCTP_PRINTF("\n");
} else if (sctp_audit_data[i][0] == 0xf0) {
cnt = 0;
printf("\n");
SCTP_PRINTF("\n");
} else if ((sctp_audit_data[i][0] == 0xc0) &&
(sctp_audit_data[i][1] == 0x01)) {
printf("\n");
SCTP_PRINTF("\n");
cnt = 0;
}
printf("%2.2x%2.2x ", (uint32_t) sctp_audit_data[i][0],
SCTP_PRINTF("%2.2x%2.2x ", (uint32_t) sctp_audit_data[i][0],
(uint32_t) sctp_audit_data[i][1]);
cnt++;
if ((cnt % 14) == 0)
printf("\n");
SCTP_PRINTF("\n");
}
for (i = 0; i < sctp_audit_indx; i++) {
if ((sctp_audit_data[i][0] == 0xe0) &&
(sctp_audit_data[i][1] == 0x01)) {
cnt = 0;
printf("\n");
SCTP_PRINTF("\n");
} else if (sctp_audit_data[i][0] == 0xf0) {
cnt = 0;
printf("\n");
SCTP_PRINTF("\n");
} else if ((sctp_audit_data[i][0] == 0xc0) &&
(sctp_audit_data[i][1] == 0x01)) {
printf("\n");
SCTP_PRINTF("\n");
cnt = 0;
}
printf("%2.2x%2.2x ", (uint32_t) sctp_audit_data[i][0],
SCTP_PRINTF("%2.2x%2.2x ", (uint32_t) sctp_audit_data[i][0],
(uint32_t) sctp_audit_data[i][1]);
cnt++;
if ((cnt % 14) == 0)
printf("\n");
SCTP_PRINTF("\n");
}
printf("\n");
SCTP_PRINTF("\n");
}
void
@ -677,7 +677,7 @@ sctp_auditing(int from, struct sctp_inpcb *inp, struct sctp_tcb *stcb,
if (sctp_audit_indx >= SCTP_AUDIT_SIZE) {
sctp_audit_indx = 0;
}
printf("resend_cnt:%d asoc-tot:%d\n",
SCTP_PRINTF("resend_cnt:%d asoc-tot:%d\n",
resend_cnt, stcb->asoc.sent_queue_retran_cnt);
rep = 1;
stcb->asoc.sent_queue_retran_cnt = resend_cnt;
@ -697,7 +697,7 @@ sctp_auditing(int from, struct sctp_inpcb *inp, struct sctp_tcb *stcb,
sctp_audit_indx = 0;
}
rep = 1;
printf("tot_flt:%d asoc_tot:%d\n", tot_out,
SCTP_PRINTF("tot_flt:%d asoc_tot:%d\n", tot_out,
(int)stcb->asoc.total_flight);
stcb->asoc.total_flight = tot_out;
}
@ -709,7 +709,7 @@ sctp_auditing(int from, struct sctp_inpcb *inp, struct sctp_tcb *stcb,
sctp_audit_indx = 0;
}
rep = 1;
printf("tot_flt_book:%d\n", tot_book);
SCTP_PRINTF("tot_flt_book:%d\n", tot_book);
stcb->asoc.total_flight_count = tot_book_cnt;
}
@ -725,7 +725,7 @@ sctp_auditing(int from, struct sctp_inpcb *inp, struct sctp_tcb *stcb,
sctp_audit_indx = 0;
}
rep = 1;
printf("real flight:%d net total was %d\n",
SCTP_PRINTF("real flight:%d net total was %d\n",
stcb->asoc.total_flight, tot_out);
/* now corrective action */
TAILQ_FOREACH(lnet, &stcb->asoc.nets, sctp_next) {
@ -738,8 +738,9 @@ sctp_auditing(int from, struct sctp_inpcb *inp, struct sctp_tcb *stcb,
}
}
if (lnet->flight_size != tot_out) {
printf("net:%x flight was %d corrected to %d\n",
(uint32_t) lnet, lnet->flight_size, tot_out);
SCTP_PRINTF("net:%x flight was %d corrected to %d\n",
(uint32_t) lnet, lnet->flight_size,
tot_out);
lnet->flight_size = tot_out;
}
}
@ -842,7 +843,7 @@ sctp_fill_random_store(struct sctp_pcb *m)
* numbers, but thats ok too since that is random as well :->
*/
m->store_at = 0;
sctp_hmac(SCTP_HMAC, (uint8_t *) m->random_numbers,
(void)sctp_hmac(SCTP_HMAC, (uint8_t *) m->random_numbers,
sizeof(m->random_numbers), (uint8_t *) & m->random_counter,
sizeof(m->random_counter), (uint8_t *) m->random_store);
m->random_counter++;
@ -950,6 +951,8 @@ sctp_init_asoc(struct sctp_inpcb *m, struct sctp_association *asoc,
asoc->my_vtag_nonce = sctp_select_a_tag(m);
asoc->peer_vtag_nonce = sctp_select_a_tag(m);
asoc->vrf_id = vrf_id;
/* Save the table id as well from the inp */
asoc->table_id = m->def_table_id;
if (sctp_is_feature_on(m, SCTP_PCB_FLAGS_DONOT_HEARTBEAT))
asoc->hb_is_disabled = 1;
@ -1026,7 +1029,7 @@ sctp_init_asoc(struct sctp_inpcb *m, struct sctp_association *asoc,
asoc->smallest_mtu = m->sctp_frag_point;
#ifdef SCTP_PRINT_FOR_B_AND_M
printf("smallest_mtu init'd with asoc to :%d\n",
SCTP_PRINTF("smallest_mtu init'd with asoc to :%d\n",
asoc->smallest_mtu);
#endif
asoc->minrto = m->sctp_ep.sctp_minrto;
@ -1128,7 +1131,7 @@ sctp_expand_mapping_array(struct sctp_association *asoc)
SCTP_MALLOC(new_array, uint8_t *, new_size, "MappingArray");
if (new_array == NULL) {
/* can't get more, forget it */
printf("No memory for expansion of SCTP mapping array %d\n",
SCTP_PRINTF("No memory for expansion of SCTP mapping array %d\n",
new_size);
return (-1);
}
@ -1148,9 +1151,9 @@ sctp_iterator_work(struct sctp_iterator *it)
int inp_skip = 0;
SCTP_ITERATOR_LOCK();
if (it->inp)
if (it->inp) {
SCTP_INP_DECR_REF(it->inp);
}
if (it->inp == NULL) {
/* iterator is complete */
done_with_iterator:
@ -1332,7 +1335,7 @@ sctp_handle_addr_wq(void)
if (asc->cnt == 0) {
SCTP_FREE(asc);
} else {
sctp_initiate_iterator(sctp_iterator_ep,
(void)sctp_initiate_iterator(sctp_iterator_ep,
sctp_iterator_stcb,
NULL, /* No ep end for boundall */
SCTP_PCB_FLAGS_BOUNDALL,
@ -1368,7 +1371,7 @@ sctp_timeout_handler(void *t)
/* sanity checks... */
if (tmr->self != (void *)tmr) {
/*
* printf("Stale SCTP timer fired (%p), ignoring...\n",
* SCTP_PRINTF("Stale SCTP timer fired (%p), ignoring...\n",
* tmr);
*/
return;
@ -1376,7 +1379,7 @@ sctp_timeout_handler(void *t)
tmr->stopped_from = 0xa001;
if (!SCTP_IS_TIMER_TYPE_VALID(tmr->type)) {
/*
* printf("SCTP timer fired with invalid type: 0x%x\n",
* SCTP_PRINTF("SCTP timer fired with invalid type: 0x%x\n",
* tmr->type);
*/
return;
@ -1416,11 +1419,7 @@ sctp_timeout_handler(void *t)
}
}
tmr->stopped_from = 0xa005;
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_TIMER1) {
printf("Timer type %d goes off\n", tmr->type);
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_TIMER1, "Timer type %d goes off\n", tmr->type);
if (!SCTP_OS_TIMER_ACTIVE(&tmr->timer)) {
if (inp) {
SCTP_INP_DECR_REF(inp);
@ -1461,6 +1460,9 @@ sctp_timeout_handler(void *t)
sctp_iterator_timer(it);
break;
case SCTP_TIMER_TYPE_SEND:
if ((stcb == NULL) || (inp == NULL)) {
break;
}
SCTP_STAT_INCR(sctps_timodata);
stcb->asoc.timodata++;
stcb->asoc.num_send_timers_up--;
@ -1493,6 +1495,9 @@ sctp_timeout_handler(void *t)
}
break;
case SCTP_TIMER_TYPE_INIT:
if ((stcb == NULL) || (inp == NULL)) {
break;
}
SCTP_STAT_INCR(sctps_timoinit);
stcb->asoc.timoinit++;
if (sctp_t1init_timer(inp, stcb, net)) {
@ -1503,6 +1508,9 @@ sctp_timeout_handler(void *t)
did_output = 0;
break;
case SCTP_TIMER_TYPE_RECV:
if ((stcb == NULL) || (inp == NULL)) {
break;
}
SCTP_STAT_INCR(sctps_timosack);
stcb->asoc.timosack++;
sctp_send_sack(stcb);
@ -1512,6 +1520,9 @@ sctp_timeout_handler(void *t)
sctp_chunk_output(inp, stcb, SCTP_OUTPUT_FROM_SACK_TMR);
break;
case SCTP_TIMER_TYPE_SHUTDOWN:
if ((stcb == NULL) || (inp == NULL)) {
break;
}
if (sctp_shutdown_timer(inp, stcb, net)) {
/* no need to unlock on tcb its gone */
goto out_decr;
@ -1528,6 +1539,9 @@ sctp_timeout_handler(void *t)
struct sctp_nets *net;
int cnt_of_unconf = 0;
if ((stcb == NULL) || (inp == NULL)) {
break;
}
SCTP_STAT_INCR(sctps_timoheartbeat);
stcb->asoc.timoheartbeat++;
TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) {
@ -1551,6 +1565,9 @@ sctp_timeout_handler(void *t)
}
break;
case SCTP_TIMER_TYPE_COOKIE:
if ((stcb == NULL) || (inp == NULL)) {
break;
}
if (sctp_cookie_timer(inp, stcb, net)) {
/* no need to unlock on tcb its gone */
goto out_decr;
@ -1571,6 +1588,9 @@ sctp_timeout_handler(void *t)
struct timeval tv;
int i, secret;
if (inp == NULL) {
break;
}
SCTP_STAT_INCR(sctps_timosecret);
(void)SCTP_GETTIME_TIMEVAL(&tv);
SCTP_INP_WLOCK(inp);
@ -1593,11 +1613,17 @@ sctp_timeout_handler(void *t)
did_output = 0;
break;
case SCTP_TIMER_TYPE_PATHMTURAISE:
if ((stcb == NULL) || (inp == NULL)) {
break;
}
SCTP_STAT_INCR(sctps_timopathmtu);
sctp_pathmtu_timer(inp, stcb, net);
did_output = 0;
break;
case SCTP_TIMER_TYPE_SHUTDOWNACK:
if ((stcb == NULL) || (inp == NULL)) {
break;
}
if (sctp_shutdownack_timer(inp, stcb, net)) {
/* no need to unlock on tcb its gone */
goto out_decr;
@ -1610,14 +1636,19 @@ sctp_timeout_handler(void *t)
sctp_chunk_output(inp, stcb, SCTP_OUTPUT_FROM_SHUT_ACK_TMR);
break;
case SCTP_TIMER_TYPE_SHUTDOWNGUARD:
if ((stcb == NULL) || (inp == NULL)) {
break;
}
SCTP_STAT_INCR(sctps_timoshutdownguard);
sctp_abort_an_association(inp, stcb,
SCTP_SHUTDOWN_GUARD_EXPIRES, NULL);
/* no need to unlock on tcb its gone */
goto out_decr;
break;
case SCTP_TIMER_TYPE_STRRESET:
if ((stcb == NULL) || (inp == NULL)) {
break;
}
if (sctp_strreset_timer(inp, stcb, net)) {
/* no need to unlock on tcb its gone */
goto out_decr;
@ -1627,10 +1658,16 @@ sctp_timeout_handler(void *t)
break;
case SCTP_TIMER_TYPE_EARLYFR:
/* Need to do FR of things for net */
if ((stcb == NULL) || (inp == NULL)) {
break;
}
SCTP_STAT_INCR(sctps_timoearlyfr);
sctp_early_fr_timer(inp, stcb, net);
break;
case SCTP_TIMER_TYPE_ASCONF:
if ((stcb == NULL) || (inp == NULL)) {
break;
}
if (sctp_asconf_timer(inp, stcb, net)) {
/* no need to unlock on tcb its gone */
goto out_decr;
@ -1643,12 +1680,18 @@ sctp_timeout_handler(void *t)
break;
case SCTP_TIMER_TYPE_AUTOCLOSE:
if ((stcb == NULL) || (inp == NULL)) {
break;
}
SCTP_STAT_INCR(sctps_timoautoclose);
sctp_autoclose_timer(inp, stcb, net);
sctp_chunk_output(inp, stcb, SCTP_OUTPUT_FROM_AUTOCLOSE_TMR);
did_output = 0;
break;
case SCTP_TIMER_TYPE_ASOCKILL:
if ((stcb == NULL) || (inp == NULL)) {
break;
}
SCTP_STAT_INCR(sctps_timoassockill);
/* Can we free it yet? */
SCTP_INP_DECR_REF(inp);
@ -1660,9 +1703,11 @@ sctp_timeout_handler(void *t)
*/
stcb = NULL;
goto out_no_decr;
break;
case SCTP_TIMER_TYPE_INPKILL:
SCTP_STAT_INCR(sctps_timoinpkill);
if (inp == NULL) {
break;
}
/*
* special case, take away our increment since WE are the
* killer
@ -1672,14 +1717,9 @@ sctp_timeout_handler(void *t)
sctp_inpcb_free(inp, SCTP_FREE_SHOULD_USE_ABORT,
SCTP_CALLED_DIRECTLY_NOCMPSET);
goto out_no_decr;
break;
default:
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_TIMER1) {
printf("sctp_timeout_handler:unknown timer %d\n",
tmr->type);
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_TIMER1, "sctp_timeout_handler:unknown timer %d\n",
tmr->type);
break;
};
#ifdef SCTP_AUDITING_ENABLED
@ -1706,17 +1746,13 @@ sctp_timeout_handler(void *t)
SCTP_INP_DECR_REF(inp);
}
out_no_decr:
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_TIMER1) {
printf("Timer now complete (type %d)\n", tmr->type);
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_TIMER1, "Timer now complete (type %d)\n",
tmr->type);
if (inp) {
}
}
int
void
sctp_timer_start(int t_type, struct sctp_inpcb *inp, struct sctp_tcb *stcb,
struct sctp_nets *net)
{
@ -1724,7 +1760,7 @@ sctp_timer_start(int t_type, struct sctp_inpcb *inp, struct sctp_tcb *stcb,
struct sctp_timer *tmr;
if ((t_type != SCTP_TIMER_TYPE_ADDR_WQ) && (inp == NULL))
return (EFAULT);
return;
to_ticks = 0;
@ -1753,7 +1789,7 @@ sctp_timer_start(int t_type, struct sctp_inpcb *inp, struct sctp_tcb *stcb,
int rto_val;
if ((stcb == NULL) || (net == NULL)) {
return (EFAULT);
return;
}
tmr = &net->rxt_timer;
if (net->RTO == 0) {
@ -1770,7 +1806,7 @@ sctp_timer_start(int t_type, struct sctp_inpcb *inp, struct sctp_tcb *stcb,
* minute.
*/
if ((stcb == NULL) || (net == NULL)) {
return (EFAULT);
return;
}
tmr = &net->rxt_timer;
if (net->RTO == 0) {
@ -1785,7 +1821,7 @@ sctp_timer_start(int t_type, struct sctp_inpcb *inp, struct sctp_tcb *stcb,
* ususually about 200ms.
*/
if (stcb == NULL) {
return (EFAULT);
return;
}
tmr = &stcb->asoc.dack_timer;
to_ticks = MSEC_TO_TICKS(stcb->asoc.delayed_ack);
@ -1793,7 +1829,7 @@ sctp_timer_start(int t_type, struct sctp_inpcb *inp, struct sctp_tcb *stcb,
case SCTP_TIMER_TYPE_SHUTDOWN:
/* Here we use the RTO of the destination. */
if ((stcb == NULL) || (net == NULL)) {
return (EFAULT);
return;
}
if (net->RTO == 0) {
to_ticks = MSEC_TO_TICKS(stcb->asoc.initial_rto);
@ -1808,9 +1844,9 @@ sctp_timer_start(int t_type, struct sctp_inpcb *inp, struct sctp_tcb *stcb,
* though we use a different timer. We also add the HB timer
* PLUS a random jitter.
*/
if (stcb == NULL) {
return (EFAULT);
} {
if ((inp == NULL) || (stcb == NULL)) {
return;
} else {
uint32_t rndval;
uint8_t this_random;
int cnt_of_unconf = 0;
@ -1824,7 +1860,7 @@ sctp_timer_start(int t_type, struct sctp_inpcb *inp, struct sctp_tcb *stcb,
}
if (cnt_of_unconf) {
lnet = NULL;
sctp_heartbeat_timer(inp, stcb, lnet, cnt_of_unconf);
(void)sctp_heartbeat_timer(inp, stcb, lnet, cnt_of_unconf);
}
if (stcb->asoc.hb_random_idx > 3) {
rndval = sctp_select_initial_TSN(&inp->sctp_ep);
@ -1840,7 +1876,7 @@ sctp_timer_start(int t_type, struct sctp_inpcb *inp, struct sctp_tcb *stcb,
*/
if ((stcb->asoc.hb_is_disabled) &&
(cnt_of_unconf == 0)) {
return (0);
return;
}
if (net) {
struct sctp_nets *lnet;
@ -1883,7 +1919,7 @@ sctp_timer_start(int t_type, struct sctp_inpcb *inp, struct sctp_tcb *stcb,
* using the RTO initial value.
*/
if ((stcb == NULL) || (net == NULL)) {
return (EFAULT);
return;
}
if (net->RTO == 0) {
to_ticks = MSEC_TO_TICKS(stcb->asoc.initial_rto);
@ -1897,12 +1933,15 @@ sctp_timer_start(int t_type, struct sctp_inpcb *inp, struct sctp_tcb *stcb,
* nothing needed but the endpoint here ususually about 60
* minutes.
*/
if (inp == NULL) {
return;
}
tmr = &inp->sctp_ep.signature_change;
to_ticks = inp->sctp_ep.sctp_timeoutticks[SCTP_TIMER_SIGNATURE];
break;
case SCTP_TIMER_TYPE_ASOCKILL:
if (stcb == NULL) {
return (EFAULT);
return;
}
tmr = &stcb->asoc.strreset_timer;
to_ticks = MSEC_TO_TICKS(SCTP_ASOC_KILL_TIMEOUT);
@ -1913,6 +1952,9 @@ sctp_timer_start(int t_type, struct sctp_inpcb *inp, struct sctp_tcb *stcb,
* timer since that has stopped and we are in the GONE
* state.
*/
if (inp == NULL) {
return;
}
tmr = &inp->sctp_ep.signature_change;
to_ticks = MSEC_TO_TICKS(SCTP_INP_KILL_TIMEOUT);
break;
@ -1921,11 +1963,11 @@ sctp_timer_start(int t_type, struct sctp_inpcb *inp, struct sctp_tcb *stcb,
* Here we use the value found in the EP for PMTU ususually
* about 10 minutes.
*/
if (stcb == NULL) {
return (EFAULT);
if ((stcb == NULL) || (inp == NULL)) {
return;
}
if (net == NULL) {
return (EFAULT);
return;
}
to_ticks = inp->sctp_ep.sctp_timeoutticks[SCTP_TIMER_PMTU];
tmr = &net->pmtu_timer;
@ -1933,7 +1975,7 @@ sctp_timer_start(int t_type, struct sctp_inpcb *inp, struct sctp_tcb *stcb,
case SCTP_TIMER_TYPE_SHUTDOWNACK:
/* Here we use the RTO of the destination */
if ((stcb == NULL) || (net == NULL)) {
return (EFAULT);
return;
}
if (net->RTO == 0) {
to_ticks = MSEC_TO_TICKS(stcb->asoc.initial_rto);
@ -1947,8 +1989,8 @@ sctp_timer_start(int t_type, struct sctp_inpcb *inp, struct sctp_tcb *stcb,
* Here we use the endpoints shutdown guard timer usually
* about 3 minutes.
*/
if (stcb == NULL) {
return (EFAULT);
if ((inp == NULL) || (stcb == NULL)) {
return;
}
to_ticks = inp->sctp_ep.sctp_timeoutticks[SCTP_TIMER_MAXSHUTDOWN];
tmr = &stcb->asoc.shut_guard_timer;
@ -1959,7 +2001,7 @@ sctp_timer_start(int t_type, struct sctp_inpcb *inp, struct sctp_tcb *stcb,
* the RTO.
*/
if ((stcb == NULL) || (net == NULL)) {
return (EFAULT);
return;
}
if (net->RTO == 0) {
to_ticks = MSEC_TO_TICKS(stcb->asoc.initial_rto);
@ -1974,11 +2016,11 @@ sctp_timer_start(int t_type, struct sctp_inpcb *inp, struct sctp_tcb *stcb,
unsigned int msec;
if ((stcb == NULL) || (net == NULL)) {
return (EFAULT);
return;
}
if (net->flight_size > net->cwnd) {
/* no need to start */
return (0);
return;
}
SCTP_STAT_INCR(sctps_earlyfrstart);
if (net->lastsa == 0) {
@ -2003,7 +2045,7 @@ sctp_timer_start(int t_type, struct sctp_inpcb *inp, struct sctp_tcb *stcb,
* the RTO.
*/
if ((stcb == NULL) || (net == NULL)) {
return (EFAULT);
return;
}
if (net->RTO == 0) {
to_ticks = MSEC_TO_TICKS(stcb->asoc.initial_rto);
@ -2014,43 +2056,35 @@ sctp_timer_start(int t_type, struct sctp_inpcb *inp, struct sctp_tcb *stcb,
break;
case SCTP_TIMER_TYPE_AUTOCLOSE:
if (stcb == NULL) {
return (EFAULT);
return;
}
if (stcb->asoc.sctp_autoclose_ticks == 0) {
/*
* Really an error since stcb is NOT set to
* autoclose
*/
return (0);
return;
}
to_ticks = stcb->asoc.sctp_autoclose_ticks;
tmr = &stcb->asoc.autoclose_timer;
break;
default:
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_TIMER1) {
printf("sctp_timer_start:Unknown timer type %d\n",
t_type);
}
#endif /* SCTP_DEBUG */
return (EFAULT);
SCTPDBG(SCTP_DEBUG_TIMER1, "%s: Unknown timer type %d\n",
__FUNCTION__, t_type);
return;
break;
};
if ((to_ticks <= 0) || (tmr == NULL)) {
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_TIMER1) {
printf("sctp_timer_start:%d:software error to_ticks:%d tmr:%p not set ??\n",
t_type, to_ticks, tmr);
}
#endif /* SCTP_DEBUG */
return (EFAULT);
SCTPDBG(SCTP_DEBUG_TIMER1, "%s: %d:software error to_ticks:%d tmr:%p not set ??\n",
__FUNCTION__, t_type, to_ticks, tmr);
return;
}
if (SCTP_OS_TIMER_PENDING(&tmr->timer)) {
/*
* we do NOT allow you to have it already running. if it is
* we leave the current one up unchanged
*/
return (EALREADY);
return;
}
/* At this point we can proceed */
if (t_type == SCTP_TIMER_TYPE_SEND) {
@ -2063,8 +2097,8 @@ sctp_timer_start(int t_type, struct sctp_inpcb *inp, struct sctp_tcb *stcb,
tmr->net = (void *)net;
tmr->self = (void *)tmr;
tmr->ticks = ticks;
SCTP_OS_TIMER_START(&tmr->timer, to_ticks, sctp_timeout_handler, tmr);
return (0);
(void)SCTP_OS_TIMER_START(&tmr->timer, to_ticks, sctp_timeout_handler, tmr);
return;
}
void
@ -2199,12 +2233,8 @@ sctp_timer_stop(int t_type, struct sctp_inpcb *inp, struct sctp_tcb *stcb,
tmr = &stcb->asoc.autoclose_timer;
break;
default:
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_TIMER1) {
printf("sctp_timer_stop:Unknown timer type %d\n",
t_type);
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_TIMER1, "%s: Unknown timer type %d\n",
__FUNCTION__, t_type);
break;
};
if (tmr == NULL) {
@ -2219,7 +2249,7 @@ sctp_timer_stop(int t_type, struct sctp_inpcb *inp, struct sctp_tcb *stcb,
*/
return;
}
if (t_type == SCTP_TIMER_TYPE_SEND) {
if ((t_type == SCTP_TIMER_TYPE_SEND) && (stcb != NULL)) {
stcb->asoc.num_send_timers_up--;
if (stcb->asoc.num_send_timers_up < 0) {
stcb->asoc.num_send_timers_up = 0;
@ -2429,7 +2459,7 @@ sctp_mtu_size_reset(struct sctp_inpcb *inp,
unsigned int eff_mtu, ovh;
#ifdef SCTP_PRINT_FOR_B_AND_M
printf("sctp_mtu_size_reset(%p, asoc:%p mtu:%d\n",
SCTP_PRINTF("sctp_mtu_size_reset(%p, asoc:%p mtu:%d\n",
inp, asoc, mtu);
#endif
asoc->smallest_mtu = mtu;
@ -2701,7 +2731,8 @@ sctp_notify_assoc_change(uint32_t event, struct sctp_tcb *stcb,
* socket rcv queue.
*/
if ((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) ||
if ((stcb == NULL) ||
(stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) ||
(stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) ||
(stcb->asoc.state & SCTP_STATE_CLOSED_SOCKET)
) {
@ -2775,7 +2806,7 @@ sctp_notify_peer_addr_change(struct sctp_tcb *stcb, uint32_t state,
struct sctp_paddr_change *spc;
struct sctp_queued_to_read *control;
if (sctp_is_feature_off(stcb->sctp_ep, SCTP_PCB_FLAGS_RECVPADDREVNT))
if ((stcb == NULL) || (sctp_is_feature_off(stcb->sctp_ep, SCTP_PCB_FLAGS_RECVPADDREVNT)))
/* event not enabled */
return;
@ -2840,7 +2871,7 @@ sctp_notify_send_failed(struct sctp_tcb *stcb, uint32_t error,
struct sctp_queued_to_read *control;
int length;
if (sctp_is_feature_off(stcb->sctp_ep, SCTP_PCB_FLAGS_RECVSENDFAILEVNT))
if ((stcb == NULL) || (sctp_is_feature_off(stcb->sctp_ep, SCTP_PCB_FLAGS_RECVSENDFAILEVNT)))
/* event not enabled */
return;
@ -2905,7 +2936,7 @@ sctp_notify_send_failed2(struct sctp_tcb *stcb, uint32_t error,
struct sctp_queued_to_read *control;
int length;
if (sctp_is_feature_off(stcb->sctp_ep, SCTP_PCB_FLAGS_RECVSENDFAILEVNT))
if ((stcb == NULL) || (sctp_is_feature_off(stcb->sctp_ep, SCTP_PCB_FLAGS_RECVSENDFAILEVNT)))
/* event not enabled */
return;
@ -2970,7 +3001,7 @@ sctp_notify_adaptation_layer(struct sctp_tcb *stcb,
struct sctp_adaptation_event *sai;
struct sctp_queued_to_read *control;
if (sctp_is_feature_off(stcb->sctp_ep, SCTP_PCB_FLAGS_ADAPTATIONEVNT))
if ((stcb == NULL) || (sctp_is_feature_off(stcb->sctp_ep, SCTP_PCB_FLAGS_ADAPTATIONEVNT)))
/* event not enabled */
return;
@ -3017,7 +3048,7 @@ sctp_notify_partial_delivery_indication(struct sctp_tcb *stcb,
struct sctp_queued_to_read *control;
struct sockbuf *sb;
if (sctp_is_feature_off(stcb->sctp_ep, SCTP_PCB_FLAGS_PDAPIEVNT))
if ((stcb == NULL) || sctp_is_feature_off(stcb->sctp_ep, SCTP_PCB_FLAGS_PDAPIEVNT))
/* event not enabled */
return;
@ -3090,6 +3121,9 @@ sctp_notify_shutdown_event(struct sctp_tcb *stcb)
* For TCP model AND UDP connected sockets we will send an error up
* when an SHUTDOWN completes
*/
if (stcb == NULL) {
return;
}
if ((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
(stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL)) {
/* mark socket closed for read/write and wakeup! */
@ -3139,6 +3173,9 @@ sctp_notify_stream_reset(struct sctp_tcb *stcb,
struct sctp_stream_reset_event *strreset;
int len;
if (stcb == NULL) {
return;
}
if (sctp_is_feature_off(stcb->sctp_ep, SCTP_PCB_FLAGS_STREAM_RESETEVNT))
/* event not enabled */
return;
@ -3357,12 +3394,8 @@ sctp_ulp_notify(uint32_t notification, struct sctp_tcb *stcb,
default:
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_UTIL1) {
printf("NOTIFY: unknown notification %xh (%u)\n",
notification, notification);
}
#endif /* SCTP_DEBUG */
SCTPDBG(SCTP_DEBUG_UTIL1, "%s: unknown notification %xh (%u)\n",
__FUNCTION__, notification, notification);
break;
} /* end switch */
}
@ -3378,14 +3411,18 @@ sctp_report_all_outbound(struct sctp_tcb *stcb, int holds_lock)
asoc = &stcb->asoc;
if (stcb == NULL) {
return;
}
if ((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) ||
(stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) ||
(stcb->asoc.state & SCTP_STATE_CLOSED_SOCKET)) {
return;
}
/* now through all the gunk freeing chunks */
if (holds_lock == 0)
if (holds_lock == 0) {
SCTP_TCB_SEND_LOCK(stcb);
}
for (i = 0; i < stcb->asoc.streamoutcnt; i++) {
/* For each stream */
outs = &stcb->asoc.strmout[i];
@ -3470,14 +3507,18 @@ sctp_report_all_outbound(struct sctp_tcb *stcb, int holds_lock)
chk = TAILQ_FIRST(&asoc->sent_queue);
}
}
if (holds_lock == 0)
if (holds_lock == 0) {
SCTP_TCB_SEND_UNLOCK(stcb);
}
}
void
sctp_abort_notification(struct sctp_tcb *stcb, int error)
{
if (stcb == NULL) {
return;
}
if ((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) ||
(stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) ||
(stcb->asoc.state & SCTP_STATE_CLOSED_SOCKET)) {
@ -3529,15 +3570,15 @@ sctp_print_out_track_log(struct sctp_tcb *stcb)
{
int i;
printf("Last ep reason:%x\n", stcb->sctp_ep->last_abort_code);
printf("IN bound TSN log-aaa\n");
SCTP_PRINTF("Last ep reason:%x\n", stcb->sctp_ep->last_abort_code);
SCTP_PRINTF("IN bound TSN log-aaa\n");
if ((stcb->asoc.tsn_in_at == 0) && (stcb->asoc.tsn_in_wrapped == 0)) {
printf("None rcvd\n");
SCTP_PRINTF("None rcvd\n");
goto none_in;
}
if (stcb->asoc.tsn_in_wrapped) {
for (i = stcb->asoc.tsn_in_at; i < SCTP_TSN_LOG_SIZE; i++) {
printf("TSN:%x strm:%d seq:%d flags:%x sz:%d\n",
SCTP_PRINTF("TSN:%x strm:%d seq:%d flags:%x sz:%d\n",
stcb->asoc.in_tsnlog[i].tsn,
stcb->asoc.in_tsnlog[i].strm,
stcb->asoc.in_tsnlog[i].seq,
@ -3547,7 +3588,7 @@ sctp_print_out_track_log(struct sctp_tcb *stcb)
}
if (stcb->asoc.tsn_in_at) {
for (i = 0; i < stcb->asoc.tsn_in_at; i++) {
printf("TSN:%x strm:%d seq:%d flags:%x sz:%d\n",
SCTP_PRINTF("TSN:%x strm:%d seq:%d flags:%x sz:%d\n",
stcb->asoc.in_tsnlog[i].tsn,
stcb->asoc.in_tsnlog[i].strm,
stcb->asoc.in_tsnlog[i].seq,
@ -3556,13 +3597,14 @@ sctp_print_out_track_log(struct sctp_tcb *stcb)
}
}
none_in:
printf("OUT bound TSN log-aaa\n");
if ((stcb->asoc.tsn_out_at == 0) && (stcb->asoc.tsn_out_wrapped == 0)) {
printf("None sent\n");
SCTP_PRINTF("OUT bound TSN log-aaa\n");
if ((stcb->asoc.tsn_out_at == 0) &&
(stcb->asoc.tsn_out_wrapped == 0)) {
SCTP_PRINTF("None sent\n");
}
if (stcb->asoc.tsn_out_wrapped) {
for (i = stcb->asoc.tsn_out_at; i < SCTP_TSN_LOG_SIZE; i++) {
printf("TSN:%x strm:%d seq:%d flags:%x sz:%d\n",
SCTP_PRINTF("TSN:%x strm:%d seq:%d flags:%x sz:%d\n",
stcb->asoc.out_tsnlog[i].tsn,
stcb->asoc.out_tsnlog[i].strm,
stcb->asoc.out_tsnlog[i].seq,
@ -3572,7 +3614,7 @@ sctp_print_out_track_log(struct sctp_tcb *stcb)
}
if (stcb->asoc.tsn_out_at) {
for (i = 0; i < stcb->asoc.tsn_out_at; i++) {
printf("TSN:%x strm:%d seq:%d flags:%x sz:%d\n",
SCTP_PRINTF("TSN:%x strm:%d seq:%d flags:%x sz:%d\n",
stcb->asoc.out_tsnlog[i].tsn,
stcb->asoc.out_tsnlog[i].strm,
stcb->asoc.out_tsnlog[i].seq,
@ -3804,13 +3846,14 @@ sctp_cmpaddr(struct sockaddr *sa1, struct sockaddr *sa2)
void
sctp_print_address(struct sockaddr *sa)
{
char ip6buf[INET6_ADDRSTRLEN];
ip6buf[0] = 0;
if (sa->sa_family == AF_INET6) {
struct sockaddr_in6 *sin6;
char ip6buf[INET6_ADDRSTRLEN];
sin6 = (struct sockaddr_in6 *)sa;
printf("IPv6 address: %s:port:%d scope:%u\n",
SCTP_PRINTF("IPv6 address: %s:port:%d scope:%u\n",
ip6_sprintf(ip6buf, &sin6->sin6_addr),
ntohs(sin6->sin6_port),
sin6->sin6_scope_id);
@ -3820,10 +3863,10 @@ sctp_print_address(struct sockaddr *sa)
sin = (struct sockaddr_in *)sa;
p = (unsigned char *)&sin->sin_addr;
printf("IPv4 address: %u.%u.%u.%u:%d\n",
SCTP_PRINTF("IPv4 address: %u.%u.%u.%u:%d\n",
p[0], p[1], p[2], p[3], ntohs(sin->sin_port));
} else {
printf("?\n");
SCTP_PRINTF("?\n");
}
}
@ -3843,9 +3886,9 @@ sctp_print_address_pkt(struct ip *iph, struct sctphdr *sh)
fsa.sin_family = AF_INET;
fsa.sin_addr = iph->ip_dst;
fsa.sin_port = sh->dest_port;
printf("src: ");
SCTP_PRINTF("src: ");
sctp_print_address((struct sockaddr *)&lsa);
printf("dest: ");
SCTP_PRINTF("dest: ");
sctp_print_address((struct sockaddr *)&fsa);
} else if (iph->ip_v == (IPV6_VERSION >> 4)) {
struct ip6_hdr *ip6;
@ -3862,9 +3905,9 @@ sctp_print_address_pkt(struct ip *iph, struct sctphdr *sh)
fsa6.sin6_family = AF_INET6;
fsa6.sin6_addr = ip6->ip6_dst;
fsa6.sin6_port = sh->dest_port;
printf("src: ");
SCTP_PRINTF("src: ");
sctp_print_address((struct sockaddr *)&lsa6);
printf("dest: ");
SCTP_PRINTF("dest: ");
sctp_print_address((struct sockaddr *)&fsa6);
}
}
@ -4111,7 +4154,7 @@ sctp_append_to_readq(struct sctp_inpcb *inp,
}
if (end) {
/* message is complete */
if (control == stcb->asoc.control_pdapi) {
if (stcb && (control == stcb->asoc.control_pdapi)) {
stcb->asoc.control_pdapi = NULL;
}
control->held_length = 0;
@ -4132,6 +4175,9 @@ sctp_append_to_readq(struct sctp_inpcb *inp,
control->data = m;
control->tail_mbuf = tail;
}
if (stcb == NULL) {
control->do_not_ref_stcb = 1;
}
/*
* When we are appending in partial delivery, the cum-ack is used
* for the actual pd-api highest tsn on this mbuf. The true cum-ack
@ -4272,7 +4318,7 @@ sctp_release_pr_sctp_chunk(struct sctp_tcb *stcb, struct sctp_tmit_chunk *tp1,
ret_sz += sctp_release_pr_sctp_chunk(stcb, tp1, reason,
&stcb->asoc.send_queue);
} else {
printf("hmm, nothing on the send queue and no EOM?\n");
SCTP_PRINTF("hmm, nothing on the send queue and no EOM?\n");
}
}
return (ret_sz);
@ -4289,9 +4335,9 @@ sctp_find_ifa_in_ep(struct sctp_inpcb *inp, struct sockaddr *addr, int holds_loc
{
struct sctp_laddr *laddr;
if (holds_lock == 0)
if (holds_lock == 0) {
SCTP_INP_RLOCK(inp);
}
LIST_FOREACH(laddr, &inp->sctp_addr_list, sctp_nxt_addr) {
if (laddr->ifa == NULL)
continue;
@ -4301,8 +4347,9 @@ sctp_find_ifa_in_ep(struct sctp_inpcb *inp, struct sockaddr *addr, int holds_loc
if (((struct sockaddr_in *)addr)->sin_addr.s_addr ==
laddr->ifa->address.sin.sin_addr.s_addr) {
/* found him. */
if (holds_lock == 0)
if (holds_lock == 0) {
SCTP_INP_RUNLOCK(inp);
}
return (laddr->ifa);
break;
}
@ -4310,15 +4357,17 @@ sctp_find_ifa_in_ep(struct sctp_inpcb *inp, struct sockaddr *addr, int holds_loc
if (SCTP6_ARE_ADDR_EQUAL(&((struct sockaddr_in6 *)addr)->sin6_addr,
&laddr->ifa->address.sin6.sin6_addr)) {
/* found him. */
if (holds_lock == 0)
if (holds_lock == 0) {
SCTP_INP_RUNLOCK(inp);
}
return (laddr->ifa);
break;
}
}
}
if (holds_lock == 0)
if (holds_lock == 0) {
SCTP_INP_RUNLOCK(inp);
}
return (NULL);
}
@ -4367,11 +4416,11 @@ sctp_find_ifa_by_addr(struct sockaddr *addr, uint32_t vrf_id, int holds_lock)
hash_head = &vrf->vrf_addr_hash[(hash_of_addr & vrf->vrf_addr_hashmark)];
if (hash_head == NULL) {
printf("hash_of_addr:%x mask:%x table:%x - ",
SCTP_PRINTF("hash_of_addr:%x mask:%x table:%x - ",
(u_int)hash_of_addr, (u_int)vrf->vrf_addr_hashmark,
(u_int)(hash_of_addr & vrf->vrf_addr_hashmark));
sctp_print_address(addr);
printf("No such bucket for address\n");
SCTP_PRINTF("No such bucket for address\n");
if (holds_lock == 0)
SCTP_IPI_ADDR_UNLOCK();
@ -5192,7 +5241,7 @@ sctp_sorecvmsg(struct socket *so,
#ifdef INVARIANTS
panic("control->data not null at read eor?");
#else
printf("Strange, data left in the control buffer .. invarients would panic?\n");
SCTP_PRINTF("Strange, data left in the control buffer .. invarients would panic?\n");
sctp_m_freem(control->data);
control->data = NULL;
#endif

View File

@ -132,7 +132,7 @@ int sctp_init_asoc(struct sctp_inpcb *, struct sctp_association *, int, uint32_t
void sctp_fill_random_store(struct sctp_pcb *);
int
void
sctp_timer_start(int, struct sctp_inpcb *, struct sctp_tcb *,
struct sctp_nets *);
@ -272,16 +272,16 @@ sctp_free_bufspace(struct sctp_tcb *, struct sctp_association *,
#define sctp_free_bufspace(stcb, asoc, tp1, chk_cnt) \
do { \
if (tp1->data != NULL) { \
atomic_add_int(&((asoc)->chunks_on_out_queue), -chk_cnt); \
atomic_subtract_int(&((asoc)->chunks_on_out_queue), chk_cnt); \
if ((asoc)->total_output_queue_size >= tp1->book_size) { \
atomic_add_int(&((asoc)->total_output_queue_size), -tp1->book_size); \
atomic_subtract_int(&((asoc)->total_output_queue_size), tp1->book_size); \
} else { \
(asoc)->total_output_queue_size = 0; \
} \
if (stcb->sctp_socket && ((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) || \
(stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL))) { \
if (stcb->sctp_socket->so_snd.sb_cc >= tp1->book_size) { \
atomic_add_int(&((stcb)->sctp_socket->so_snd.sb_cc), -tp1->book_size); \
atomic_subtract_int(&((stcb)->sctp_socket->so_snd.sb_cc), tp1->book_size); \
} else { \
stcb->sctp_socket->so_snd.sb_cc = 0; \
} \
@ -294,16 +294,16 @@ do { \
#define sctp_free_spbufspace(stcb, asoc, sp) \
do { \
if (sp->data != NULL) { \
atomic_add_int(&(asoc)->chunks_on_out_queue, -1); \
atomic_subtract_int(&(asoc)->chunks_on_out_queue, 1); \
if ((asoc)->total_output_queue_size >= sp->length) { \
atomic_add_int(&(asoc)->total_output_queue_size,sp->length); \
atomic_subtract_int(&(asoc)->total_output_queue_size, sp->length); \
} else { \
(asoc)->total_output_queue_size = 0; \
} \
if (stcb->sctp_socket && ((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) || \
(stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL))) { \
if (stcb->sctp_socket->so_snd.sb_cc >= sp->length) { \
atomic_add_int(&stcb->sctp_socket->so_snd.sb_cc,sp->length); \
atomic_subtract_int(&stcb->sctp_socket->so_snd.sb_cc,sp->length); \
} else { \
stcb->sctp_socket->so_snd.sb_cc = 0; \
} \

View File

@ -109,12 +109,8 @@ sctp6_input(i_pak, offp, proto)
#endif /* NFAITH defined and > 0 */
SCTP_STAT_INCR(sctps_recvpackets);
SCTP_STAT_INCR_COUNTER64(sctps_inpackets);
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_INPUT1) {
printf("V6 input gets a packet iphlen:%d pktlen:%d\n", iphlen,
SCTP_HEADER_LEN((*i_pak)));
}
#endif
SCTPDBG(SCTP_DEBUG_INPUT1, "V6 input gets a packet iphlen:%d pktlen:%d\n",
iphlen, SCTP_HEADER_LEN((*i_pak)));
if (IN6_IS_ADDR_MULTICAST(&ip6->ip6_dst)) {
/* No multi-cast support in SCTP */
goto bad;
@ -141,13 +137,8 @@ sctp6_input(i_pak, offp, proto)
sh->checksum = 0; /* prepare for calc */
calc_check = sctp_calculate_sum(m, &mlen, iphlen);
if (calc_check != check) {
#ifdef SCTP_DEBUG
if (sctp_debug_on & SCTP_DEBUG_INPUT1) {
printf("Bad CSUM on SCTP packet calc_check:%x check:%x m:%p mlen:%d iphlen:%d\n",
calc_check, check, m,
mlen, iphlen);
}
#endif
SCTPDBG(SCTP_DEBUG_INPUT1, "Bad CSUM on SCTP packet calc_check:%x check:%x m:%p mlen:%d iphlen:%d\n",
calc_check, check, m, mlen, iphlen);
stcb = sctp_findassociation_addr(m, iphlen, offset - sizeof(*ch),
sh, ch, &in6p, &net, vrf_id);
/* in6p's ref-count increased && stcb locked */
@ -185,7 +176,10 @@ sctp6_input(i_pak, offp, proto)
init_chk = (struct sctp_init_chunk *)sctp_m_getptr(m,
iphlen + sizeof(*sh), sizeof(*init_chk),
(uint8_t *) & chunk_buf);
sh->v_tag = init_chk->init.initiate_tag;
if (init_chk)
sh->v_tag = init_chk->init.initiate_tag;
else
sh->v_tag = 0;
}
if (ch->chunk_type == SCTP_SHUTDOWN_ACK) {
sctp_send_shutdown_complete2(m, iphlen, sh, vrf_id,
@ -238,9 +232,9 @@ sctp6_input(i_pak, offp, proto)
return IPPROTO_DONE;
bad:
if (stcb)
if (stcb) {
SCTP_TCB_UNLOCK(stcb);
}
if ((in6p) && refcount_up) {
/* reduce ref-count */
SCTP_INP_WLOCK(in6p);
@ -249,9 +243,6 @@ sctp6_input(i_pak, offp, proto)
}
if (m)
sctp_m_freem(m);
/* For BSD/MAC this does nothing */
SCTP_DETACH_HEADER_FROM_CHAIN(*i_pak);
SCTP_RELEASE_HEADER(*i_pak);
return IPPROTO_DONE;
}
@ -327,8 +318,9 @@ sctp6_notify_mbuf(struct sctp_inpcb *inp,
}
sctp_timer_start(SCTP_TIMER_TYPE_PATHMTURAISE, inp, stcb, NULL);
out:
if (stcb)
if (stcb) {
SCTP_TCB_UNLOCK(stcb);
}
}
@ -889,7 +881,7 @@ sctp6_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr,
/* now what about control */
if (control) {
if (inp->control) {
printf("huh? control set?\n");
SCTP_PRINTF("huh? control set?\n");
SCTP_RELEASE_PKT(inp->control);
inp->control = NULL;
}
@ -1003,8 +995,9 @@ sctp6_connect(struct socket *so, struct sockaddr *addr, struct thread *p)
/* Now do we connect? */
if (inp->sctp_flags & SCTP_PCB_FLAGS_CONNECTED) {
stcb = LIST_FIRST(&inp->sctp_asoc_list);
if (stcb)
if (stcb) {
SCTP_TCB_UNLOCK(stcb);
}
SCTP_INP_RUNLOCK(inp);
} else {
SCTP_INP_RUNLOCK(inp);
@ -1038,7 +1031,7 @@ sctp6_connect(struct socket *so, struct sockaddr *addr, struct thread *p)
soisconnecting(so);
}
stcb->asoc.state = SCTP_STATE_COOKIE_WAIT;
SCTP_GETTIME_TIMEVAL(&stcb->asoc.time_entered);
(void)SCTP_GETTIME_TIMEVAL(&stcb->asoc.time_entered);
/* initialize authentication parameters for the assoc */
sctp_initialize_auth_params(inp, stcb);
@ -1174,8 +1167,9 @@ sctp6_peeraddr(struct socket *so, struct sockaddr **addr)
}
SCTP_INP_RLOCK(inp);
stcb = LIST_FIRST(&inp->sctp_asoc_list);
if (stcb)
if (stcb) {
SCTP_TCB_LOCK(stcb);
}
SCTP_INP_RUNLOCK(inp);
if (stcb == NULL) {
SCTP_FREE_SONAME(sin6);