Change in libosmo-sccp[master]: Fix default ASP local addr if remote addr contains only IPv4

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

pespin gerrit-no-reply at lists.osmocom.org
Fri Sep 4 10:55:12 UTC 2020


pespin has submitted this change. ( https://gerrit.osmocom.org/c/libosmo-sccp/+/19932 )

Change subject: Fix default ASP local addr if remote addr contains only IPv4
......................................................................

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
---
M src/osmo_ss7_vty.c
1 file changed, 14 insertions(+), 2 deletions(-)

Approvals:
  laforge: Looks good to me, but someone else must approve
  lynxis lazus: Looks good to me, approved
  Jenkins Builder: Verified



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 <netdb.h>
 #include <arpa/inet.h>
 
+#include <osmocom/core/sockaddr_str.h>
+
 #include <osmocom/vty/vty.h>
 #include <osmocom/vty/command.h>
 #include <osmocom/vty/logging.h>
@@ -1842,8 +1844,18 @@
 		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");

-- 
To view, visit https://gerrit.osmocom.org/c/libosmo-sccp/+/19932
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmo-sccp
Gerrit-Branch: master
Gerrit-Change-Id: I33faf1291e9105bba2e816c01a6b4854cf13d5e0
Gerrit-Change-Number: 19932
Gerrit-PatchSet: 3
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: lynxis lazus <lynxis at fe80.eu>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200904/61f6c2cf/attachment.htm>


More information about the gerrit-log mailing list