Skip to content

Commit

Permalink
MT#55283 add desired_family to call_monologue
Browse files Browse the repository at this point in the history
This is required to look up the correct interface during Redis restore.

Change-Id: I0ea67576deba95b4201c6384fdcf8051b84f879e
  • Loading branch information
rfuchs committed Oct 30, 2023
1 parent eaf4376 commit 531e720
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 5 deletions.
8 changes: 5 additions & 3 deletions daemon/call.c
Original file line number Diff line number Diff line change
Expand Up @@ -2053,8 +2053,10 @@ static void __tos_change(struct call *call, const struct sdp_ng_flags *flags) {
}

static void __init_interface(struct call_media *media, const str *ifname, int num_ports) {
if (!media->logical_intf && media->monologue)
if (!media->logical_intf)
media->logical_intf = media->monologue->logical_intf;
if (!media->desired_family)
media->desired_family = media->monologue->desired_family;
if (!media->logical_intf)
goto get;
if (media->logical_intf->preferred_family != media->desired_family)
Expand Down Expand Up @@ -2082,8 +2084,8 @@ static void __init_interface(struct call_media *media, const str *ifname, int nu
media->logical_intf = get_logical_interface(NULL, NULL, 0);
}
}
if (media->monologue)
media->monologue->logical_intf = media->logical_intf;
media->monologue->logical_intf = media->logical_intf;
media->monologue->desired_family = media->desired_family;
}


Expand Down
9 changes: 7 additions & 2 deletions daemon/redis.c
Original file line number Diff line number Diff line change
Expand Up @@ -1509,11 +1509,15 @@ static int redis_tags(struct call *c, struct redis_list *tags, JsonReader *root_
if (!redis_hash_get_int(&ii, rh, "ml_flags"))
ml->ml_flags = ii;

if (redis_hash_get_str(&s, rh, "desired_family"))
return -1;
ml->desired_family = get_socket_family_rfc(&s);

if (redis_hash_get_str(&s, rh, "logical_intf")
|| !(ml->logical_intf = get_logical_interface(&s, NULL, 0)))
|| !(ml->logical_intf = get_logical_interface(&s, ml->desired_family, 0)))
{
rlog(LOG_ERR, "unable to find specified local interface");
ml->logical_intf = get_logical_interface(NULL, NULL, 0);
ml->logical_intf = get_logical_interface(NULL, ml->desired_family, 0);
}

if (json_build_ssrc(ml, root_reader))
Expand Down Expand Up @@ -2474,6 +2478,7 @@ char* redis_encode_json(struct call *c) {
JSON_SET_SIMPLE("deleted", "%llu", (long long unsigned) ml->deleted);
JSON_SET_SIMPLE("block_dtmf", "%i", ml->block_dtmf);
JSON_SET_SIMPLE("ml_flags","%u", ml->ml_flags);
JSON_SET_SIMPLE_CSTR("desired_family", ml->desired_family ? ml->desired_family->rfc_name : "");
if (ml->logical_intf)
JSON_SET_SIMPLE_STR("logical_intf", &ml->logical_intf->name);

Expand Down
1 change: 1 addition & 0 deletions include/call.h
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,7 @@ struct call_monologue {
struct timeval started; /* for CDR */
struct timeval terminated; /* for CDR */
enum termination_reason term_reason;
sockfamily_t *desired_family;
const struct logical_intf *logical_intf;
GHashTable *associated_tags;
GQueue subscriptions; /* who am I subscribed to (sources) */
Expand Down
19 changes: 19 additions & 0 deletions t/auto-daemon-tests-redis.pl
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ sub redis_io {
'tag-0' => {
'block_dtmf' => '0',
'created' => qr/^\d+$/,
'desired_family' => 'IP4',
'deleted' => '0',
'logical_intf' => 'foo',
'ml_flags' => 0,
Expand All @@ -317,6 +318,7 @@ sub redis_io {
'tag-1' => {
'block_dtmf' => '0',
'created' => qr/^\d+$/,
'desired_family' => 'IP4',
'deleted' => '0',
'logical_intf' => 'foo',
'ml_flags' => 0,
Expand Down Expand Up @@ -566,6 +568,7 @@ sub redis_io {
'block_dtmf' => '0',
'created' => qr/^\d+$/,
'deleted' => '0',
'desired_family' => 'IP4',
'logical_intf' => 'foo',
'ml_flags' => 0,
'tag' => ft()
Expand All @@ -574,6 +577,7 @@ sub redis_io {
'block_dtmf' => '0',
'created' => qr/^\d+$/,
'deleted' => '0',
'desired_family' => 'IP4',
'logical_intf' => 'foo',
'ml_flags' => 0,
'tag' => tt()
Expand Down Expand Up @@ -831,6 +835,7 @@ sub redis_io {
'block_dtmf' => '0',
'created' => qr/^\d+$/,
'deleted' => '0',
'desired_family' => 'IP4',
'logical_intf' => 'foo',
'ml_flags' => 0,
'tag' => ft()
Expand All @@ -839,6 +844,7 @@ sub redis_io {
'block_dtmf' => '0',
'created' => qr/^\d+$/,
'deleted' => '0',
'desired_family' => 'IP4',
'logical_intf' => 'foo',
'ml_flags' => 0,
}
Expand Down Expand Up @@ -1090,6 +1096,7 @@ sub redis_io {
'block_dtmf' => '0',
'created' => qr/^\d+$/,
'deleted' => '0',
'desired_family' => 'IP4',
'logical_intf' => 'foo',
'ml_flags' => 0,
'tag' => ft()
Expand All @@ -1098,6 +1105,7 @@ sub redis_io {
'block_dtmf' => '0',
'created' => qr/^\d+$/,
'deleted' => '0',
'desired_family' => 'IP4',
'logical_intf' => 'foo',
'ml_flags' => 0,
'tag' => tt()
Expand Down Expand Up @@ -1535,6 +1543,7 @@ sub redis_io {
'block_dtmf' => '0',
'created' => qr/^\d+$/,
'deleted' => '0',
'desired_family' => 'IP4',
'logical_intf' => 'foo',
'ml_flags' => 0,
'tag' => ft()
Expand All @@ -1543,6 +1552,7 @@ sub redis_io {
'block_dtmf' => '0',
'created' => qr/^\d+$/,
'deleted' => '0',
'desired_family' => 'IP4',
'logical_intf' => 'foo',
'ml_flags' => 0,
'tag' => tt()
Expand All @@ -1551,6 +1561,7 @@ sub redis_io {
'block_dtmf' => '0',
'created' => qr/^\d+$/,
'deleted' => '0',
'desired_family' => 'IP4',
'logical_intf' => 'foo',
'ml_flags' => 0,
'tag' => qr//
Expand Down Expand Up @@ -1739,6 +1750,7 @@ sub redis_io {
'block_dtmf' => '0',
'created' => qr//,
'deleted' => '0',
'desired_family' => 'IP4',
'logical_intf' => 'foo',
'ml_flags' => 0,
'tag' => ft()
Expand Down Expand Up @@ -1978,6 +1990,7 @@ sub redis_io {
'block_dtmf' => '0',
'created' => qr//,
'deleted' => '0',
'desired_family' => 'IP4',
'logical_intf' => 'foo',
'ml_flags' => 0,
'tag' => ft()
Expand All @@ -1986,6 +1999,7 @@ sub redis_io {
'block_dtmf' => '0',
'created' => qr//,
'deleted' => '0',
'desired_family' => 'IP4',
'logical_intf' => 'foo',
'ml_flags' => 0,
'tag' => qr//,
Expand Down Expand Up @@ -2217,6 +2231,7 @@ sub redis_io {
'block_dtmf' => '0',
'created' => qr//,
'deleted' => '0',
'desired_family' => 'IP4',
'logical_intf' => 'foo',
'ml_flags' => 0,
'tag' => ft()
Expand All @@ -2225,6 +2240,7 @@ sub redis_io {
'block_dtmf' => '0',
'created' => qr//,
'deleted' => '0',
'desired_family' => 'IP4',
'logical_intf' => 'foo',
'ml_flags' => 0,
'tag' => qr//,
Expand Down Expand Up @@ -2549,6 +2565,7 @@ sub redis_io {
'block_dtmf' => '0',
'created' => qr//,
'deleted' => '0',
'desired_family' => 'IP4',
'logical_intf' => 'foo',
'ml_flags' => 0,
'tag' => ft()
Expand All @@ -2557,6 +2574,7 @@ sub redis_io {
'block_dtmf' => '0',
'created' => qr//,
'deleted' => '0',
'desired_family' => 'IP4',
'logical_intf' => 'foo',
'ml_flags' => 0,
'tag' => qr//,
Expand All @@ -2565,6 +2583,7 @@ sub redis_io {
'block_dtmf' => '0',
'created' => qr//,
'deleted' => '0',
'desired_family' => 'IP4',
'logical_intf' => 'foo',
'ml_flags' => 0,
'tag' => qr//,
Expand Down

0 comments on commit 531e720

Please sign in to comment.