bankd: Don't use 127.0.0.1 as default IP address for the server

If remsim-bankd connects via 127.0.0.1 or any other loopback-routed
IP address to the remsim-server, then the getpername() of remsim-server
for the bankd will also render 127.0.0.1, and subsequently that IP
address will be provided to remsim-client as address to connect to.

In almost all setups, remsim-client will be running on a remote node and
hence not able to reach remsim-bankd at 127.0.0.1.

Let's turn the server-IP into a mandatory command line argument of
remsim-bankd and not use a problematic default value.

Change-Id: I3deb05e31cdf35232cf9a118d5a5fcdb5d0ab601
This commit is contained in:
Harald Welte 2023-07-18 19:55:43 +02:00 committed by laforge
parent 7703150eaf
commit bfcca52af3
2 changed files with 16 additions and 7 deletions

View File

@ -61,7 +61,7 @@ approach seems to make more sense.
==== SYNOPSIS ==== SYNOPSIS
*osmo-remsim-bankd* [-h] [-V] [-d LOGOPT] [-i A.B.C.D] [-p <1-65535>] [-b <1-1023>] [-n <1-1023>] [-I A.B.C.D] [-P <1-65535> ] *osmo-remsim-bankd* [-h] [-V] [-d LOGOPT] -i A.B.C.D [-p <1-65535>] [-b <1-1023>] [-n <1-1023>] [-I A.B.C.D] [-P <1-65535> ]
==== OPTIONS ==== OPTIONS
@ -73,7 +73,9 @@ approach seems to make more sense.
Configure the logging verbosity, see <<remsim_logging>>. Configure the logging verbosity, see <<remsim_logging>>.
*-i, --server-host A.B.C.D*:: *-i, --server-host A.B.C.D*::
Specify the remote IP address/hostname of the `osmo-remsim-server` to Specify the remote IP address/hostname of the `osmo-remsim-server` to
which this bankd shall establish its RSPRO control connection which this bankd shall establish its RSPRO control connection. Do not specify a loopback
address or localhost, as this would in most cases result in a broken configuration where
a [usually remote] remsim-client attempts to reach the bankd via loopback, which doesn't work.
*-p, --server-port <1-65535>*:: *-p, --server-port <1-65535>*::
Specify the remote TCP port number of the `osmo-remsim-server` to which Specify the remote TCP port number of the `osmo-remsim-server` to which
this bankd shall establish its RSPRO control connection this bankd shall establish its RSPRO control connection

View File

@ -284,13 +284,13 @@ send_resp:
return 0; return 0;
} }
static void printf_help() static void printf_help(FILE *out)
{ {
printf( fprintf(out,
" -h --help Print this help message\n" " -h --help Print this help message\n"
" -V --version Print the version of the program\n" " -V --version Print the version of the program\n"
" -d --debug option Enable debug logging (e.g. DMAIN:DST2)\n" " -d --debug option Enable debug logging (e.g. DMAIN:DST2)\n"
" -i --server-host A.B.C.D remsim-server IP address (default: 127.0.0.1)\n" " -i --server-host A.B.C.D remsim-server IP address (mandatory)\n"
" -p --server-port <1-65535> remsim-server TCP port (default: 9998)\n" " -p --server-port <1-65535> remsim-server TCP port (default: 9998)\n"
" -b --bank-id <1-1023> Bank Identifier of this SIM bank (default: 1)\n" " -b --bank-id <1-1023> Bank Identifier of this SIM bank (default: 1)\n"
" -n --num-slots <1-1023> Number of Slots in this SIM bank (default: 8)\n" " -n --num-slots <1-1023> Number of Slots in this SIM bank (default: 8)\n"
@ -336,7 +336,7 @@ static void handle_options(int argc, char **argv)
switch (c) { switch (c) {
case 'h': case 'h':
printf_help(); printf_help(stdout);
exit(0); exit(0);
break; break;
case 'V': case 'V':
@ -397,7 +397,7 @@ int main(int argc, char **argv)
bankd_init(g_bankd); bankd_init(g_bankd);
srvc = &g_bankd->srvc; srvc = &g_bankd->srvc;
srvc->server_host = "localhost"; srvc->server_host = NULL;
srvc->server_port = 9998; srvc->server_port = 9998;
srvc->handle_rx = bankd_srvc_handle_rx; srvc->handle_rx = bankd_srvc_handle_rx;
srvc->own_comp_id.type = ComponentType_remsimBankd; srvc->own_comp_id.type = ComponentType_remsimBankd;
@ -407,6 +407,13 @@ int main(int argc, char **argv)
handle_options(argc, argv); handle_options(argc, argv);
if (!srvc->server_host) {
fprintf(stderr, "ERROR: You must specify the host name / IP of the remsim-server to which "
"the bankd shall connect to\n\n");
printf_help(stderr);
exit(2);
}
g_bankd->main = pthread_self(); g_bankd->main = pthread_self();
signal(SIGMAPDEL, handle_sig_mapdel); signal(SIGMAPDEL, handle_sig_mapdel);
signal(SIGMAPADD, handle_sig_mapadd); signal(SIGMAPADD, handle_sig_mapadd);