From 44456920e567e67fb64cbfcac0c6842de6b03e78 Mon Sep 17 00:00:00 2001 From: Pau Espin Pedrol Date: Tue, 1 Sep 2020 14:19:10 +0200 Subject: Fix default ASP local addr if remote addr contains only IPv4 Otherwise it would end up attempting to connect "::" -> "1.2.3.4" which would fail during osmo_sock_init2_multiaddr(). If local address is unset (default), but only IPv4 addresses are set on the remote, then one must use "0.0.0.0" instead. Change-Id: I33faf1291e9105bba2e816c01a6b4854cf13d5e0 --- src/osmo_ss7_vty.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/osmo_ss7_vty.c b/src/osmo_ss7_vty.c index 109b94a..08e650e 100644 --- a/src/osmo_ss7_vty.c +++ b/src/osmo_ss7_vty.c @@ -29,6 +29,8 @@ #include #include +#include + #include #include #include @@ -1842,8 +1844,18 @@ int osmo_ss7_vty_go_parent(struct vty *vty) asp = vty->index; /* If no local addr was set */ if (!asp->cfg.local.host_cnt) { - /* "::" Covers both IPv4 and IPv6 */ - if (ipv6_sctp_supported("::", true)) + bool rem_has_v4 = false, rem_has_v6 = false; + int i; + for (i = 0; i < asp->cfg.remote.host_cnt; i++) { + if (osmo_ip_str_type(asp->cfg.remote.host[i]) == AF_INET6) + rem_has_v6 = true; + else + rem_has_v4 = true; + } + /* "::" Covers both IPv4 and IPv6, but if only IPv4 + * address are set on the remote side, IPv4 on the local + * side must be set too */ + if (ipv6_sctp_supported("::", true) && !(rem_has_v4 && !rem_has_v6)) osmo_ss7_asp_peer_add_host(&asp->cfg.local, asp, "::"); else osmo_ss7_asp_peer_add_host(&asp->cfg.local, asp, "0.0.0.0"); -- cgit v1.2.3