diff options
author | Harald Welte <laforge@gnumonks.org> | 2017-07-13 20:39:50 +0200 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2017-07-13 21:35:33 +0200 |
commit | 576408b651003ab6cd9da69e3c849ecc4148179e (patch) | |
tree | 5aaf0c49c9a46f6e335beaa5b3154c52ee9fcf26 /src | |
parent | e3b8279f26547b3af44fe11e1469a3b185a1278d (diff) |
VIRT-PHY: cause BTS to terminate in case of recv()/send() on udp socket returns 0
It is important that we reliably terminate the BTS in case any of the
VirtPHY multicast sockets dies for whatever reason.
Change-Id: I5ae3fdd7cc35fdf235550a3b8362020fdd287c13
Diffstat (limited to 'src')
-rw-r--r-- | src/osmo-bts-virtual/l1_if.c | 8 | ||||
-rw-r--r-- | src/osmo-bts-virtual/scheduler_virtbts.c | 7 | ||||
-rw-r--r-- | src/osmo-bts-virtual/virtual_um.c | 9 |
3 files changed, 19 insertions, 5 deletions
diff --git a/src/osmo-bts-virtual/l1_if.c b/src/osmo-bts-virtual/l1_if.c index 36b2748b..92121216 100644 --- a/src/osmo-bts-virtual/l1_if.c +++ b/src/osmo-bts-virtual/l1_if.c @@ -66,6 +66,13 @@ static struct phy_instance *phy_instance_by_arfcn(struct phy_link *plink, uint16 static void virt_um_rcv_cb(struct virt_um_inst *vui, struct msgb *msg) { struct phy_link *plink = (struct phy_link *)vui->priv; + struct phy_instance *pinst; + if (!msg) { + pinst = phy_instance_by_num(plink, 0); + bts_shutdown(pinst->trx->bts, "VirtPHY read socket died\n"); + return; + } + struct gsmtap_hdr *gh = msgb_l1(msg); uint32_t fn = ntohl(gh->frame_number); /* frame number of the rcv msg */ uint16_t arfcn = ntohs(gh->arfcn); /* arfcn of the cell we currently camp on */ @@ -77,7 +84,6 @@ static void virt_um_rcv_cb(struct virt_um_inst *vui, struct msgb *msg) uint8_t rsl_chantype; /* rsl chan type (8.58, 9.3.1) */ uint8_t link_id; /* rsl link id tells if this is an ssociated or dedicated link */ uint8_t chan_nr; /* encoded rsl channel type, timeslot and mf subslot */ - struct phy_instance *pinst; struct osmo_phsap_prim l1sap; memset(&l1sap, 0, sizeof(l1sap)); diff --git a/src/osmo-bts-virtual/scheduler_virtbts.c b/src/osmo-bts-virtual/scheduler_virtbts.c index 9b52864e..1338ce59 100644 --- a/src/osmo-bts-virtual/scheduler_virtbts.c +++ b/src/osmo-bts-virtual/scheduler_virtbts.c @@ -36,6 +36,7 @@ #include <osmo-bts/phy_link.h> #include <osmo-bts/logging.h> #include <osmo-bts/rsl.h> +#include <osmo-bts/bts.h> #include <osmo-bts/l1sap.h> #include <osmo-bts/amr.h> #include <osmo-bts/scheduler.h> @@ -93,9 +94,13 @@ static void tx_to_virt_um(struct l1sched_trx *l1t, uint8_t tn, uint32_t fn, if (outmsg) { struct phy_instance *pinst = trx_phy_instance(l1t->trx); struct gsmtap_hdr *gh = (struct gsmtap_hdr *)msgb_data(outmsg); + int rc; - if (virt_um_write_msg(pinst->phy_link->u.virt.virt_um, outmsg) == -1) + rc = virt_um_write_msg(pinst->phy_link->u.virt.virt_um, outmsg); + if (rc < 0) LOGP(DL1P, LOGL_ERROR, "%s GSMTAP msg could not send to virtual Um\n", gsmtap_hdr_stringify(gh)); + else if (rc == 0) + bts_shutdown(l1t->trx->bts, "VirtPHY write socket died\n"); else DEBUGP(DL1C, "%s Sending GSMTAP message to virtual Um\n", gsmtap_hdr_stringify(gh)); } else diff --git a/src/osmo-bts-virtual/virtual_um.c b/src/osmo-bts-virtual/virtual_um.c index e6b9615d..e8d42529 100644 --- a/src/osmo-bts-virtual/virtual_um.c +++ b/src/osmo-bts-virtual/virtual_um.c @@ -48,11 +48,12 @@ static int virt_um_fd_cb(struct osmo_fd *ofd, unsigned int what) msg->l1h = msgb_data(msg); /* call the l1 callback function for a received msg */ vui->recv_cb(vui, msg); - } else { - /* FIXME: this kind of error handling might be a bit harsh */ + } else if (rc == 0) { vui->recv_cb(vui, NULL); osmo_fd_close(ofd); - } + } else + perror("Read from multicast socket"); + } return 0; @@ -86,6 +87,8 @@ int virt_um_write_msg(struct virt_um_inst *vui, struct msgb *msg) rc = mcast_bidir_sock_tx(vui->mcast_sock, msgb_data(msg), msgb_length(msg)); + if (rc < 0) + perror("Writing to multicast socket"); msgb_free(msg); return rc; |