server: Log connection establishment from bankd/client; warn on localhost

If a bankd connects to the server from 127.0.0.0/8, then clients will
not be able to reach it unless they also run on localhost.  Warn the
user.

Change-Id: I5446752961b039dad54aec981c1df4814779f765
This commit is contained in:
Harald Welte 2022-04-27 09:15:43 +02:00
parent 5ae0f31c31
commit fb48de8968
1 changed files with 14 additions and 0 deletions

View File

@ -123,6 +123,12 @@ static void clnt_st_established(struct osmo_fsm_inst *fi, uint32_t event, void *
const ConnectClientReq_t *cclreq = NULL;
const ConnectBankReq_t *cbreq = NULL;
RsproPDU_t *resp = NULL;
char ip_str[INET6_ADDRSTRLEN];
char port_str[6];
/* remote IP and port */
osmo_sock_get_ip_and_port(conn->peer->ofd.fd, ip_str, sizeof(ip_str),
port_str, sizeof(port_str), false);
switch (event) {
case CLNTC_E_CLIENT_CONN:
@ -161,6 +167,7 @@ static void clnt_st_established(struct osmo_fsm_inst *fi, uint32_t event, void *
osmo_fsm_inst_update_id_f(conn->keepalive_fi, "C%u:%u",
conn->client.slot.client_id,
conn->client.slot.slot_nr);
LOGPFSML(fi, LOGL_INFO, "Client connected from %s:%s\n", ip_str, port_str);
resp = rspro_gen_ConnectClientRes(&conn->srv->comp_id, ResultCode_ok);
client_conn_send(conn, resp);
osmo_fsm_inst_state_chg(fi, CLNTC_ST_CONNECTED_CLIENT, 0, 0);
@ -180,6 +187,13 @@ static void clnt_st_established(struct osmo_fsm_inst *fi, uint32_t event, void *
osmo_fsm_inst_update_id_f(fi, "B%u", conn->bank.bank_id);
osmo_fsm_inst_update_id_f(conn->keepalive_fi, "B%u", conn->bank.bank_id);
LOGPFSML(fi, LOGL_INFO, "Bankd connected from %s:%s\n", ip_str, port_str);
if (!strncmp(ip_str, "127.", 4)) {
LOGPFSML(fi, LOGL_NOTICE, "Bankd connected from %s (localhost). "
"This only works if your clients also all are on localhost, "
"as they must be able to reach the bankd!\n", ip_str);
}
/* reparent us from srv->connections to srv->banks */
pthread_rwlock_wrlock(&conn->srv->rwlock);
llist_del(&conn->list);