Skip to content

Commit

Permalink
Proper inheriting of branch attributes during DNS-based failover.
Browse files Browse the repository at this point in the history
When creating a fake request based on an existing UAC entity, use the DST_URI and PATH_VEC specific to that UAC entity and not the per-message values.
This will correctly preserve the DST_URI and PATH_VEC during a DNS based failover, where the new branch must be a perfect copy of the original failed branch.

(cherry picked from commit 09473b3)
  • Loading branch information
bogdan-iancu committed Jan 14, 2020
1 parent ce4da02 commit fd15c1c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
5 changes: 4 additions & 1 deletion modules/tm/async.c
Expand Up @@ -93,9 +93,12 @@ int t_resume_async(int fd, void *param)
abort();
}

/* prepare for resume route */
/* prepare for resume route, by filling in a phony UAC structure to
* trigger the inheritance of the branch specific values */
uac.br_flags = getb0flags( t->uas.request ) ;
uac.uri = *GET_RURI( t->uas.request );
uac.duri = t->uas.request->dst_uri;
uac.path_vec = t->uas.request->path_vec;
if (!fake_req( &faked_req /* the fake msg to be built*/,
t->uas.request, /* the template msg saved in transaction */
&t->uas, /*the UAS side of the transaction*/
Expand Down
14 changes: 6 additions & 8 deletions modules/tm/t_msgbuilder.h
Expand Up @@ -227,23 +227,21 @@ static inline int fake_req(struct sip_msg *faked_req, struct sip_msg *shm_msg,
if (inherit_br_data) {
/* duplicate the dst_uri and path_vec into private mem
* so that they can be visible and changed at script level */
if (shm_msg->dst_uri.s) {
faked_req->dst_uri.s = pkg_malloc(shm_msg->dst_uri.len);
if (uac->duri.s) {
faked_req->dst_uri.s = pkg_malloc(uac->duri.len);
if (!faked_req->dst_uri.s) {
LM_ERR("out of pkg mem\n");
goto out;
}
memcpy(faked_req->dst_uri.s, shm_msg->dst_uri.s,
shm_msg->dst_uri.len);
memcpy(faked_req->dst_uri.s, uac->duri.s, uac->duri.len);
}
if (shm_msg->path_vec.s) {
faked_req->path_vec.s = pkg_malloc(shm_msg->path_vec.len);
if (uac->path_vec.s) {
faked_req->path_vec.s = pkg_malloc(uac->path_vec.len);
if (!faked_req->path_vec.s) {
LM_ERR("out of pkg mem\n");
goto out2;
}
memcpy(faked_req->path_vec.s, shm_msg->path_vec.s,
shm_msg->path_vec.len);
memcpy(faked_req->path_vec.s, uac->path_vec.s, uac->path_vec.len);
}
/* Q value was already copied as part of the sip_msg struct */
} else {
Expand Down

0 comments on commit fd15c1c

Please sign in to comment.