[PATCH] osmo-iuh[master]: hnbgw: make Iuh bind address configurable via VTY

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

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Thu Aug 18 01:26:42 UTC 2016


Review at  https://gerrit.osmocom.org/711

hnbgw: make Iuh bind address configurable via VTY

Add config node hnbgw/iuh/bind, taking an IPv4 address.

Use this address to bind the Iuh server.

This is particularly useful for the ip.access nano3G, which is very sensitive
with SCTP addresses that don't respond to SCTP heartbeats. If the hnbgw listens
on 0.0.0.0, there will be SCTP heartbeats for all local interfaces on the
machine that the hnbgw runs on; the nano3G will interpret the "missing", or
rather, redundant heartbeat acks for the interfaces that aren't really related
to the Iuh server and assume a broken Iuh link, leading to an Iuh shutdown and
reconnection, looping every minute or so. By binding the hnbgw to only one
local interface, the SCTP addresses can be reduced and "missing" heartbeat acks
can be avoided.

Change-Id: Ie2749c152b878e17aa65dfb806826357d5c494f1
---
M src/hnbgw.c
M src/hnbgw.h
M src/hnbgw_vty.c
3 files changed, 38 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-iuh refs/changes/11/711/1

diff --git a/src/hnbgw.c b/src/hnbgw.c
index d2e7b30..4f23e8d 100644
--- a/src/hnbgw.c
+++ b/src/hnbgw.c
@@ -289,6 +289,14 @@
 	return 0;
 }
 
+const char *hnbgw_get_iuh_bind_addr(struct hnb_gw *gw)
+{
+	const char *addr = gw->config.iuh_bind_addr;
+	if (!addr)
+		addr = HNBGW_IUH_BIND_ADDR_DEFAULT;
+	return addr;
+}
+
 static const struct log_info_cat log_cat[] = {
 	[DMAIN] = {
 		.name = "DMAIN", .loglevel = LOGL_DEBUG, .enabled = 1,
@@ -480,6 +488,9 @@
 	g_hnb_gw->cnlink_cs = hnbgw_cnlink_init(g_hnb_gw, "127.0.0.1", SUA_PORT, 0);
 	g_hnb_gw->cnlink_ps = hnbgw_cnlink_init(g_hnb_gw, "127.0.0.2", SUA_PORT, 1);
 
+	LOGP(DMAIN, LOGL_NOTICE, "Listening for Iuh at %s %d\n",
+	     hnbgw_get_iuh_bind_addr(g_hnb_gw),
+	     g_hnb_gw->config.iuh_listen_port);
 	srv = osmo_stream_srv_link_create(tall_hnb_ctx);
 	if (!srv) {
 		perror("cannot create server");
@@ -487,7 +498,7 @@
 	}
 	osmo_stream_srv_link_set_data(srv, g_hnb_gw);
 	osmo_stream_srv_link_set_proto(srv, IPPROTO_SCTP);
-	osmo_stream_srv_link_set_addr(srv, "0.0.0.0");
+	osmo_stream_srv_link_set_addr(srv, hnbgw_get_iuh_bind_addr(g_hnb_gw));
 	osmo_stream_srv_link_set_port(srv, g_hnb_gw->config.iuh_listen_port);
 	osmo_stream_srv_link_set_accept_cb(srv, accept_cb);
 
diff --git a/src/hnbgw.h b/src/hnbgw.h
index 9b5ae85..21a9602 100644
--- a/src/hnbgw.h
+++ b/src/hnbgw.h
@@ -107,8 +107,11 @@
 	struct hnb_context *hnb;
 };
 
+#define HNBGW_IUH_BIND_ADDR_DEFAULT "0.0.0.0"
+
 struct hnb_gw {
 	struct {
+		const char *iuh_bind_addr;
 		/*! SCTP port for Iuh listening */
 		uint16_t iuh_listen_port;
 		/*! The UDP port where we receive multiplexed CS user
@@ -143,3 +146,9 @@
 void hnb_context_release(struct hnb_context *ctx);
 
 void hnbgw_vty_init(struct hnb_gw *gw, void *tall_ctx);
+
+/*
+ * Return IP address passed to the hnbgw/iuh/bind command, or
+ * IUH_BIND_ADDR_DEFAULT
+ */
+const char *hnbgw_get_iuh_bind_addr(struct hnb_gw *gw);
diff --git a/src/hnbgw_vty.c b/src/hnbgw_vty.c
index 0845ff7..1673c0c 100644
--- a/src/hnbgw_vty.c
+++ b/src/hnbgw_vty.c
@@ -105,6 +105,15 @@
 	return CMD_SUCCESS;
 }
 
+DEFUN(cfg_hnbgw_iuh_bind, cfg_hnbgw_iuh_bind_cmd, "bind A.B.C.D",
+      "Accept Iuh connections on local interface\n"
+      "Local interface IP address (default: " HNBGW_IUH_BIND_ADDR_DEFAULT ")")
+{
+	talloc_free((void*)g_hnb_gw->config.iuh_bind_addr);
+	g_hnb_gw->config.iuh_bind_addr = talloc_strdup(tall_hnb_ctx, argv[0]);
+	return CMD_SUCCESS;
+}
+
 static int config_write_hnbgw(struct vty *vty)
 {
 	vty_out(vty, "hnbgw%s", VTY_NEWLINE);
@@ -113,7 +122,14 @@
 
 static int config_write_hnbgw_iuh(struct vty *vty)
 {
+	const char *addr;
+
 	vty_out(vty, " iuh%s", VTY_NEWLINE);
+
+	addr = g_hnb_gw->config.iuh_bind_addr;
+	if (addr && (strcmp(addr, HNBGW_IUH_BIND_ADDR_DEFAULT) != 0))
+		vty_out(vty, "  bind %s%s", addr, VTY_NEWLINE);
+
 	return CMD_SUCCESS;
 }
 
@@ -129,6 +145,7 @@
 	install_element(HNBGW_NODE, &cfg_hnbgw_iuh_cmd);
 	install_node(&iuh_node, config_write_hnbgw_iuh);
 	vty_install_default(IUH_NODE);
+	install_element(IUH_NODE, &cfg_hnbgw_iuh_bind_cmd);
 
 	install_element_ve(&show_hnb_cmd);
 	install_element_ve(&show_ue_cmd);

-- 
To view, visit https://gerrit.osmocom.org/711
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie2749c152b878e17aa65dfb806826357d5c494f1
Gerrit-PatchSet: 1
Gerrit-Project: osmo-iuh
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>



More information about the gerrit-log mailing list