Change in libosmo-abis[master]: Set local IP in ipa_server_link properly

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/.

Max gerrit-no-reply at lists.osmocom.org
Thu Jan 24 17:22:52 UTC 2019


Max has submitted this change and it was merged. ( https://gerrit.osmocom.org/12653 )

Change subject: Set local IP in ipa_server_link properly
......................................................................

Set local IP in ipa_server_link properly

When creating IPA link for server we might be called without explicit
address (which is legit - it means bind to all available
addresses). However in this case we won't have 'addr' field of
ipa_server_link initialized properly.

Fix this by following changes:

* don't copy NULL value as address
* use socket's local IP when no address set explicitly

Change-Id: I33679bb35f426d4cafb223b9200fccbf407e0cf6
---
M src/input/ipa.c
1 file changed, 10 insertions(+), 1 deletion(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/input/ipa.c b/src/input/ipa.c
index 09e3426..9853ffa 100644
--- a/src/input/ipa.c
+++ b/src/input/ipa.c
@@ -248,6 +248,7 @@
 static int ipa_server_fd_cb(struct osmo_fd *ofd, unsigned int what)
 {
 	int fd, ret;
+	char ipbuf[INET6_ADDRSTRLEN + 1];
 	struct sockaddr_in sa;
 	socklen_t sa_len = sizeof(sa);
 	struct ipa_server_link *link = ofd->data;
@@ -258,6 +259,13 @@
 			"peer, reason=`%s'\n", strerror(errno));
 		return fd;
 	}
+
+	if (!link->addr) {
+		ret = osmo_sock_get_local_ip(fd, ipbuf, INET6_ADDRSTRLEN + 1);
+		if (ret == 0)
+			link->addr = talloc_strdup(link, ipbuf);
+	}
+
 	LOGP(DLINP, LOGL_NOTICE, "accept()ed new link from %s to port %u\n",
 		inet_ntoa(sa.sin_addr), link->port);
 
@@ -290,7 +298,8 @@
 	ipa_link->ofd.when |= BSC_FD_READ | BSC_FD_WRITE;
 	ipa_link->ofd.cb = ipa_server_fd_cb;
 	ipa_link->ofd.data = ipa_link;
-	ipa_link->addr = talloc_strdup(ipa_link, addr);
+	if (addr)
+		ipa_link->addr = talloc_strdup(ipa_link, addr);
 	ipa_link->port = port;
 	ipa_link->accept_cb = accept_cb;
 	ipa_link->line = line;

-- 
To view, visit https://gerrit.osmocom.org/12653
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmo-abis
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I33679bb35f426d4cafb223b9200fccbf407e0cf6
Gerrit-Change-Number: 12653
Gerrit-PatchSet: 2
Gerrit-Owner: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Max <msuraev at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190124/ec039c9e/attachment.htm>


More information about the gerrit-log mailing list