laforge submitted this change.

View Change

Approvals: Jenkins Builder: Verified laforge: Looks good to me, approved
Check RSPRO component type; print error if type doesn't match

If one component connects to another component, verify that the
remote component type (bank/server/client) matches our expectation.

This is important in order to detect a misconfiguration of port numbers,
for example.

Closes: OS#5548
Change-Id: I89a4fc4331e8a0622f8f146c7fc235d34d990497
---
M src/bankd/bankd_main.c
M src/client/remsim_client.c
2 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/src/bankd/bankd_main.c b/src/bankd/bankd_main.c
index fcdbf76..9e2d8f8 100644
--- a/src/bankd/bankd_main.c
+++ b/src/bankd/bankd_main.c
@@ -174,6 +174,13 @@

switch (pdu->msg.present) {
case RsproPDUchoice_PR_connectBankRes:
+ if (pdu->msg.choice.connectBankRes.identity.type != ComponentType_remsimServer) {
+ LOGPFSML(srvc->fi, LOGL_ERROR, "Server connection to a ComponentType(%ld) != RemsimServer? "
+ "Check your IP/Port configuration\n",
+ pdu->msg.choice.connectBankRes.identity.type);
+ osmo_fsm_inst_dispatch(srvc->fi, SRVC_E_DISCONNECT, NULL);
+ return -1;
+ }
/* Store 'identity' of server in srvc->peer_comp_id */
rspro_comp_id_retrieve(&srvc->peer_comp_id, &pdu->msg.choice.connectBankRes.identity);
osmo_fsm_inst_dispatch(srvc->fi, SRVC_E_CLIENT_CONN_RES, (void *) pdu);
diff --git a/src/client/remsim_client.c b/src/client/remsim_client.c
index 8da82ef..247ae42 100644
--- a/src/client/remsim_client.c
+++ b/src/client/remsim_client.c
@@ -67,6 +67,13 @@

switch (pdu->msg.present) {
case RsproPDUchoice_PR_connectClientRes:
+ if (pdu->msg.choice.connectClientRes.identity.type != ComponentType_remsimBankd) {
+ LOGPFSML(bankdc->fi, LOGL_ERROR, "Server connection to a ComponentType(%ld) != RemsimBankd? "
+ "Check your IP/Port configuration\n",
+ pdu->msg.choice.connectClientRes.identity.type);
+ osmo_fsm_inst_dispatch(bankdc->fi, SRVC_E_DISCONNECT, NULL);
+ return -1;
+ }
/* Store 'identity' of bankd to in peer_comp_id */
rspro_comp_id_retrieve(&bankdc->peer_comp_id, &pdu->msg.choice.connectClientRes.identity);
osmo_fsm_inst_dispatch(bankdc->fi, SRVC_E_CLIENT_CONN_RES, (void *) pdu);
@@ -94,6 +101,13 @@

switch (pdu->msg.present) {
case RsproPDUchoice_PR_connectClientRes:
+ if (pdu->msg.choice.connectClientRes.identity.type != ComponentType_remsimServer) {
+ LOGPFSML(srvc->fi, LOGL_ERROR, "Server connection to a ComponentType(%ld) != RemsimServer? "
+ "Check your IP/Port configuration\n",
+ pdu->msg.choice.connectClientRes.identity.type);
+ osmo_fsm_inst_dispatch(srvc->fi, SRVC_E_DISCONNECT, NULL);
+ return -1;
+ }
/* Store 'identity' of server in srvc->peer_comp_id */
rspro_comp_id_retrieve(&srvc->peer_comp_id, &pdu->msg.choice.connectClientRes.identity);
osmo_fsm_inst_dispatch(srvc->fi, SRVC_E_CLIENT_CONN_RES, (void *) pdu);

To view, visit change 27929. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: osmo-remsim
Gerrit-Branch: master
Gerrit-Change-Id: I89a4fc4331e8a0622f8f146c7fc235d34d990497
Gerrit-Change-Number: 27929
Gerrit-PatchSet: 2
Gerrit-Owner: laforge <laforge@osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge@osmocom.org>
Gerrit-Reviewer: lynxis lazus <lynxis@fe80.eu>
Gerrit-MessageType: merged