[PATCH] osmo-bts[master]: octphy: prevent mismatch between dsp-firmware and octphy hea...

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

dexter gerrit-no-reply at lists.osmocom.org
Thu Oct 6 14:03:43 UTC 2016


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

octphy: prevent mismatch between dsp-firmware and octphy headers

in its current statue l1_oml.c does not check if the version
number in the header files (octvc1_main_version.h) matches up
the version that is reported from the DSP during startip. This
patch ads a check to make sure that the currently loaded
firmware and the headers used during compile time match. If
a mismatch is detected, osmo-bts exits immediately.

Change-Id: Icba5756517d632d53b129c5ce1a1dab4936dab91
---
M src/osmo-bts-octphy/l1_oml.c
1 file changed, 20 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/12/1012/1

diff --git a/src/osmo-bts-octphy/l1_oml.c b/src/osmo-bts-octphy/l1_oml.c
index 88dc041..41acaaf 100644
--- a/src/osmo-bts-octphy/l1_oml.c
+++ b/src/osmo-bts-octphy/l1_oml.c
@@ -50,6 +50,7 @@
 #include <octphy/octvc1/gsm/octvc1_gsm_default.h>
 #include <octphy/octvc1/gsm/octvc1_gsm_id.h>
 #include <octphy/octvc1/main/octvc1_main_default.h>
+#include <octphy/octvc1/main/octvc1_main_version.h>
 
 int trx_locked = 0;
 
@@ -1209,28 +1210,41 @@
 	return l1if_req_compl(fl1h, msg, app_info_sys_compl_cb, 0);
 }
 
-static int app_info_compl_cb(struct octphy_hdl *fl1h, struct msgb *resp, void *data)
+static int app_info_compl_cb(struct octphy_hdl *fl1h, struct msgb *resp,
+			     void *data)
 {
+	char ver_hdr[32];
+
 	tOCTVC1_MAIN_MSG_APPLICATION_INFO_RSP *air =
 		(tOCTVC1_MAIN_MSG_APPLICATION_INFO_RSP *) resp->l2h;
 
-	/* in a completion call-back, we take msgb ownership and must
-	 * release it before returning */
+	sprintf(ver_hdr, "%02i.%02i.%02i-B%i", cOCTVC1_MAIN_VERSION_MAJOR,
+		cOCTVC1_MAIN_VERSION_MINOR, cOCTVC1_MAIN_VERSION_MAINTENANCE,
+		cOCTVC1_MAIN_VERSION_BUILD);
 
 	mOCTVC1_MAIN_MSG_APPLICATION_INFO_RSP_SWAP(air);
 
-	LOGP(DL1C, LOGL_INFO, "Rx APP-INFO.resp (name='%s', desc='%s', ver='%s')\n",
-		air->szName, air->szDescription, air->szVersion);
+	LOGP(DL1C, LOGL_INFO,
+	     "Rx APP-INFO.resp (name='%s', desc='%s', ver='%s', ver_hdr='%s')\n",
+	     air->szName, air->szDescription, air->szVersion, ver_hdr);
+
+	/* Bail if dsp firmware does not match up the header version info */
+	if (strcmp(air->szVersion, ver_hdr) != 0) {
+		LOGP(DL1C, LOGL_ERROR,
+		     "Invalid header-file / dsp-firmware combination, exiting...\n");
+		exit(1);
+	}
 
 	talloc_replace(fl1h->info.app.name, fl1h, air->szName);
 	talloc_replace(fl1h->info.app.description, fl1h, air->szDescription);
 	talloc_replace(fl1h->info.app.version, fl1h, air->szVersion);
 
+	/* in a completion call-back, we take msgb ownership and must
+	 * release it before returning */
 	msgb_free(resp);
 
 	return 0;
 }
-
 
 int l1if_check_app_version(struct gsm_bts_trx *trx)
 {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Icba5756517d632d53b129c5ce1a1dab4936dab91
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: dexter <pmaier at sysmocom.de>



More information about the gerrit-log mailing list