[MERGED] osmo-bts[master]: osmo-bts-virtual: Shut down gracefully on socket creation fa...

Harald Welte gerrit-no-reply at lists.osmocom.org
Thu Feb 22 11:19:41 UTC 2018


Harald Welte has submitted this change and it was merged.

Change subject: osmo-bts-virtual: Shut down gracefully on socket creation failure
......................................................................


osmo-bts-virtual: Shut down gracefully on socket creation failure

Don't simply crash if creation of the multicast socket fails

Change-Id: Ie87b6684b3aa7f21742e4cf21533e980485c1230
---
M src/osmo-bts-virtual/l1_if.c
M src/osmo-bts-virtual/virtual_um.c
2 files changed, 7 insertions(+), 2 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/osmo-bts-virtual/l1_if.c b/src/osmo-bts-virtual/l1_if.c
index e7478a0..290e097 100644
--- a/src/osmo-bts-virtual/l1_if.c
+++ b/src/osmo-bts-virtual/l1_if.c
@@ -193,12 +193,12 @@
 	plink->u.virt.virt_um = virt_um_init(plink, plink->u.virt.ms_mcast_group, plink->u.virt.ms_mcast_port,
 					     plink->u.virt.bts_mcast_group, plink->u.virt.bts_mcast_port,
 					     virt_um_rcv_cb);
-	/* set back reference to plink */
-	plink->u.virt.virt_um->priv = plink;
 	if (!plink->u.virt.virt_um) {
 		phy_link_state_set(plink, PHY_LINK_SHUTDOWN);
 		return -1;
 	}
+	/* set back reference to plink */
+	plink->u.virt.virt_um->priv = plink;
 
 	/* iterate over list of PHY instances and initialize the scheduler */
 	llist_for_each_entry(pinst, &plink->instances, list) {
diff --git a/src/osmo-bts-virtual/virtual_um.c b/src/osmo-bts-virtual/virtual_um.c
index e8d4252..fd0940f 100644
--- a/src/osmo-bts-virtual/virtual_um.c
+++ b/src/osmo-bts-virtual/virtual_um.c
@@ -66,6 +66,11 @@
 	struct virt_um_inst *vui = talloc_zero(ctx, struct virt_um_inst);
 	vui->mcast_sock = mcast_bidir_sock_setup(ctx, tx_mcast_group, tx_mcast_port,
 						 rx_mcast_group, rx_mcast_port, 1, virt_um_fd_cb, vui);
+	if (!vui->mcast_sock) {
+		perror("Unable to create VirtualUm multicast socket");
+		talloc_free(vui);
+		return NULL;
+	}
 	vui->recv_cb = recv_cb;
 
 	return vui;

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ie87b6684b3aa7f21742e4cf21533e980485c1230
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder


More information about the gerrit-log mailing list