Change in libosmo-sccp[master]: Fix matching IPv6 anyaddr :: in osmo_ss7_asp_find_by_socket_addr

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
Thu Aug 27 14:52:10 UTC 2020


pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-sccp/+/19852 )


Change subject: Fix matching IPv6 anyaddr :: in osmo_ss7_asp_find_by_socket_addr
......................................................................

Fix matching IPv6 anyaddr :: in osmo_ss7_asp_find_by_socket_addr

Change-Id: I36dd8f1978e3b7b785660745378c9cf77a21a566
---
M src/osmo_ss7.c
1 file changed, 17 insertions(+), 3 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/52/19852/1

diff --git a/src/osmo_ss7.c b/src/osmo_ss7.c
index 6357be1..fd8bfdb 100644
--- a/src/osmo_ss7.c
+++ b/src/osmo_ss7.c
@@ -1256,6 +1256,7 @@
 	socklen_t sa_len_r = sizeof(sa_r);
 	char hostbuf_l[64], hostbuf_r[64];
 	uint16_t local_port, remote_port;
+	bool loc_is_v6, rem_is_v6;
 	int rc;
 	int i;
 
@@ -1287,6 +1288,8 @@
 	 */
 	chop_v4_mapped_on_v6_prefix(hostbuf_l);
 	chop_v4_mapped_on_v6_prefix(hostbuf_r);
+	loc_is_v6 = host_is_ipv6(hostbuf_l);
+	rem_is_v6 = host_is_ipv6(hostbuf_r);
 
 	/* check all instances for any ASP definition matching the
 	 * address combination of local/remote ip/port */
@@ -1299,8 +1302,13 @@
 				continue;
 
 			for (i = 0; i < asp->cfg.local.host_cnt; i++) {
-				bool is_any = !asp->cfg.local.host[i] || !strcmp(asp->cfg.local.host[i], "0.0.0.0");
-				if (is_any || !strcmp(asp->cfg.local.host[i], hostbuf_l))
+				bool iter_is_any;
+				bool iter_is_v6 = host_is_ipv6(asp->cfg.local.host[i]);
+				if (iter_is_v6 != loc_is_v6)
+					continue;
+				iter_is_any = iter_is_v6 ? host_is_ipv6_anyaddr(asp->cfg.local.host[i])
+							 : host_is_ipv4_anyaddr(asp->cfg.local.host[i]);
+				if (iter_is_any || !strcmp(asp->cfg.local.host[i], hostbuf_l))
 					break;
 			}
 			if (i == asp->cfg.local.host_cnt)
@@ -1309,7 +1317,13 @@
 			/* If no remote host was set, it's probably a server and hence we match any cli src */
 			if (asp->cfg.remote.host_cnt) {
 				for (i = 0; i < asp->cfg.remote.host_cnt; i++) {
-					if (!asp->cfg.remote.host[i] || !strcmp(asp->cfg.remote.host[i], hostbuf_r))
+					bool iter_is_any;
+					bool iter_is_v6 = host_is_ipv6(asp->cfg.remote.host[i]);
+					if (iter_is_v6 != rem_is_v6)
+						continue;
+					iter_is_any = iter_is_v6 ? host_is_ipv6_anyaddr(asp->cfg.remote.host[i])
+								 : host_is_ipv4_anyaddr(asp->cfg.remote.host[i]);
+					if (iter_is_any || !strcmp(asp->cfg.remote.host[i], hostbuf_r))
 						break;
 				}
 				if (i == asp->cfg.remote.host_cnt)

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

Gerrit-Project: libosmo-sccp
Gerrit-Branch: master
Gerrit-Change-Id: I36dd8f1978e3b7b785660745378c9cf77a21a566
Gerrit-Change-Number: 19852
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200827/0016d9d6/attachment.htm>


More information about the gerrit-log mailing list