Skip to content

Commit

Permalink
Proper/additional check of tcp_no_new_conn_bflag
Browse files Browse the repository at this point in the history
Check the tcp_no_new_conn_bflag (to avoid opening TCP conns) when:
* sending a cancel to an invite (which was marked)
* sending a negative ACK to an invite (which was marked)
* sending an local UAC request (marked via local route)
  • Loading branch information
bogdan-iancu committed Feb 26, 2019
1 parent 738905d commit d3a0aaa
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions modules/tm/t_cancel.c
Expand Up @@ -110,13 +110,16 @@ void cancel_branch( struct cell *t, int branch )
crb->activ_type=TYPE_LOCAL_CANCEL;

LM_DBG("sending cancel...\n");
if (t->uac[branch].br_flags & tcp_no_new_conn_bflag)
tcp_no_new_conn = 1;
if (SEND_BUFFER( crb )==0) {
if ( has_tran_tmcbs( t, TMCB_REQUEST_BUILT|TMCB_MSG_SENT_OUT) ) {
set_extra_tmcb_params( &crb->buffer, &crb->dst);
run_trans_callbacks( TMCB_REQUEST_BUILT|TMCB_MSG_SENT_OUT,
t, t->uas.request, 0, 0);
}
}
tcp_no_new_conn = 0;

/*sets and starts the FINAL RESPONSE timer */
start_retr( crb );
Expand Down
5 changes: 5 additions & 0 deletions modules/tm/t_reply.c
Expand Up @@ -310,6 +310,9 @@ static int send_ack(struct sip_msg* rpl, struct cell *trans, int branch)
goto error;
}

if (trans->uac[branch].br_flags & tcp_no_new_conn_bflag)
tcp_no_new_conn = 1;

if(SEND_PR_BUFFER(&trans->uac[branch].request, ack_buf.s, ack_buf.len)==0){
/* successfully sent out */
if ( has_tran_tmcbs( trans, TMCB_MSG_SENT_OUT) ) {
Expand All @@ -319,6 +322,8 @@ static int send_ack(struct sip_msg* rpl, struct cell *trans, int branch)
}
}

tcp_no_new_conn = 0;

shm_free(ack_buf.s);

return 0;
Expand Down
5 changes: 5 additions & 0 deletions modules/tm/uac.c
Expand Up @@ -471,12 +471,17 @@ int t_uac(str* method, str* headers, str* body, dlg_t* dialog,
REF_UNSAFE(new_cell);
}

if (new_cell->uac[0].br_flags & tcp_no_new_conn_bflag)
tcp_no_new_conn = 1;

if (SEND_BUFFER(request) == -1) {
LM_ERR("attempt to send to '%.*s' failed\n",
dialog->hooks.next_hop->len,
dialog->hooks.next_hop->s);
}

tcp_no_new_conn = 0;

if (method->len==ACK_LEN && memcmp(method->s, ACK, ACK_LEN)==0 ) {
t_release_transaction(new_cell);
} else {
Expand Down

0 comments on commit d3a0aaa

Please sign in to comment.